aboutsummaryrefslogtreecommitdiff
path: root/src/objs/player.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/objs/player.lua')
-rw-r--r--src/objs/player.lua30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/objs/player.lua b/src/objs/player.lua
index 8ba664b..84e42f0 100644
--- a/src/objs/player.lua
+++ b/src/objs/player.lua
@@ -17,8 +17,28 @@ local function player_normal_state_update(player, state, dt)
player.vx = dlerp(player.vx, inputx * PLAYER_SPEED, PLAYER_ACCEL * dt)
player.vy = math.min(player.vy + GRAVITY * dt, TERMINAL_VELOCITY)
- if player.box:touching_down() and is_input_just_pressed("Jump") then
- player.vy = -PLAYER_JUMP_FORCE
+ if inputx ~= 0 then
+ player.sprite:set_tag("run")
+ elseif not player.box:touching_down() then
+ if player.vy < -100 then
+ player.sprite:set_tag("jump_up")
+ elseif player.vy > 100 then
+ player.sprite:set_tag("jump_down")
+ else
+ player.sprite:set_tag("jump_trans")
+ end
+ else
+ player.sprite:set_tag("idle")
+ end
+
+ if player.box:touching_down() then
+ if is_input_just_pressed("Jump") then
+ player.vy = -PLAYER_JUMP_FORCE
+ end
+ else
+ if is_input_just_released("Jump") and player.vy < -100 then
+ player.vy = -100
+ end
end
if state.dash_cooldown <= 0 and is_input_just_pressed("Dash") then
@@ -51,6 +71,12 @@ local function player_dash_state_exit(player, state, entering)
player.vx = player.vx / 2
end
+function player_update_sys(player, dt)
+ if player.vx ~= 0 then
+ player.scalex = sign(player.vx)
+ end
+end
+
function new_player(x, y)
local ent = new_entity()