WOWOWOWOWOWOWO WI DID IT WOWOWWWWWW WOW

This commit is contained in:
0x81c 2015-03-15 04:52:18 -04:00
parent 286871ca21
commit c668dc513b
7 changed files with 294 additions and 58 deletions

View file

@ -10,8 +10,12 @@ function Entity:initialize(t)
self.shaAmount = t.sha or 1
end
function Entity:getCollision()
return self.collision
end
function Entity:atGridPos(x, y)
-- print(x, y, self.x, self.y, self.x + self.size.x, self.y + self.size.y)
-- we probably don't need this anymore
local size = self:getGridSize()
if x >= self.x and y >= self.y and x < self.x + size.x and y < self.y + size.y then
return true
@ -19,6 +23,21 @@ function Entity:atGridPos(x, y)
return false
end
function Entity:getOccupiedCells(coords)
--we have this offset so we can project what a movement would do
local offset = coords or {x = 0, y = 0}
local box = self:getGridBox()
local cells = {}
for i = box.x + offset.x, box.x + box.w - 1 + offset.x do
for j = box.y + offset.y, box.y + box.h - 1 + offset.y do
table.insert(cells, {x = i, y = j})
end
end
return cells
end
function Entity:getDrawBox()
local drawPos = self:getDrawPos()
return {x = drawPos.x, y = drawPos.y, w = self.spriteSize.w * drawScale, h = self.spriteSize.h * drawScale}