basic stuff w movemet n collision done

This commit is contained in:
0x81c 2015-03-12 04:05:39 -04:00
parent 03112bb0fb
commit bffa27ec01
4 changed files with 25 additions and 15 deletions

View file

@ -6,6 +6,7 @@ function Entity:initialize(t)
self.color = Color:new(t.color)
self.collision = t.collision --either "none", "moveable", "unmoveable"
self.sprite = t.sprite
self.shaAmount = t.sha or 1
end
function Entity:atGridPos(x, y)
@ -31,7 +32,7 @@ end
function Entity:draw()
love.graphics.setColor(self.color:set())
local p = self:getDrawPos()
love.graphics.draw(self.sprite, p.x, p.y, 0, drawScale, drawScale)
love.graphics.draw(self.sprite, p.x + self:sha(), p.y + self:sha(), 0, drawScale, drawScale)
end
function Entity:isAlignedWithPlayerMovement(axis, pos)
@ -53,6 +54,7 @@ function Entity:move(axis, direction)
self[axis] = self[axis] + direction
end
function Entity:push(direction)
function Entity:sha()
return math.random(-self.shaAmount, self.shaAmount) * .5
end