fixed dash timer bad when lag

This commit is contained in:
lustlion 2022-02-27 03:02:06 +01:00
parent ce43e48723
commit e62eae1564
2 changed files with 6 additions and 5 deletions

View File

@ -16,10 +16,10 @@ function Player:New(x,y)
o.jumpImpulse = 3.5 -- gameworld pixels o.jumpImpulse = 3.5 -- gameworld pixels
self.wallJumpImpulse = { x = 2.5, y = 3.5 } o.wallJumpImpulse = { x = 2.5, y = 3.5 }
o.coyoteAmount = 5 -- int
o.coyoteValue = 5 -- frames o.coyoteValue = 5 -- frames
o.coyoteAmount = 5 -- int
o.dashCooldownTime = 0.1 -- seconds o.dashCooldownTime = 0.1 -- seconds
o.dashCooldownTimer = 0 -- seconds o.dashCooldownTimer = 0 -- seconds
@ -151,7 +151,7 @@ function Player:Smart()
-- set dash values -- set dash values
self.dashDirection = GetAngleFromVector(horizontal, vertical) self.dashDirection = GetAngleFromVector(horizontal, vertical)
self.dashTimer = self.dashTime self.dashTimer = math.floor(self.dashTime * game.framerate)
end end
else else
-- not dashing! -- not dashing!
@ -193,7 +193,7 @@ function Player:DoPhysics()
self.isOnGround = false self.isOnGround = false
-- adjust timers -- adjust timers
self.dashTimer = self.dashTimer - current_dt self.dashTimer = self.dashTimer - 1
self.noDriftFrames = self.noDriftFrames - 1 self.noDriftFrames = self.noDriftFrames - 1
-- DASH STATE -- DASH STATE

View File

@ -22,7 +22,8 @@ function love.load()
game = { game = {
scale = 2, scale = 2,
width = love.graphics.getWidth(), width = love.graphics.getWidth(),
height = love.graphics.getHeight() height = love.graphics.getHeight(),
framerate = 60
} }
require "code/require" require "code/require"