epervier-old/examples/gameplay/moveplayer/actors/player.lua

35 lines
713 B
Lua
Raw Normal View History

local cwd = (...):gsub('%.player$', '') .. "."
local Parent = require(cwd .. "parent")
local Player = Parent:extend()
2019-04-29 15:27:40 +02:00
function Player:new(world, x, y, id)
Player.super.new(self, world, "player", x, y, 16, 16, true)
2019-04-29 15:27:40 +02:00
self.playerid = id
end
function Player:update(dt)
2019-04-28 09:31:37 +02:00
self.xfrc, self.yfrc = 480*3, 480*3
2019-04-29 15:27:40 +02:00
if self.keys["up"].isDown then
self.ysp = -120
end
if self.keys["down"].isDown then
self.ysp = 120
end
if self.keys["left"].isDown then
self.xsp = -120
end
if self.keys["right"].isDown then
self.xsp = 120
end
2019-04-13 09:40:14 +02:00
Player.super.update(self, dt)
end
2019-04-29 15:27:40 +02:00
function Player:draw()
Player.super.draw(self)
love.graphics.print(self.playerid, self.x, self.y)
end
return Player