chroma_solstice/player.lua

41 lines
781 B
Lua
Raw Normal View History

2015-03-11 20:11:29 -04:00
require "entity"
2015-03-11 21:08:15 -04:00
Player = class("Player", Entity)
2015-03-11 20:11:29 -04:00
function Player:initialize(x, y, color)
2015-03-11 21:08:15 -04:00
Entity.initialize(self, {
2015-03-11 20:11:29 -04:00
x = x,
y = y,
2015-03-11 21:08:15 -04:00
sizeX = 3,
sizeY = 3,
2015-03-11 20:11:29 -04:00
color = color,
collision = "none" --player can't push other player
2015-03-11 21:08:15 -04:00
})
2015-03-11 20:11:29 -04:00
self.sprite = playerSprite
2015-03-11 21:41:02 -04:00
print("i exist!!")
2015-03-11 20:11:29 -04:00
end
function Player:update()
end
function Player:draw()
love.graphics.setColor(self.color:set())
local p = self:getDrawPos()
love.graphics.draw(self.sprite, p.x, p.y, 0, drawScale, drawScale)
end
function Player:move(direction)
if direction == "up" then
self.gridY = self.gridY - 1
elseif direction == "down" then
self.gridY = self.gridY + 1
elseif direction == "left" then
self.gridX = self.gridX - 1
elseif direction == "right" then
self.gridX = self.gridX + 1
end
end