-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathblockade_enemy.lua
45 lines (40 loc) · 966 Bytes
/
blockade_enemy.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local G = love.graphics
BlockadeEnemy = Enemy:New {
size = 8,
model = { 16, 12, 16, -12, -16, -12, -16, 12, },
shield = 10,
score = 2000,
}
BlockadeEnemy:InitQuads("media/blockade.png")
initPolygonRadius(BlockadeEnemy.model)
function BlockadeEnemy:init(rand, x, y, wall_row, index)
self:super(rand, x, y - game.walls.speed) -- fix offset issue
self.neighbors = {}
self.index = index
self.wall_row = wall_row
end
function BlockadeEnemy:die()
self.wall_row[self.index] = 0
local ttls = { 9, 10 }
if not self.ttl then
makeEnergyItem(self.x, self.y, self.rand, 5)
ttls[2] = 5
end
for i, ttl in ipairs(ttls) do
if self.neighbors[i] then
self.neighbors[i].ttl = ttl
self.neighbors[i].neighbors[3 - i] = nil
self.neighbors[i] = nil
end
end
end
function BlockadeEnemy:subUpdate()
self.y = self.y + game.walls.speed
if self.ttl then
self.ttl = self.ttl - 1
if self.ttl <= 0 then
self.alive = false
end
end
transform(self)
end