From 71f90b84ff0e0a05f9c45a10c9add510a0dc5b6e Mon Sep 17 00:00:00 2001 From: Rodrigo Delduca Date: Thu, 3 Oct 2024 13:43:04 -0300 Subject: [PATCH] Work in progress --- scripts/main.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/main.lua b/scripts/main.lua index a70a32e..70e3a08 100644 --- a/scripts/main.lua +++ b/scripts/main.lua @@ -11,7 +11,7 @@ engine:prefetch({ local player = engine:spawn("player") -player:set_action("run") +player:set_action("idle") player:set_placement(0, 580) local function loop(delta) @@ -37,7 +37,18 @@ player:on_update(function(self) end if engine:is_keydown(KeyEvent.space) then - velocity.y = -3 + velocity.y = -.8 + end + + if velocity:moving() then + self:set_action("run") + if velocity:right() then + self:set_flip(Flip.none) + elseif velocity:left() then + self:set_flip(Flip.horizontal) + end + elseif velocity:stationary() then + self:set_action("idle") end self:set_velocity(velocity)