2019-04-07 17:00:47 +02:00
|
|
|
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)
|
2019-04-07 18:15:06 +02:00
|
|
|
local dx, dy = 0, 0
|
2019-04-07 22:53:59 +02:00
|
|
|
if self.keys["up"].isDown then
|
2019-04-07 17:00:47 +02:00
|
|
|
dy = -120 * dt
|
|
|
|
end
|
2019-04-07 22:53:59 +02:00
|
|
|
if self.keys["down"].isDown then
|
2019-04-07 17:00:47 +02:00
|
|
|
dy = 120 * dt
|
|
|
|
end
|
2019-04-07 22:53:59 +02:00
|
|
|
if self.keys["left"].isDown then
|
2019-04-07 17:00:47 +02:00
|
|
|
dx = -120 * dt
|
|
|
|
end
|
2019-04-07 22:53:59 +02:00
|
|
|
if self.keys["right"].isDown then
|
2019-04-07 17:00:47 +02:00
|
|
|
dx = 120 * dt
|
|
|
|
end
|
|
|
|
|
|
|
|
self:move(self.x + dx, self.y + dy)
|
|
|
|
end
|
|
|
|
|
|
|
|
return Player
|