add intro and settings menu
This commit is contained in:
parent
e3cf871f79
commit
b77f6fccf1
2
conf.lua
2
conf.lua
|
@ -3,7 +3,7 @@ function love.conf(t)
|
||||||
t.appendidentity = false -- Search files in source directory before save directory (boolean)
|
t.appendidentity = false -- Search files in source directory before save directory (boolean)
|
||||||
t.version = "11.4" -- The LÖVE version this game was made for (string)
|
t.version = "11.4" -- The LÖVE version this game was made for (string)
|
||||||
t.console = false -- Attach a console (boolean, Windows only)
|
t.console = false -- Attach a console (boolean, Windows only)
|
||||||
t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean)
|
t.accelerometerjoystick = false -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean)
|
||||||
t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean)
|
t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean)
|
||||||
t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)
|
t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
local t = {}
|
||||||
|
|
||||||
|
local fallbackString = function( t, s )
|
||||||
|
return "!UNLOCALISED STRING!: "..tostring( s )
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.setLanguage( name )
|
||||||
|
name = name or "en"
|
||||||
|
setmetatable( t, {__index =
|
||||||
|
setmetatable( require( "i18n."..name ), {__index =
|
||||||
|
fallbackString } ) } )
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
return t.setLanguage( "en" )
|
|
@ -3,7 +3,7 @@ return {
|
||||||
font = "fonts/bjcrus.ttf",
|
font = "fonts/bjcrus.ttf",
|
||||||
intro = [[ᐊᑯᓕᕕᒃ, 1968
|
intro = [[ᐊᑯᓕᕕᒃ, 1968
|
||||||
|
|
||||||
BROTHER JARED HAS BROUGHT THE ROCK OF FINAL JUDGEMENT, HIS BELOVED FLOCK, BEYOND DARKEST THULE, TO THE REMAINS OF A REMOTE TRADING POST.
|
BROTHER JARED HAS BROUGHT THE ROCK OF THE JUDGEMENT, HIS BELOVED FLOCK, TO THE REMAINS OF A REMOTE TRADING POST BEYOND DARKEST THULE.
|
||||||
|
|
||||||
HERE WE WILL ATTEMPT TO CONJURE ZIMINIAR, THE KING OF THE NORTH.
|
HERE WE WILL ATTEMPT TO CONJURE ZIMINIAR, THE KING OF THE NORTH.
|
||||||
|
|
||||||
|
@ -11,9 +11,13 @@ I HAVE VOLUNTEERED TO BE THE FIRST TO ATTEMPT THE RITUAL, THAT I MIGHT BE CROWNE
|
||||||
loss = "YOU HAVE DIED OF %s",
|
loss = "YOU HAVE DIED OF %s",
|
||||||
win = "RICHES TO THE CONJURER",
|
win = "RICHES TO THE CONJURER",
|
||||||
settingsMenuTitle = "SETTINGS",
|
settingsMenuTitle = "SETTINGS",
|
||||||
|
settingsMenuBackspace = [[ESCAPE TO CANCEL
|
||||||
|
ENTER TO KEEP]],
|
||||||
|
settingsMenuScroll = "SCROLL TO CHANGE SETTING",
|
||||||
toContinue = "PRESS ENTER TO CONTINUE",
|
toContinue = "PRESS ENTER TO CONTINUE",
|
||||||
keyForward = "FORWARD",
|
keyForward = "FORWARD",
|
||||||
keyBack = "BACK",
|
keyBack = "BACK",
|
||||||
keyLeft = "LEFT",
|
keyLeft = "LEFT",
|
||||||
keyRight = "RIGHT",
|
keyRight = "RIGHT",
|
||||||
|
mouseSensitivity = "TURN SPEED",
|
||||||
}
|
}
|
4
main.lua
4
main.lua
|
@ -1,8 +1,8 @@
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
local scene = require( "scene" )
|
local scene = require( "scene" )
|
||||||
local strings = require( "i18n.en" )
|
local strings = require( "i18n" )
|
||||||
local slideshow = require( "scenes.slideshow" )
|
local slideshow = require( "scenes.slideshow" )
|
||||||
local settings = require( "scenes.settings" )
|
local settings = require( "scenes.settings" )
|
||||||
|
|
||||||
love.graphics.setNewFont( strings.font, 18 )
|
love.graphics.setNewFont( strings.font, 20 )
|
||||||
return slideshow.play( strings.intro, function() return scene.load( settings ) end )
|
return slideshow.play( strings.intro, function() return scene.load( settings ) end )
|
|
@ -0,0 +1,21 @@
|
||||||
|
local player = {
|
||||||
|
x = 0,
|
||||||
|
y = 0,
|
||||||
|
z = 0,
|
||||||
|
vx = 0,
|
||||||
|
vy = 0,
|
||||||
|
yaw = 0,
|
||||||
|
pitch = 0,
|
||||||
|
desx = 0,
|
||||||
|
desy = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
function player.updateDesiredDirection( x, y )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function player.update( dt )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return player
|
|
@ -0,0 +1,39 @@
|
||||||
|
local love = assert( love )
|
||||||
|
local player = require( "player" )
|
||||||
|
local settings = require( "settings" )
|
||||||
|
local t = {}
|
||||||
|
|
||||||
|
function t.play()
|
||||||
|
local scene = require( "scene" )
|
||||||
|
return scene.load( t )
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.draw()
|
||||||
|
love.graphics.setScissor( )
|
||||||
|
love.graphics.push( "transform" )
|
||||||
|
love.graphics.scale( love.graphics.getWidth(), love.graphics.getHeight() )
|
||||||
|
love.graphics.rectangle( "fill", player.x, player.y, 6, 6 )
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.update( dt )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.mousepressed( x, y, button, isTouch, presses )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.keypressed( key, code, isrepeat )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.keyreleased( key, code )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.mousemoved( x, y, dx, dy, isTouch )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return t
|
|
@ -1,20 +1,76 @@
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
local strings = require( "i18n.en" )
|
local strings = require( "i18n" )
|
||||||
local settings = require( "settings" )
|
local settings = require( "settings" )
|
||||||
local t = {}
|
local t = {}
|
||||||
|
|
||||||
local currentSetting
|
local currentSetting = false
|
||||||
|
local mouseOverSetting = false
|
||||||
|
local cachedSettingVal = nil
|
||||||
|
local menu = {}
|
||||||
|
for i, setting in ipairs( settings ) do
|
||||||
|
menu[i] = { x = 410, y = 10 + i * 25, w = love.graphics.getWidth() - 410 , h = 25 }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restoreCachedSetting()
|
||||||
|
if (not currentSetting) or (cachedSettingVal == nil) then return end
|
||||||
|
settings[currentSetting].val = cachedSettingVal
|
||||||
|
cachedSettingVal = nil
|
||||||
|
end
|
||||||
|
|
||||||
function t.keypressed( key, code, isRepeat )
|
function t.keypressed( key, code, isRepeat )
|
||||||
|
if currentSetting then
|
||||||
|
if code == "escape" or code == "return" then
|
||||||
|
if code == "escape" then restoreCachedSetting() end
|
||||||
|
currentSetting = false
|
||||||
|
return
|
||||||
|
elseif settings[currentSetting].type == "keybind" then
|
||||||
|
settings[currentSetting].val = code
|
||||||
|
currentSetting = false
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if code == "return" then
|
||||||
|
local main = require( "scenes.main" )
|
||||||
|
return main.play()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function t.mousemoved()
|
function t.wheelmoved(x, y)
|
||||||
|
if not currentSetting then return end
|
||||||
|
local setting = settings[currentSetting]
|
||||||
|
if setting.type == "number" then
|
||||||
|
if y > 0 then setting.val = setting.val + 1
|
||||||
|
elseif y < 0 then setting.val = setting.val - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function t.mousepressed()
|
function t.mousemoved( x, y )
|
||||||
|
for i, button in ipairs( menu ) do
|
||||||
|
if
|
||||||
|
x > button.x and
|
||||||
|
y > button.y and
|
||||||
|
y <= button.y + button.h then
|
||||||
|
mouseOverSetting = i
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mouseOverSetting = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function t.mousepressed( x, y )
|
||||||
|
for i, button in ipairs( menu ) do
|
||||||
|
if
|
||||||
|
x > button.x and
|
||||||
|
y > button.y and
|
||||||
|
y <= button.y + button.h then
|
||||||
|
restoreCachedSetting()
|
||||||
|
currentSetting = i
|
||||||
|
cachedSettingVal = settings[i].val
|
||||||
|
mouseOverSetting = false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function t.update()
|
function t.update()
|
||||||
|
@ -22,14 +78,45 @@ function t.update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function t.draw()
|
function t.draw()
|
||||||
love.graphics.print( strings.toContinue, 0, love.graphics.getHeight() - love.graphics.getFont():getHeight() )
|
|
||||||
love.graphics.print( strings.settingsMenuTitle, 0, 0 )
|
love.graphics.setScissor( 400, 0, love.graphics.getWidth() - 400, love.graphics.getHeight() )
|
||||||
for i, setting in ipairs( settings ) do
|
|
||||||
local x, y = 10, 10 + i * 100
|
love.graphics.setColor( 1, 0.1, 0.1, 0.2 )
|
||||||
love.graphics.rectangle( "line", x, y, love.graphics.getWidth(), 100 )
|
if mouseOverSetting then
|
||||||
love.graphics.print( setting.name, x + 10, y )
|
love.graphics.rectangle( "fill",
|
||||||
love.graphics.print( setting.val, x + 10, y + 25 )
|
menu[mouseOverSetting].x,
|
||||||
|
menu[mouseOverSetting].y,
|
||||||
|
menu[mouseOverSetting].w,
|
||||||
|
menu[mouseOverSetting].h )
|
||||||
end
|
end
|
||||||
|
love.graphics.setColor( 1, 0.1, 0.1, 0.8 )
|
||||||
|
if currentSetting then
|
||||||
|
love.graphics.rectangle( "fill",
|
||||||
|
menu[currentSetting].x,
|
||||||
|
menu[currentSetting].y,
|
||||||
|
menu[currentSetting].w,
|
||||||
|
menu[currentSetting].h )
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.setColor( 1, 1, 1, 1 )
|
||||||
|
love.graphics.print( strings.settingsMenuTitle, 400 , 0 )
|
||||||
|
|
||||||
|
for i, setting in ipairs( settings ) do
|
||||||
|
local x, y = menu[i].x, menu[i].y
|
||||||
|
--love.graphics.rectangle( "line", x, y, love.graphics.getWidth() / 2, 25 )
|
||||||
|
love.graphics.print( setting.name, x + 10, y )
|
||||||
|
love.graphics.print( setting.val, x + 250, y )
|
||||||
|
end
|
||||||
|
|
||||||
|
if currentSetting then
|
||||||
|
love.graphics.print( strings.settingsMenuBackspace, 400, love.graphics.getHeight() - 2 * love.graphics.getFont():getHeight())
|
||||||
|
if settings[currentSetting].type == "number" then
|
||||||
|
love.graphics.print( strings.settingsMenuScroll, 400, love.graphics.getHeight() - 3 * love.graphics.getFont():getHeight())
|
||||||
|
end
|
||||||
|
else
|
||||||
|
love.graphics.print( strings.toContinue, 400, love.graphics.getHeight() - love.graphics.getFont():getHeight() )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return t
|
return t
|
|
@ -1,7 +1,7 @@
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
local scene = require( "scene" )
|
local scene = require( "scene" )
|
||||||
local settings = require( "scenes.settings" )
|
local settings = require( "scenes.settings" )
|
||||||
local strings = require( "i18n.en" )
|
local strings = require( "i18n" )
|
||||||
local printString
|
local printString
|
||||||
local fullString
|
local fullString
|
||||||
local loadNextScene
|
local loadNextScene
|
||||||
|
@ -24,10 +24,9 @@ end
|
||||||
|
|
||||||
function t.update( dt )
|
function t.update( dt )
|
||||||
time = time + dt
|
time = time + dt
|
||||||
if time > 0.05 then
|
if time > 0.03 then
|
||||||
time = 0
|
time = 0
|
||||||
len = len + 1
|
len = len + 1
|
||||||
if len > fullString:len() + 40 then return loadNextScene() end
|
|
||||||
printString = fullString:sub( 1, ( utf8.offset( fullString, len ) or 0 ) - 1 )
|
printString = fullString:sub( 1, ( utf8.offset( fullString, len ) or 0 ) - 1 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
17
settings.lua
17
settings.lua
|
@ -1,7 +1,12 @@
|
||||||
local strings = require( "i18n.en" )
|
local strings = require( "i18n" )
|
||||||
return {
|
local settings = {
|
||||||
{ setting = "keyForward", name = strings.keyForward, val = "w" },
|
{ setting = "keyForward", type = "keybind", name = strings.keyForward, val = "w" },
|
||||||
{ setting = "keyBack", name = strings.keyBack, val = "a" },
|
{ setting = "keyBack", type = "keybind", name = strings.keyBack, val = "s" },
|
||||||
{ setting = "keyLeft", name = strings.keyLeft, val = "s" },
|
{ setting = "keyLeft", type = "keybind", name = strings.keyLeft, val = "a" },
|
||||||
{ setting = "keyRight", name = strings.keyRight, val = "d" },
|
{ setting = "keyRight", type = "keybind", name = strings.keyRight, val = "d" },
|
||||||
|
{ setting = "mouseSensitivity",
|
||||||
|
type = "number",
|
||||||
|
name = strings.mouseSensitivity,
|
||||||
|
val = 0 },
|
||||||
}
|
}
|
||||||
|
return settings
|
Loading…
Reference in New Issue