chroma_solstice/player.lua
2015-03-11 21:41:02 -04:00

41 lines
No EOL
781 B
Lua

require "entity"
Player = class("Player", Entity)
function Player:initialize(x, y, color)
Entity.initialize(self, {
x = x,
y = y,
sizeX = 3,
sizeY = 3,
color = color,
collision = "none" --player can't push other player
})
self.sprite = playerSprite
print("i exist!!")
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