summaryrefslogtreecommitdiff
path: root/client/main.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-04-09 12:10:00 +0100
committerubq323 <ubq323@ubq323.website>2023-04-09 12:10:00 +0100
commitd74f0d75b214b893e9069a32612dae9c33f4bb52 (patch)
treeffd22bb82c28ad57e6ef8c27db21086f793bb105 /client/main.lua
parent6e9a052aa877222a1a494ddcdc5507b5bcc3ea68 (diff)
misc things
Diffstat (limited to 'client/main.lua')
-rw-r--r--client/main.lua41
1 files changed, 34 insertions, 7 deletions
diff --git a/client/main.lua b/client/main.lua
index db4b6bf..1d9409f 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -1,16 +1,20 @@
local gamescene = require"game"
+local utf8 = require 'utf8'
local current_scene
-local function switch_scene(newscene)
+local function switch_scene(newscene,...)
if current_scene.quit then current_scene.quit() end
current_scene = newscene
- if newscene.load then newscene.load() end
+ if newscene.load then newscene.load(...) end
end
local big_font = love.graphics.newFont(72)
local normal_font = love.graphics.getFont()
+local username = 'horace'
+
+
local titlescene = {}
function titlescene.draw()
love.graphics.clear(1,1,1)
@@ -18,19 +22,40 @@ function titlescene.draw()
love.graphics.setColor(0,0,0)
love.graphics.setFont(big_font)
love.graphics.print("hexagon emulator",30,30)
-
love.graphics.setFont(normal_font)
- love.graphics.print("press <enter> to start",40,120)
+
+ love.graphics.print("enter username: ",40,120)
+
+ love.graphics.setColor(0,0,0,0.8)
+ love.graphics.rectangle('fill', 60,150, 3+normal_font:getWidth(username), 15)
+ love.graphics.setColor(1,1,1)
+ love.graphics.print(username, 60, 150)
+
+ love.graphics.setColor(0,0,0)
+ love.graphics.print("press <enter> to start",40,250)
end
-local evilscene
+
function titlescene.keypressed(k,s,r)
- if k=="return" then
+ if k=='backspace' then
+ local b = utf8.offset(username, -1)
+ if b then
+ username = username:sub(1,b-1)
+ end
+ elseif k=="return" then
switch_scene(gamescene)
end
end
+function titlescene.textinput(text)
+ username = username .. text
+end
+
+function titlescene.load()
+ love.keyboard.setKeyRepeat(true)
+end
+
+
-current_scene=titlescene
for _,f in ipairs{
"update",
@@ -46,4 +71,6 @@ for _,f in ipairs{
end
end
+current_scene=titlescene
+current_scene.load()