local HorizontalHats, super = Class(Wave) function HorizontalHats:init() super.init(self) -- The duration of our wave, in seconds. (Defaults to `5`) self.time = 7 self.count = 0 end function HorizontalHats:onStart() -- code here gets called at the start of the wave -- create a bullet in the center of the screen arena = Game.battle.arena local x_positions = {arena.x - SCREEN_WIDTH/3.3, arena.x + SCREEN_WIDTH/3.3, arena.x - SCREEN_WIDTH/3.3} local y_positions = {arena.y*0.73, arena.y*1, arena.y*1.25} self.collider1 = LineCollider(self, x_positions[2] + 10, y_positions[1], x_positions[2] + 10, y_positions[3]) self.collider2 = LineCollider(self, x_positions[1] - 10, y_positions[1], x_positions[1] - 10, y_positions[3]) self.colliderGroup = ColliderGroup(self, {self.collider1, self.collider2}) for i = 1, 3, 1 do local x = x_positions[i] local y = y_positions[i] self.bullets[i] = self:spawnBullet("hatbulllet", x, y, 0, 6.7) self.bullets[i]:setScale(2.2) if (i == 1 or i == 3) then self.bullets[i].physics.direction = math.rad(0) else self.bullets[i].physics.direction = math.rad(180) end end super.onStart(self) end function HorizontalHats:update() -- code here gets called every frame for i = 1, 3, 1 do if (self.bullets[i]) then if (self.bullets[i].collider:collidesWith(self.collider1) or self.bullets[i].collider:collidesWith(self.collider2)) then self.bullets[i].physics.direction = self.bullets[i].physics.direction + math.rad(180) end end end super.update(self) end function HorizontalHats:draw() super.draw(self) if DEBUG_RENDER then if (self.colliderGroup) then self.colliderGroup:draw(0,1,0,1) end end end return HorizontalHats