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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue