local gamescene = require"game" local utf8 = require 'utf8' local current_scene local function switch_scene(newscene,...) if current_scene.quit then current_scene.quit() end current_scene = newscene 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) love.graphics.origin() 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("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 to start",40,250) end function titlescene.keypressed(k,s,r) 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, username) end end function titlescene.textinput(text) username = username .. text end function titlescene.load() love.keyboard.setKeyRepeat(true) end for _,f in ipairs{ "update", "draw", "keypressed", "textinput", "wheelmoved", "quit", } do love[f] = function(...) local x = current_scene[f] if x then return x(...) end end end current_scene=titlescene current_scene.load()