27 lines
565 B
Lua
27 lines
565 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)
|
|
local dx, dy
|
|
if self.keys["up"].isPressed then
|
|
dy = -120 * dt
|
|
end
|
|
if self.keys["down"].isPressed then
|
|
dy = 120 * dt
|
|
end
|
|
if self.keys["left"].isPressed then
|
|
dx = -120 * dt
|
|
end
|
|
if self.keys["right"].isPressed then
|
|
dx = 120 * dt
|
|
end
|
|
|
|
self:move(self.x + dx, self.y + dy)
|
|
end
|
|
|
|
return Player
|