basix
This commit is contained in:
commit
b4905845e6
148 changed files with 30049 additions and 0 deletions
28
entity.lua
Normal file
28
entity.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
Entity = class("Entity")
|
||||
|
||||
function Entity:initialize(t)
|
||||
self.gridX, self.gridY = t.x, t.y
|
||||
self.gridSize = {x = t.sizeX, y = t.sizeY}
|
||||
self.color = Color:new(t.color)
|
||||
self.collision = t.collision
|
||||
end
|
||||
|
||||
function Entity:atGridPos(x, y)
|
||||
if x >= self.gridX and x <= self.gridX + self.gridSize.x and
|
||||
y >= self.gridY and y <= self.gridSize.y then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Entity:getGridPos()
|
||||
return {x = self.gridX, y = self.gridY}
|
||||
end
|
||||
|
||||
function Entity:getDrawPos()
|
||||
local gridPos = self:getGridPos()
|
||||
return {
|
||||
x = (gridPos.x - 1) * width / gridWidth,
|
||||
y = (gridPos.y - 1) * height / gridHeight
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue