Compare commits
3 commits
2439711358
...
e029672bb6
Author | SHA1 | Date | |
---|---|---|---|
|
e029672bb6 | ||
|
d4d6584ef8 | ||
|
bac76b95dc |
2 changed files with 91 additions and 11 deletions
|
@ -28,6 +28,17 @@ font["f"] = {
|
|||
{0, 0, 0.7, 0},
|
||||
{0, 0.5, 0.5, 0.5},
|
||||
}
|
||||
font["g"] = {
|
||||
{0, 0.2, 0.2, 0},
|
||||
{0.2, 0, 0.5, 0},
|
||||
{0.5, 0, 0.7, 0.2},
|
||||
{0, 0.2, 0, 0.8},
|
||||
{0, 0.8, 0.2, 1},
|
||||
{0.2, 1, 0.5, 1},
|
||||
{0.5, 1, 0.7, 0.8},
|
||||
{0.7, 0.8, 0.7, 0.6},
|
||||
{0.7, 0.6, 0.5, 0.6},
|
||||
}
|
||||
font["i"] = {
|
||||
{0.1, 0, 0.6, 0},
|
||||
{0.35, 0, 0.35, 1},
|
||||
|
@ -43,6 +54,12 @@ font["l"] = {
|
|||
{0, 0, 0, 1},
|
||||
{0, 1, 0.7, 1},
|
||||
}
|
||||
font["m"] = {
|
||||
{0, 1, 0.175, 0},
|
||||
{0.175, 0, 0.35, 1},
|
||||
{0.35, 1, 0.525, 0},
|
||||
{0.525, 0, 0.7, 1},
|
||||
}
|
||||
font["o"] = {
|
||||
{0, 0.2, 0.2, 0},
|
||||
{0.2, 0, 0.5, 0},
|
||||
|
@ -53,6 +70,17 @@ font["o"] = {
|
|||
{0.5, 1, 0.7, 0.8},
|
||||
{0.7, 0.2, 0.7, 0.8},
|
||||
}
|
||||
font["q"] = {
|
||||
{0, 0.2, 0.2, 0},
|
||||
{0.2, 0, 0.5, 0},
|
||||
{0.5, 0, 0.7, 0.2},
|
||||
{0, 0.2, 0, 0.8},
|
||||
{0, 0.8, 0.2, 1},
|
||||
{0.2, 1, 0.5, 1},
|
||||
{0.5, 1, 0.7, 0.8},
|
||||
{0.7, 0.2, 0.7, 0.8},
|
||||
{0.5, 0.7, 0.7, 1},
|
||||
}
|
||||
font["r"] = {
|
||||
{0, 0, 0, 1},
|
||||
{0, 0, 0.5, 0},
|
||||
|
@ -79,6 +107,13 @@ font["t"] = {
|
|||
{0, 0, 0.7, 0},
|
||||
{0.35, 0, 0.35, 1},
|
||||
}
|
||||
font["u"] = {
|
||||
{0, 0, 0, 0.8},
|
||||
{0, 0.8, 0.2, 1},
|
||||
{0.2, 1, 0.5, 1},
|
||||
{0.5, 1, 0.7, 0.8},
|
||||
{0.7, 0.8, 0.7, 0},
|
||||
}
|
||||
font["v"] = {
|
||||
{0, 0, 0.35, 1},
|
||||
{0.35, 1, 0.7, 0},
|
||||
|
|
|
@ -34,7 +34,7 @@ local enemy_inaccuracy = 0.05
|
|||
local intro_duration = 1
|
||||
local outro_duration = 0.5
|
||||
|
||||
local stage = 1
|
||||
local stage = nil
|
||||
|
||||
local window_width = nil
|
||||
local window_height = nil
|
||||
|
@ -44,7 +44,7 @@ local scale = nil
|
|||
|
||||
local time = nil
|
||||
|
||||
local states = {title = 0, intro = 1, outro = 2, gameplay = 3}
|
||||
local states = {title = 0, intro = 1, outro = 2, gameplay = 3, game_over = 4}
|
||||
local state = nil
|
||||
|
||||
font = require("font")
|
||||
|
@ -154,6 +154,8 @@ function love.load()
|
|||
cities = {}
|
||||
spawnCities()
|
||||
|
||||
stage = 1
|
||||
|
||||
state = states.title
|
||||
end
|
||||
|
||||
|
@ -365,10 +367,26 @@ function updateEnemies(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_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)
|
||||
spawnMissile(enemy.x, enemy.y, target.x + inaccuracy, target.y, speed)
|
||||
local inaccuracy = math.random() * 2 * enemy_inaccuracy - enemy_inaccuracy
|
||||
local behaviour = math.random(0, 7)
|
||||
if behaviour == 0 then
|
||||
spawnMissile(enemy.x, enemy.y, enemy.x + inaccuracy, 1, speed)
|
||||
elseif behaviour <= 5 then
|
||||
local target = cities[math.random(1, #cities)]
|
||||
for i = 1, 7 do
|
||||
if target.alive then
|
||||
break
|
||||
end
|
||||
target = cities[math.random(1, #cities)]
|
||||
end
|
||||
spawnMissile(enemy.x, enemy.y, target.x + inaccuracy, target.y, speed)
|
||||
else
|
||||
local angle = (math.random() * 140 - 70) * math.pi / 180
|
||||
local x = enemy.x + math.sin(angle)
|
||||
local y = enemy.y + math.cos(angle)
|
||||
spawnMissile(enemy.x, enemy.y, x, y, speed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -394,7 +412,13 @@ function love.update(dt)
|
|||
unreflected_missiles_allowed = unreflected_missiles_allowed + 1
|
||||
end
|
||||
|
||||
if #enemies == 0 then
|
||||
local cities_remaining = 0
|
||||
for _, city in ipairs(cities) do
|
||||
if city.alive then
|
||||
cities_remaining = cities_remaining + 1
|
||||
end
|
||||
end
|
||||
if cities_remaining == 0 or #enemies == 0 then
|
||||
state = states.outro
|
||||
time = 0
|
||||
explodeAllMissiles()
|
||||
|
@ -406,8 +430,21 @@ function love.update(dt)
|
|||
if #explosions == 0 then
|
||||
time = time + dt
|
||||
if time >= outro_duration then
|
||||
stage = stage + 1
|
||||
startStage()
|
||||
local cities_remaining = 0
|
||||
for _, city in ipairs(cities) do
|
||||
if city.alive then
|
||||
cities_remaining = cities_remaining + 1
|
||||
end
|
||||
end
|
||||
if cities_remaining == 0 then
|
||||
love.mouse.setVisible(true)
|
||||
love.mouse.setGrabbed(false)
|
||||
state = states.game_over
|
||||
else
|
||||
time = 0
|
||||
stage = stage + 1
|
||||
startStage()
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif state == states.intro then
|
||||
|
@ -443,7 +480,7 @@ function movePaddle(screen_x)
|
|||
paddle_x = fromScreenCoordinate(screen_x, 0)
|
||||
paddle_x = math.max(paddle_x, paddle_width/2 + wall_thickness)
|
||||
paddle_x = math.min(paddle_x, 1 - (paddle_width/2 + wall_thickness))
|
||||
paddle_y = 0.9
|
||||
paddle_y = 0.8
|
||||
end
|
||||
|
||||
love.mousemoved = movePaddle
|
||||
|
@ -456,6 +493,8 @@ function love.mousepressed(x, y, button, istouch, presses)
|
|||
explodeAllReflected()
|
||||
elseif state == states.title then
|
||||
startStage()
|
||||
elseif state == states.game_over then
|
||||
love.event.quit()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -599,7 +638,7 @@ function drawTextCentered(y, text_scale, text)
|
|||
end
|
||||
|
||||
function love.draw()
|
||||
if state == states.gameplay or state == states.outro or state == states.intro then
|
||||
if state == states.gameplay or state == states.outro or state == states.intro or state == states.game_over then
|
||||
drawCities()
|
||||
drawWalls()
|
||||
drawMissiles()
|
||||
|
@ -609,7 +648,13 @@ function love.draw()
|
|||
if state == states.intro then
|
||||
drawTextCentered(0.4, 0.1, "wave")
|
||||
local number = tostring(stage)
|
||||
drawTextCentered(0.55, 0.1, number)
|
||||
drawTextCentered(0.55, 0.07, number)
|
||||
end
|
||||
if state == states.game_over then
|
||||
drawTextCentered(0.4, 0.1, "game over")
|
||||
local number = tostring(stage)
|
||||
drawTextCentered(0.55, 0.07, number)
|
||||
drawTextCentered(0.7, 0.03, "click to quit")
|
||||
end
|
||||
elseif state == states.title then
|
||||
drawTextCentered(0.3, 0.1, "reflect")
|
||||
|
|
Loading…
Reference in a new issue