epervier-framework/examples/scenes/gameplay/moveplayer/actors/player.lua

38 lines
673 B
Lua
Raw Normal View History

local Player = actor {
type = "player",
dimensions = {w = 16, h = 16},
isSolid = true,
visuals = {
mode = "box",
color = {r = .5, g = 0, b = 0}
}
}
function Player:onInit()
self.coin = 0
end
function Player:update(dt)
self.friction.x, self.friction.y = 480*3, 480*3
2019-04-29 15:27:40 +02:00
if love.keyboard.isDown("up") then
self.speed.y = -120
end
if love.keyboard.isDown("down") then
self.speed.y = 120
end
if love.keyboard.isDown("left") then
self.speed.x = -120
end
if love.keyboard.isDown("right") then
self.speed.x = 120
end
end
function Player:drawHUD()
assets:print("medium", "Coins : " .. self.coin, 8, 8)
end
return Player