-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpawn.lua
More file actions
59 lines (57 loc) · 2.57 KB
/
Copy pathSpawn.lua
File metadata and controls
59 lines (57 loc) · 2.57 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
spawnTimer = 0
function spawnEnemies(map, level, dt)
spawnTimer = spawnTimer + dt
if level == 1 then
if spawnTimer >= spawnTime then
if spawned <= enemyMax / 2 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'bat', spawned, 'right')
elseif spawned < enemyMax - 1 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'ghost', spawned, 'right')
elseif spawned == enemyMax - 1 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'cat', spawned, 'right')
end
end
elseif level == 2 then
if spawnTimer >= spawnTime then
if spawned <= 10 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'snail', spawned, 'right')
elseif spawned < 20 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'spider', spawned, 'right')
elseif spawned < 30 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'slime', spawned, 'right')
elseif spawned < 39 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'fly', spawned, 'right')
elseif spawned == enemyMax - 1 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'cat', spawned, 'right')
end
end
elseif level == 3 then
if spawnTimer >= spawnTime then
if spawned < enemyMax - 3 then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, enemyTypes[math.random(#enemyTypes)], spawned, 'right')
elseif spawned < enemyMax then
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'cat', spawned, 'right')
end
end
elseif level > 3 and spawnTimer > spawnTime then
if cats < level then
cats = cats + 1
spawnUp()
enemies[spawned] = Enemy(spawnX * map.tileWidth, spawnY * map.tileHeight, 'cat', spawned, 'right')
end
end
end
function spawnUp()
spawned = spawned + 1
spawnTimer = 0
end