-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemyBullets.lua
More file actions
35 lines (31 loc) · 821 Bytes
/
enemyBullets.lua
File metadata and controls
35 lines (31 loc) · 821 Bytes
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
---@diagnostic disable: lowercase-global, undefined-global
function createEnemyBullet(aTable, enemy, initialSpeed)
table.insert(aTable, {
x = enemy.x + 25,
y = enemy.y + 10,
speed = initialSpeed or 100
})
end
function destroyEnemeyBullet(aTable, index)
table.remove(aTable, index)
end
function updateEnemyBullets(aTable, dt)
for i = #aTable, 1, -1 do
local bullet = aTable[i]
bullet.y = bullet.y + bullet.speed * dt
if bullet.y > VIRTUAL_HEIGHT then
table.remove(aTable, i)
end
end
end
function drawEnemyBullets(aTable)
for _, eBullet in ipairs(aTable) do
love.graphics.setColor(BLUE)
love.graphics.circle(
'fill',
eBullet.x,
eBullet.y,
4
)
end
end