kupo nice now

bow nice
aim nice
arrow nice

all nice
This commit is contained in:
lustlion
2021-10-25 01:41:40 +02:00
parent 5b7924fe4e
commit 1e1f9edb45
22 changed files with 348 additions and 82 deletions

View File

@@ -1,6 +1,44 @@
Player = Entity:New(x,y)
function Player:DoInput()
function Player:New(x,y)
local o = Entity:New(x,y)
Player.health = 3
Player.coins = 0
-- physics
o.vel = {
x = 0,
y = 0
}
-- constants
o.acc = 90
o.friction = 20
o.gravity = 9.81
o.climbHeight = 4
o.jumpForce = 5
o.maxSpeed = 600
o.jumpMaxSpeed = 9.5
o.zeroSpeed = 0.001
-- bools
o.isJumping = false
o.isOnGround = 0
o.coyoteValue = 10
o.isOnLadder = false
o.canJump = true
o.canFall = true
o.canFriction = true
-- sprite
o.sprite_offset = {x = 8, y = 16}
o.target_offset = {x = 4, y = 12}
setmetatable(o, self)
self.__index = self
return o
end
function Player:Smart()
-- PLATFORMER INPUT
if self.isOnGround > 0 then
-- apply friction
@@ -42,7 +80,7 @@ end
function Player:HandleAnimation()
-- flip sprite to look in the direction is moving
if self.vel.x ~= 0 then self.flip.x = math.sign(self.vel.x) end
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
-- animation manager
if self.isOnLadder then
@@ -163,40 +201,3 @@ function Player:DoPhysics()
self.vel.x = self.vel.x * (1 - math.min(current_dt * self.friction/20, 1))
end
end
function Player:New(x,y)
local o = Entity:New(x,y)
Player.health = 3
Player.coins = 0
-- physics
o.vel = {
x = 0,
y = 0
}
-- constants
o.acc = 90
o.friction = 20
o.gravity = 9.81
o.climbHeight = 4
o.jumpForce = 5
o.maxSpeed = 600
o.jumpMaxSpeed = 9.5
o.zeroSpeed = 0.001
-- bools
o.isJumping = false
o.isOnGround = 0
o.coyoteValue = 10
o.isOnLadder = false
o.canJump = true
o.canFall = true
o.canFriction = true
-- sprite
o.offset = {x = -8, y = -16}
setmetatable(o, self)
self.__index = self
return o
end