2019-04-07 17:00:47 +02:00
|
|
|
|
2024-10-30 18:38:11 +01:00
|
|
|
local Player = actor {
|
|
|
|
type = "player",
|
|
|
|
dimensions = {w = 16, h = 16},
|
2024-10-30 18:44:24 +01:00
|
|
|
friction = {x = 480*3, y = 480*3},
|
2024-10-30 18:38:11 +01:00
|
|
|
isSolid = true,
|
|
|
|
visuals = {
|
|
|
|
mode = "box",
|
|
|
|
color = {r = .5, g = 0, b = 0}
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 21:21:07 +02:00
|
|
|
|
2024-10-30 18:38:11 +01:00
|
|
|
function Player:onInit()
|
|
|
|
self.coin = 0
|
2019-04-07 17:00:47 +02:00
|
|
|
end
|
|
|
|
|
2024-10-30 18:38:11 +01:00
|
|
|
function Player:update(dt)
|
|
|
|
if love.keyboard.isDown("up") then
|
|
|
|
self.speed.y = -120
|
2019-04-07 17:00:47 +02:00
|
|
|
end
|
2024-10-30 18:38:11 +01:00
|
|
|
if love.keyboard.isDown("down") then
|
|
|
|
self.speed.y = 120
|
2019-04-07 17:00:47 +02:00
|
|
|
end
|
2024-10-30 18:38:11 +01:00
|
|
|
if love.keyboard.isDown("left") then
|
|
|
|
self.speed.x = -120
|
2019-04-07 17:00:47 +02:00
|
|
|
end
|
2024-10-30 18:38:11 +01:00
|
|
|
if love.keyboard.isDown("right") then
|
|
|
|
self.speed.x = 120
|
2019-04-07 17:00:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-10-30 18:38:11 +01:00
|
|
|
function Player:drawHUD()
|
|
|
|
assets:print("medium", "Coins : " .. self.coin, 8, 8)
|
2019-06-13 22:23:23 +02:00
|
|
|
end
|
|
|
|
|
2019-04-07 17:00:47 +02:00
|
|
|
return Player
|