diff --git a/code/debug.lua b/code/debug.lua index acc73fd..4c5ed2a 100644 --- a/code/debug.lua +++ b/code/debug.lua @@ -8,7 +8,7 @@ function DebugUI() love.graphics.print(light.pos.x,light.pos.x,light.pos.y+40) end - love.graphics.print("fps: "..fps_current, 10*textScale, 0*textScale, 0, textScale) + love.graphics.print("time: ".. tostring(math.floor(100*game.secondsSinceStart)/100) .." fps: "..fps_current, 10*textScale, 0*textScale, 0, textScale) love.graphics.print(--[["CPUtime: "..checkCPUTime("total")..", CPU: "..(math.floor(checkCPUTime("get")*10000)/100).."%,]] "memoryUsage: "..memoryUsage.."kB", 10*textScale, 20*textScale, 0, textScale) love.graphics.setColor(1,1,1) diff --git a/code/entities/player.lua b/code/entities/player.lua index 0c43581..490618f 100644 --- a/code/entities/player.lua +++ b/code/entities/player.lua @@ -16,8 +16,6 @@ function Player:New(x,y) o.jumpImpulse = 3.5 -- gameworld pixels - o.wallJumpImpulse = { x = 2.5, y = 3.5 } - o.coyoteValue = 5 -- frames o.coyoteAmount = 5 -- int @@ -40,7 +38,9 @@ function Player:New(x,y) } -- walljump values - o.walljumpNoDriftAmount = 7 + o.walljumpNoDriftAmount = 12 + o.walljumpImpulse = { x = 2.5, y = 3.5 } + o.walljumpFriction = 0.3 -- gameworld pixels -- light values o.lightRange = 40 -- screen pixels @@ -54,8 +54,9 @@ function Player:New(x,y) o.isDashing = false o.isHooked = false + o.isSliding = false o.isJumping = false - o.isOnGround = true + o.isOnGround = false o.isOnLadder = false o.maskType = animation.moth_mask @@ -111,13 +112,16 @@ function Player:Smart() -- jump if on ground (coyotevalue) or if 0 if self.canJump and Keybind:CheckPressed(Keybind.move.jump) then - if self.coyoteValue > 0 then + if self.canWalljump and self.wallHit ~= 0 then + self.isSliding = false + self.vel.y = -self.walljumpImpulse.y + self.vel.x = -self.walljumpImpulse.x * self.wallHit + self.move_x = 0 + self.sprite_flip.x = -self.sprite_flip.x + self.noDriftFrames = self.walljumpNoDriftAmount + elseif self.coyoteValue > 0 then self.vel.y = -self.jumpImpulse self.coyoteValue = 0 - elseif self.canWalljump and self.wallHit ~= 0 then - self.vel.y = -self.wallJumpImpulse.y - self.vel.x = -self.wallJumpImpulse.x * self.wallHit - self.noDriftFrames = self.walljumpNoDriftAmount end end end @@ -183,7 +187,13 @@ function Player:DoPhysics() self.vel.x = self.vel.x * (1-self.airFriction) end - self.vel.y = self.vel.y * (1-self.airFriction) + self.isSliding = false + if self.wallHit == 0 then + self.vel.y = self.vel.y * (1-self.airFriction) + elseif self.noDriftFrames ~= self.walljumpNoDriftAmount then + self.isSliding = true + self.vel.y = self.vel.y * (1-self.walljumpFriction) + end if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end end @@ -301,7 +311,7 @@ function Player:HandleAnimation() end -- animation priority - if self.vel.y > 1.25 then + if self.vel.y > 1.25 or self.isSliding then self.body = self.body:ChangeTo(animation.nancy.fall) self.mask = self.mask:ChangeTo(self.maskType.fall) elseif self.vel.y < 0 then @@ -346,5 +356,6 @@ function Player:Unhook() end function Player:Debug() + Entity.Debug(self) love.graphics.print("wallHit: "..self.wallHit) end diff --git a/main.lua b/main.lua index fe4f081..89d5344 100644 --- a/main.lua +++ b/main.lua @@ -17,6 +17,7 @@ function love.load() love.graphics.setDefaultFilter("nearest") -- good pixel game = { + secondsSinceStart = 0, scale = 2, width = love.graphics.getWidth(), height = love.graphics.getHeight(), @@ -68,6 +69,7 @@ function love.update(dt) fps_current = fps_history:Push(1/dt) current_dt = dt + game.secondsSinceStart = game.secondsSinceStart + dt if DemoRecording or DemoPlayback then Demo:Step() end