Compare commits
3 Commits
0e410d262d
...
9ec3b93cc2
Author | SHA1 | Date |
---|---|---|
Juhani Krekelä | 9ec3b93cc2 | |
Juhani Krekelä | 2a3d7b188f | |
Juhani Krekelä | a290a9113a |
|
@ -21,7 +21,7 @@ local explosion_duration = 0.4
|
|||
local enemies = {}
|
||||
local enemy_radius = 0.025
|
||||
local enemy_min_shoot = 5
|
||||
local enemy_max_shoot = 10
|
||||
local enemy_max_shoot = 20
|
||||
|
||||
local window_width = nil
|
||||
local window_height = nil
|
||||
|
@ -62,16 +62,23 @@ function love.load()
|
|||
setScreenDimensions(width, height)
|
||||
movePaddle(0)
|
||||
spawnCities()
|
||||
spawnEnemy(0.1, 0.1, false)
|
||||
spawnEnemy(0.2, 0.1, true)
|
||||
spawnEnemy(0.3, 0.1, false)
|
||||
spawnEnemy(0.4, 0.1, true)
|
||||
spawnEnemy(0.5, 0.1, false)
|
||||
spawnEnemy(0.6, 0.1, true)
|
||||
spawnEnemy(0.7, 0.1, false)
|
||||
spawnEnemy(0.8, 0.1, true)
|
||||
spawnEnemy(0.9, 0.1, false)
|
||||
spawnEnemy(0.1, 0.3, true)
|
||||
spawnEnemy(0.1, 0.1)
|
||||
spawnEnemy(0.2, 0.1)
|
||||
spawnEnemy(0.3, 0.1)
|
||||
spawnEnemy(0.4, 0.1)
|
||||
spawnEnemy(0.5, 0.1)
|
||||
spawnEnemy(0.6, 0.1)
|
||||
spawnEnemy(0.7, 0.1)
|
||||
spawnEnemy(0.8, 0.1)
|
||||
spawnEnemy(0.9, 0.1)
|
||||
spawnEnemy(0.15, 0.2)
|
||||
spawnEnemy(0.25, 0.2)
|
||||
spawnEnemy(0.35, 0.2)
|
||||
spawnEnemy(0.45, 0.2)
|
||||
spawnEnemy(0.55, 0.2)
|
||||
spawnEnemy(0.65, 0.2)
|
||||
spawnEnemy(0.75, 0.2)
|
||||
spawnEnemy(0.85, 0.2)
|
||||
end
|
||||
|
||||
function spawnCities()
|
||||
|
@ -118,11 +125,10 @@ function spawnExplosion(x, y)
|
|||
})
|
||||
end
|
||||
|
||||
function spawnEnemy(x, y, active)
|
||||
function spawnEnemy(x, y)
|
||||
table.insert(enemies, {
|
||||
x = x,
|
||||
y = y,
|
||||
active = active,
|
||||
until_shoot = math.random() * (enemy_max_shoot - enemy_min_shoot),
|
||||
alive = true
|
||||
})
|
||||
|
@ -203,7 +209,6 @@ function updateMissiles(dt)
|
|||
table.remove(missile.history)
|
||||
end
|
||||
end
|
||||
print(#missile.history)
|
||||
end
|
||||
|
||||
local i = 1
|
||||
|
@ -272,13 +277,11 @@ function updateEnemies(dt)
|
|||
while i <= #enemies do
|
||||
local enemy = enemies[i]
|
||||
|
||||
if enemy.active then
|
||||
enemy.until_shoot = enemy.until_shoot - dt
|
||||
if enemy.until_shoot < 0 then
|
||||
enemy.until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot)
|
||||
local target = cities[math.random(1, #cities)]
|
||||
spawnMissile(enemy.x, enemy.y, target.x, target.y, 0.2)
|
||||
end
|
||||
enemy.until_shoot = enemy.until_shoot - dt
|
||||
if enemy.until_shoot < 0 then
|
||||
enemy.until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot)
|
||||
local target = cities[math.random(1, #cities)]
|
||||
spawnMissile(enemy.x, enemy.y, target.x, target.y, 0.2)
|
||||
end
|
||||
|
||||
if not enemy.alive then
|
||||
|
@ -354,9 +357,9 @@ function drawMissiles()
|
|||
|
||||
local x, y = toScreenCoordinates(point.x, point.y)
|
||||
if missile.reflected then
|
||||
love.graphics.setColor(1 * visibility, 1 * visibility, 0.5 * visibility)
|
||||
love.graphics.setColor(1, 1, 0.5, visibility)
|
||||
else
|
||||
love.graphics.setColor(1 * visibility, 0.4 * visibility, 0 * visibility)
|
||||
love.graphics.setColor(1, 0.4, 0, visibility)
|
||||
end
|
||||
love.graphics.line(from_x, from_y, x, y)
|
||||
from_x = x
|
||||
|
|
Loading…
Reference in New Issue