From 3c1746d9149f2262c5f556ebe7acb68c77096ea3 Mon Sep 17 00:00:00 2001 From: lustlion Date: Sat, 12 Mar 2022 18:19:07 +0100 Subject: [PATCH] particles time to be handled in frames instead of seconds optionally --- code/entities/particle.lua | 10 ++++++++-- code/entities/player.lua | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/code/entities/particle.lua b/code/entities/particle.lua index 4291dda..03428dd 100644 --- a/code/entities/particle.lua +++ b/code/entities/particle.lua @@ -21,8 +21,14 @@ function Particle:new(x,y,particle_data) o.sprite_flip = particle_data.sprite_flip or o.sprite_flip o.time = particle_data.time or nil - if o.time ~= nil then o.time = o.time * game.framerate end - + if o.time ~= nil then + if particle_data.time_unit ~= nil + and particle_data.time_unit == "frames" then + o.time = o.time + else + o.time = o.time * game.framerate + end + end o.timer = 0 o.vel = { diff --git a/code/entities/player.lua b/code/entities/player.lua index be6ee03..0b89cff 100644 --- a/code/entities/player.lua +++ b/code/entities/player.lua @@ -251,7 +251,8 @@ function Player:doPhysics() animation_speed = 0, sprite_tint = hex2rgb("#fed100"), sprite_alpha = 0.5, - time = 0.05, + time = 4, + time_unit = "frames", sprite_flip = { x = self.sprite_flip.x, y = self.sprite_flip.y @@ -326,10 +327,10 @@ function Player:handleAnimation() elseif self.vel.y < 0 then self.body = self.body:change(animation.nancy.jump) self.mask = self.mask:change(self.mask_type.jump) - elseif self.vel.x + self.move_x ~= 0 then + elseif self.vel.x + self.move_x ~= 0 and not self.is_hooked then self.body = self.body:change(animation.nancy.run) self.mask = self.mask:change(self.mask_type.run) - else + elseif not self.is_hooked then self.body = self.body:change(animation.nancy.idle) self.mask = self.mask:change(self.mask_type.idle) end