Compare commits
No commits in common. "fd6c7fafa0f0594a1af0f05e7e1f4b24b9632b73" and "d7146a1d527ca203eb3952592ebacb8db0a30470" have entirely different histories.
fd6c7fafa0
...
d7146a1d52
2 changed files with 20 additions and 163 deletions
|
@ -1,82 +0,0 @@
|
||||||
local font = {}
|
|
||||||
font[" "] = {}
|
|
||||||
font["a"] = {
|
|
||||||
{0, 1, 0, 0.2},
|
|
||||||
{0, 0.2, 0.2, 0},
|
|
||||||
{0.2, 0, 0.5, 0},
|
|
||||||
{0.5, 0, 0.7, 0.2},
|
|
||||||
{0.7, 0.2, 0.7, 1},
|
|
||||||
{0, 0.6, 0.7, 0.6},
|
|
||||||
}
|
|
||||||
font["c"] = {
|
|
||||||
{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},
|
|
||||||
}
|
|
||||||
font["e"] = {
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
{0, 0, 0.7, 0},
|
|
||||||
{0, 0.5, 0.5, 0.5},
|
|
||||||
{0, 1, 0.7, 1},
|
|
||||||
}
|
|
||||||
font["f"] = {
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
{0, 0, 0.7, 0},
|
|
||||||
{0, 0.5, 0.5, 0.5},
|
|
||||||
}
|
|
||||||
font["i"] = {
|
|
||||||
{0.1, 0, 0.6, 0},
|
|
||||||
{0.35, 0, 0.35, 1},
|
|
||||||
{0.1, 1, 0.6, 1},
|
|
||||||
}
|
|
||||||
font["k"] = {
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
{0, 0.5, 0.3, 0.5},
|
|
||||||
{0.3, 0.5, 0.7, 0},
|
|
||||||
{0.3, 0.5, 0.7, 1},
|
|
||||||
}
|
|
||||||
font["l"] = {
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
{0, 1, 0.7, 1},
|
|
||||||
}
|
|
||||||
font["o"] = {
|
|
||||||
{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},
|
|
||||||
}
|
|
||||||
font["r"] = {
|
|
||||||
{0, 0, 0, 1},
|
|
||||||
{0, 0, 0.5, 0},
|
|
||||||
{0.5, 0, 0.7, 0.2},
|
|
||||||
{0.7, 0.2, 0.7, 0.3},
|
|
||||||
{0.7, 0.3, 0.5, 0.5},
|
|
||||||
{0.5, 0.5, 0, 0.5},
|
|
||||||
{0, 0.5, 0.7, 1}
|
|
||||||
}
|
|
||||||
font["s"] = {
|
|
||||||
{0.7, 0.2, 0.5, 0},
|
|
||||||
{0.5, 0, 0.2, 0},
|
|
||||||
{0.2, 0, 0, 0.2},
|
|
||||||
{0, 0.2, 0, 0.3},
|
|
||||||
{0, 0.3, 0.2, 0.5},
|
|
||||||
{0.2, 0.5, 0.5, 0.5},
|
|
||||||
{0.5, 0.5, 0.7, 0.7},
|
|
||||||
{0.7, 0.7, 0.7, 0.8},
|
|
||||||
{0.7, 0.8, 0.5, 1},
|
|
||||||
{0.5, 1, 0.2, 1},
|
|
||||||
{0.2, 1, 0, 0.8},
|
|
||||||
}
|
|
||||||
font["t"] = {
|
|
||||||
{0, 0, 0.7, 0},
|
|
||||||
{0.35, 0, 0.35, 1},
|
|
||||||
}
|
|
||||||
return font
|
|
101
bundle/main.lua
101
bundle/main.lua
|
@ -39,14 +39,6 @@ local scale = nil
|
||||||
|
|
||||||
local time = nil
|
local time = nil
|
||||||
|
|
||||||
local states = {title = 0, gameplay = 1}
|
|
||||||
local state = nil
|
|
||||||
|
|
||||||
local title = {"r", "e", "f", "l", "e", "c", "t"}
|
|
||||||
local start_instructions = {"c", "l", "i", "c", "k", " ", "t", "o", " ", "s", "t", "a", "r", "t"}
|
|
||||||
|
|
||||||
font = require("font")
|
|
||||||
|
|
||||||
function setScreenDimensions(width, height)
|
function setScreenDimensions(width, height)
|
||||||
window_width = width
|
window_width = width
|
||||||
window_height = height
|
window_height = height
|
||||||
|
@ -74,9 +66,7 @@ function fromScreenCoordinate(x, y)
|
||||||
return logical_x, logical_y
|
return logical_x, logical_y
|
||||||
end
|
end
|
||||||
|
|
||||||
function startStage()
|
function initialize()
|
||||||
movePaddle(0)
|
|
||||||
|
|
||||||
missiles = {}
|
missiles = {}
|
||||||
unreflected_missiles = 0
|
unreflected_missiles = 0
|
||||||
unreflected_missiles_allowed = 0
|
unreflected_missiles_allowed = 0
|
||||||
|
@ -103,16 +93,15 @@ function startStage()
|
||||||
spawnEnemy(0.65, 0.2)
|
spawnEnemy(0.65, 0.2)
|
||||||
spawnEnemy(0.75, 0.2)
|
spawnEnemy(0.75, 0.2)
|
||||||
spawnEnemy(0.85, 0.2)
|
spawnEnemy(0.85, 0.2)
|
||||||
|
|
||||||
state = states.gameplay
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
love.mouse.setVisible(false)
|
||||||
local width, height = love.graphics.getDimensions()
|
local width, height = love.graphics.getDimensions()
|
||||||
setScreenDimensions(width, height)
|
setScreenDimensions(width, height)
|
||||||
|
movePaddle(0)
|
||||||
state = states.title
|
initialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function spawnCities()
|
function spawnCities()
|
||||||
|
@ -342,19 +331,17 @@ function updateEnemies(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
if state == states.gameplay then
|
updateMissiles(dt)
|
||||||
updateMissiles(dt)
|
updateExplosions(dt)
|
||||||
updateExplosions(dt)
|
updateEnemies(dt)
|
||||||
updateEnemies(dt)
|
|
||||||
|
|
||||||
time = time + dt
|
time = time + dt
|
||||||
if unreflected_missiles_allowed < unreflected_missiles_max and time >= unreflected_missiles_allowed * unreflected_missiles_allowed_ramp_up then
|
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
|
unreflected_missiles_allowed = unreflected_missiles_allowed + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if #explosions == 0 and #missiles == 0 and #enemies == 0 then
|
if #explosions == 0 and #missiles == 0 and #enemies == 0 then
|
||||||
love.event.quit()
|
love.event.quit()
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -378,25 +365,7 @@ end
|
||||||
|
|
||||||
love.mousemoved = movePaddle
|
love.mousemoved = movePaddle
|
||||||
|
|
||||||
function love.mousepressed(x, y, button, istouch, presses)
|
love.mousepressed = explodeAllReflected
|
||||||
love.mouse.setVisible(false)
|
|
||||||
love.mouse.setGrabbed(true)
|
|
||||||
|
|
||||||
if state == states.gameplay then
|
|
||||||
explodeAllReflected()
|
|
||||||
elseif state == states.title then
|
|
||||||
startStage()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function love.keypressed(key, scancode, isrepeat)
|
|
||||||
-- Ungrab mouse if user tried to do any GUI commands
|
|
||||||
if scancode == 'lctrl' or scancode == 'lshift' or scancode == 'lalt' or scancode == 'lgui' or
|
|
||||||
scancode == 'rctrl' or scancode == 'rshift' or scancode == 'ralt' or scancode == 'rgui' then
|
|
||||||
love.mouse.setVisible(true)
|
|
||||||
love.mouse.setGrabbed(false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
love.resize = setScreenDimensions
|
love.resize = setScreenDimensions
|
||||||
|
|
||||||
|
@ -502,41 +471,11 @@ function drawEnemies()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawText(x, y, text_scale, text)
|
|
||||||
love.graphics.setLineWidth(2 / 700 * scale)
|
|
||||||
love.graphics.setColor(1, 1, 1)
|
|
||||||
for i, char in ipairs(text) do
|
|
||||||
local glyph = font[char]
|
|
||||||
for _, line in ipairs(glyph) do
|
|
||||||
local x0, y0 = toScreenCoordinates(x + (i - 1) * text_scale + line[1] * text_scale, y + line[2] * text_scale)
|
|
||||||
local x1, y1 = toScreenCoordinates(x + (i - 1) * text_scale + line[3] * text_scale, y + line[4] * text_scale)
|
|
||||||
love.graphics.line(x0, y0, x1, y1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function textWidth(text_scale, text)
|
|
||||||
-- Each character is 0.7 wide with 0.3 character spacing before scaling
|
|
||||||
-- Width of a text is therefore math.max(#text - 0.3, 0) before scaling
|
|
||||||
-- and math.max(#text - 0.3, 0) * text_scale after
|
|
||||||
return math.max(#text - 0.3, 0) * text_scale
|
|
||||||
end
|
|
||||||
|
|
||||||
function drawTextCentered(y, text_scale, text)
|
|
||||||
local x = (1 - textWidth(text_scale, text)) / 2
|
|
||||||
drawText(x, y, text_scale, text)
|
|
||||||
end
|
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
if state == states.gameplay then
|
drawCities()
|
||||||
drawCities()
|
drawWalls()
|
||||||
drawWalls()
|
drawMissiles()
|
||||||
drawMissiles()
|
drawPaddle()
|
||||||
drawPaddle()
|
drawEnemies()
|
||||||
drawEnemies()
|
drawExplosions()
|
||||||
drawExplosions()
|
|
||||||
elseif state == states.title then
|
|
||||||
drawTextCentered(0.3, 0.1, title)
|
|
||||||
drawTextCentered(0.45, 0.03, start_instructions)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue