Limit the number of unreflected missiles on-screen
This commit is contained in:
parent
9ec3b93cc2
commit
9cdeee04d8
|
@ -11,6 +11,9 @@ local missile_trail_fade = 0.4
|
||||||
local missile_trail_min_visibility = 0.03
|
local missile_trail_min_visibility = 0.03
|
||||||
local missile_trail_length = math.log(missile_trail_min_visibility, missile_trail_fade)
|
local missile_trail_length = math.log(missile_trail_min_visibility, missile_trail_fade)
|
||||||
|
|
||||||
|
local unreflected_missiles = 0
|
||||||
|
local unreflected_missiles_max = 5
|
||||||
|
|
||||||
local cities = {}
|
local cities = {}
|
||||||
local city_radius = 0.05
|
local city_radius = 0.05
|
||||||
|
|
||||||
|
@ -20,7 +23,7 @@ local explosion_duration = 0.4
|
||||||
|
|
||||||
local enemies = {}
|
local enemies = {}
|
||||||
local enemy_radius = 0.025
|
local enemy_radius = 0.025
|
||||||
local enemy_min_shoot = 5
|
local enemy_min_shoot = 2
|
||||||
local enemy_max_shoot = 20
|
local enemy_max_shoot = 20
|
||||||
|
|
||||||
local window_width = nil
|
local window_width = nil
|
||||||
|
@ -114,6 +117,7 @@ function spawnMissile(x, y, target_x, target_y, speed)
|
||||||
trail_length = 0,
|
trail_length = 0,
|
||||||
alive = true
|
alive = true
|
||||||
})
|
})
|
||||||
|
unreflected_missiles = unreflected_missiles + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function spawnExplosion(x, y)
|
function spawnExplosion(x, y)
|
||||||
|
@ -162,7 +166,10 @@ function updateMissiles(dt)
|
||||||
-- Collision with the paddle
|
-- Collision with the paddle
|
||||||
missile.y = paddle_top
|
missile.y = paddle_top
|
||||||
missile.dy = -missile.dy
|
missile.dy = -missile.dy
|
||||||
missile.reflected = true
|
if not missile.reflected then
|
||||||
|
missile.reflected = true
|
||||||
|
unreflected_missiles = unreflected_missiles - 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, city in ipairs(cities) do
|
for _, city in ipairs(cities) do
|
||||||
|
@ -280,8 +287,10 @@ function updateEnemies(dt)
|
||||||
enemy.until_shoot = enemy.until_shoot - dt
|
enemy.until_shoot = enemy.until_shoot - dt
|
||||||
if enemy.until_shoot < 0 then
|
if enemy.until_shoot < 0 then
|
||||||
enemy.until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot)
|
enemy.until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot)
|
||||||
local target = cities[math.random(1, #cities)]
|
if unreflected_missiles < unreflected_missiles_max then
|
||||||
spawnMissile(enemy.x, enemy.y, target.x, target.y, 0.2)
|
local target = cities[math.random(1, #cities)]
|
||||||
|
spawnMissile(enemy.x, enemy.y, target.x, target.y, 0.2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not enemy.alive then
|
if not enemy.alive then
|
||||||
|
|
Loading…
Reference in New Issue