editor progress, generic keybinds, player coyote value, cursed book entity, level changes, camera adjustments

This commit is contained in:
lustlion
2022-01-29 08:49:45 +01:00
parent 90ed1f6460
commit a1bf842cef
41 changed files with 387 additions and 154 deletions

View File

@@ -7,37 +7,40 @@
Player.coins = 0
-- physics
o.moveSpeed = 1.3
o.zeroSpeed = 0.01
o.move_x = 0
o.moveSpeed = 1.3 -- gameworld pixels
o.zeroSpeed = 0.01 -- gameworld pixels
o.move_x = 0 -- gameworld pixels
o.airFriction = 0.01
o.groundFriction = 0.3
o.airFriction = 0.01 -- gameworld pixels
o.groundFriction = 0.3 -- gameworld pixels
o.jumpImpulse = 3.5
o.jumpImpulse = 3.5 -- gameworld pixels
o.dashCooldownTime = 0.1
o.dashCooldownTimer = 0
o.coyoteAmount = 5 -- int
o.coyoteValue = 5 -- frames
o.dashTimer = 0
o.dashTime = 0.15
o.dashDistance = 40
o.dashSpeed = o.dashDistance / (o.dashTime*60)
o.dashCount = 1
o.dashCooldownTime = 0.1 -- seconds
o.dashCooldownTimer = 0 -- seconds
o.dashTimer = 0 -- seconds
o.dashTime = 0.15 -- seconds
o.dashDistance = 40 -- gameworld pixels
o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels
o.dashCount = 1 -- int
o.dashAmount = 0 -- int
o.boxCollision = {
from = {x = -8, y = -16},
to = {x = 8, y = 0}
from = {x = -8, y = -16}, --gameworld pixels
to = {x = 8, y = 0} -- gameworld pixels
}
o.lightRange = 0--32
o.lightRange = 344 -- screen pixels
-- status
o.isDashing = false
o.isJumping = false
o.isOnGround = 0
o.coyoteValue = 5
o.isOnLadder = false
o.isOnGround = true
o.isOnLadder = false
o.canJump = true
o.canFall = true
o.canFriction = true
@@ -48,7 +51,7 @@
o.body = Animation:New(animation.nancy.idle)
o.mask = Animation:New(animation.moth_mask.idle)
o:centerOffset(o.body)
o:getBoundingBox(o.body, 3,-3,0,-1)
o:getBoundingBox(o.body,0,3,-1,-3)
-- lights
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
@@ -85,12 +88,19 @@ function Player:Smart()
self.vel.x = self.vel.x
if Keybind:CheckDown(Keybind.move.jump) then
if self.isOnGround then
if self.coyoteValue > 0 then
self.vel.y = -self.jumpImpulse
self.coyoteValue = 0
end
end
end
if self.isOnGround then
self.coyoteValue = self.coyoteAmount
elseif self.coyoteValue > 0 then
self.coyoteValue = self.coyoteValue - 1
end
self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt)
if Keybind:CheckDown(Keybind.move.dash) then
if self.dashCooldownTimer == 0
@@ -118,14 +128,14 @@ function Player:Smart()
end
function Player:DoPhysics()
-- reset state
self.isOnGround = false
-- adjust timers
self.dashTimer = self.dashTimer - current_dt
-- DASH STATE
if self.dashTimer > 0 then
-- dash particle
local particle_data = {
animation = self.body,
sprite_tint = HEX2RGB("#fed100"),
@@ -137,9 +147,11 @@ function Player:DoPhysics()
}
Particle:New(self.pos.x,self.pos.y,particle_data)
self.dashCooldownTimer = self.dashCooldownTime
-- dash movement
self.vel.x = self.dashSpeed * math.cos(self.dashDirection)
self.vel.y = self.dashSpeed * math.sin(self.dashDirection)
else
-- not in dash; fall normally
self.dashTimer = 0
self.vel.y = self.vel.y + gravity
end
@@ -155,7 +167,7 @@ function Player:DoPhysics()
else
if self.vel.y > 0 then
self.isOnGround = true
self.dashCount = 1
self.dashCount = self.dashAmount
self.vel.y = 0
end
end