kupo nice now
bow nice aim nice arrow nice all nice
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user