diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/game.lua | 4 | ||||
-rw-r--r-- | client/main.lua | 41 |
2 files changed, 38 insertions, 7 deletions
diff --git a/client/game.lua b/client/game.lua index aa2e94c..50b74f9 100644 --- a/client/game.lua +++ b/client/game.lua @@ -296,6 +296,8 @@ local function draw() -- selected tile (temp) util.print_good(tostring(selected_tile), "center",10) + local W,H = love.graphics.getDimensions() + if _G.debugmode and local_player then util.print_good(table.concat({ "ms "..tostring(sm), @@ -309,6 +311,8 @@ local function draw() "", "fps "..tostring(love.timer.getFPS()), "ping "..tostring(peer:round_trip_time()), + "", + "res"..W.."x"..H, },"\n"),10,10) end 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() |