basic stacking hats pattern and basic woody ennemy
This commit is contained in:
50
scripts/battle/waves/stackinghats.lua
Normal file
50
scripts/battle/waves/stackinghats.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
local StackingHats, super = Class(Wave)
|
||||
|
||||
function StackingHats:init()
|
||||
super.init(self)
|
||||
|
||||
-- The duration of our wave, in seconds. (Defaults to `5`)
|
||||
self.time = 10
|
||||
self.count = 0
|
||||
|
||||
end
|
||||
|
||||
function StackingHats:onStart()
|
||||
-- code here gets called at the start of the wave
|
||||
-- create a bullet in the center of the screen
|
||||
arena = Game.battle.arena
|
||||
arenaX, arenaY = arena:getBottomLeft()
|
||||
arenaX2, arenaY2 = arena:getBottomRight()
|
||||
self.collider = LineCollider(self, arenaX, arenaY, arenaX2, arenaY2)
|
||||
self.timer:everyInstant(1, function()
|
||||
|
||||
local x = SCREEN_WIDTH / 2
|
||||
local y = arena:getTop() * 0.5
|
||||
self.bullets[self.count] = self:spawnBullet("hatbulllet", x, y)
|
||||
-- set the bullet's speed to 4 (pixels per 1/30th second)
|
||||
self.bullets[self.count].physics.speed = 4
|
||||
self.count = self.count + 1
|
||||
end)
|
||||
super.onStart(self)
|
||||
end
|
||||
|
||||
function StackingHats:update()
|
||||
-- code here gets called every frame
|
||||
|
||||
for i = 0, self.count -1, 1 do
|
||||
for j = 0, i-1, 1 do
|
||||
if (i ~= j) then
|
||||
if (self.bullets[i].collider:collidesWith(self.bullets[j])) then
|
||||
self.bullets[i].physics.speed = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
if (self.bullets[i].collider:collidesWith(self)) then
|
||||
self.bullets[i].physics.speed = 0
|
||||
end
|
||||
end
|
||||
|
||||
super.update(self)
|
||||
end
|
||||
|
||||
return StackingHats
|
||||
Reference in New Issue
Block a user