Make Ebi move, refactor bullet code to make more logic per-entity type.
This commit is contained in:
parent
bb25e255a3
commit
0db42e8c87
4 changed files with 46 additions and 21 deletions
|
@ -12,6 +12,10 @@ function Entity:init(img, health, armor)
|
|||
self.health = health or 10
|
||||
self.armor = armor or 0
|
||||
|
||||
-- movement direction, every update() the entity will move along this vector and return
|
||||
-- collision data to the subclass
|
||||
self.vector = {x=0,y=0}
|
||||
|
||||
self:setCollideRect(0, 0, self:getSize())
|
||||
|
||||
-- most entities will be enemies, so we configure this mask by default
|
||||
|
@ -29,3 +33,8 @@ function Entity:damage(amount)
|
|||
self:remove()
|
||||
end
|
||||
end
|
||||
|
||||
function Entity:update()
|
||||
local collisions = select(3, self:moveWithCollisions(self.x + self.vector.x, self.y + self.vector.y))
|
||||
return collisions
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue