Compare commits
2 Commits
643663a415
...
0352a9e14f
Author | SHA1 | Date |
---|---|---|
Juhani Krekelä | 0352a9e14f | |
Juhani Krekelä | 710cf27036 |
|
@ -5,7 +5,7 @@ local paddle_height = 0.02
|
|||
|
||||
local wall_thickness = 0.01
|
||||
|
||||
local missiles = {}
|
||||
local missiles = nil
|
||||
local missile_radius = 0.005
|
||||
local missile_trail_fade = 0.4
|
||||
local missile_trail_min_visibility = 0.03
|
||||
|
@ -13,20 +13,22 @@ local missile_trail_length = math.log(missile_trail_min_visibility, missile_trai
|
|||
local missile_speed_min = 0.15
|
||||
local missile_speed_max = 0.25
|
||||
|
||||
local unreflected_missiles = 0
|
||||
local unreflected_missiles_max = 5
|
||||
local unreflected_missiles = nil
|
||||
local unreflected_missiles_allowed = nil
|
||||
local unreflected_missiles_allowed_ramp_up = 10
|
||||
local unreflected_missiles_max = 7
|
||||
|
||||
local cities = {}
|
||||
local cities = nil
|
||||
local city_radius = 0.05
|
||||
|
||||
local explosions = {}
|
||||
local explosions = nil
|
||||
local explosion_radius = 0.08
|
||||
local explosion_duration = 0.4
|
||||
|
||||
local enemies = {}
|
||||
local enemies = nil
|
||||
local enemy_radius = 0.025
|
||||
local enemy_min_shoot = 2
|
||||
local enemy_max_shoot = 20
|
||||
local enemy_max_shoot = 10
|
||||
local enemy_inaccuracy = 0.05
|
||||
|
||||
local window_width = nil
|
||||
|
@ -35,6 +37,8 @@ local viewport_x_offset = nil
|
|||
local viewport_y_offset = nil
|
||||
local scale = nil
|
||||
|
||||
local time = nil
|
||||
|
||||
function setScreenDimensions(width, height)
|
||||
window_width = width
|
||||
window_height = height
|
||||
|
@ -62,12 +66,15 @@ function fromScreenCoordinate(x, y)
|
|||
return logical_x, logical_y
|
||||
end
|
||||
|
||||
function love.load()
|
||||
math.randomseed(os.time())
|
||||
love.mouse.setVisible(false)
|
||||
local width, height = love.graphics.getDimensions()
|
||||
setScreenDimensions(width, height)
|
||||
movePaddle(0)
|
||||
function initialize()
|
||||
missiles = {}
|
||||
unreflected_missiles = 0
|
||||
unreflected_missiles_allowed = 0
|
||||
cities = {}
|
||||
explosions = {}
|
||||
enemies = {}
|
||||
time = 0
|
||||
|
||||
spawnCities()
|
||||
spawnEnemy(0.1, 0.1)
|
||||
spawnEnemy(0.2, 0.1)
|
||||
|
@ -88,6 +95,15 @@ function love.load()
|
|||
spawnEnemy(0.85, 0.2)
|
||||
end
|
||||
|
||||
function love.load()
|
||||
math.randomseed(os.time())
|
||||
love.mouse.setVisible(false)
|
||||
local width, height = love.graphics.getDimensions()
|
||||
setScreenDimensions(width, height)
|
||||
movePaddle(0)
|
||||
initialize()
|
||||
end
|
||||
|
||||
function spawnCities()
|
||||
local number_of_cities = 7
|
||||
cities = {}
|
||||
|
@ -137,7 +153,7 @@ function spawnEnemy(x, y)
|
|||
table.insert(enemies, {
|
||||
x = x,
|
||||
y = y,
|
||||
until_shoot = math.random() * (enemy_max_shoot - enemy_min_shoot),
|
||||
until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot),
|
||||
alive = true
|
||||
})
|
||||
end
|
||||
|
@ -291,7 +307,7 @@ function updateEnemies(dt)
|
|||
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)
|
||||
if unreflected_missiles < unreflected_missiles_max then
|
||||
if unreflected_missiles < unreflected_missiles_allowed then
|
||||
local target = cities[math.random(1, #cities)]
|
||||
local inaccuracy = math.random() * 2 * enemy_inaccuracy - enemy_inaccuracy
|
||||
local speed = missile_speed_min + math.random() * (missile_speed_max - missile_speed_min)
|
||||
|
@ -312,6 +328,11 @@ function love.update(dt)
|
|||
updateExplosions(dt)
|
||||
updateEnemies(dt)
|
||||
|
||||
time = time + dt
|
||||
if unreflected_missiles_allowed < unreflected_missiles_max and time >= unreflected_missiles_allowed * unreflected_missiles_allowed_ramp_up then
|
||||
unreflected_missiles_allowed = unreflected_missiles_allowed + 1
|
||||
end
|
||||
|
||||
if #explosions == 0 and #missiles == 0 and #enemies == 0 then
|
||||
love.event.quit()
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue