Make Ebi move, refactor bullet code to make more logic per-entity type.
This commit is contained in:
@ -13,4 +13,18 @@ function Ebi:init()
|
||||
Ebi.super.init(self, img, 5)
|
||||
|
||||
self:setCollidesWithGroupsMask(0x3)
|
||||
local dir = 1
|
||||
if math.random(2) == 1 then
|
||||
dir = -1
|
||||
end
|
||||
self.vector = {x=0, y=dir}
|
||||
end
|
||||
|
||||
function Ebi:update()
|
||||
local collisions = Ebi.super.update(self)
|
||||
for i=1, #collisions, 1 do
|
||||
if collisions[i].other:getGroupMask() == 0x1 then
|
||||
self.vector.y *= -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user