27 lines
584 B
Lua
27 lines
584 B
Lua
local cwd = (...):gsub('%.player$', '') .. "."
|
|
local Parent = require(cwd .. "parent")
|
|
local Player = Parent:extend()
|
|
|
|
function Player:new(world, x, y)
|
|
Player.super.new(self, world, "player", x, y, 16, 16)
|
|
end
|
|
|
|
function Player:update(dt)
|
|
self.xsp, self.ysp = 0, 0
|
|
if self.keys["up"].isDown then
|
|
self.ysp = -120 * dt
|
|
end
|
|
if self.keys["down"].isDown then
|
|
self.ysp = 120 * dt
|
|
end
|
|
if self.keys["left"].isDown then
|
|
self.xsp = -120 * dt
|
|
end
|
|
if self.keys["right"].isDown then
|
|
self.xsp = 120 * dt
|
|
end
|
|
|
|
Player.super.update(self, dt)
|
|
end
|
|
|
|
return Player
|