-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.lua
More file actions
52 lines (42 loc) · 1011 Bytes
/
Copy pathmain.lua
File metadata and controls
52 lines (42 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'lib/globles'
require 'lib/ui/colors'
http = require "socket.http"
utf8 = require "utf8"
bg = require 'lib/ui/background'
button = require 'lib/ui/button'
e = require 'lib/engine'
function love.load()
e:load()
bg:load()
ispaused = false
love.keyboard.setTextInput( false )
end
function love.update(dt)
if dt<1/30 and not ispaused then
e:update(dt)
bg:update(dt)
end
end
function love.draw()
love.graphics.setBackgroundColor(255, 255, 255)
bg:draw()
e:draw()
end
function love.keypressed(key)
if key == 'backspace' then
local byteoffset = utf8.offset(user.name, -1)
if byteoffset then
user.name = string.sub(user.name, 1, byteoffset - 1)
end
end
if key == 'return' then
user:updateName(user.name)
sm:changeSceneTo('home')
love.keyboard.setTextInput( false )
end
end
function love.textinput(t)
if #user.name < 10 then
user.name = user.name..t
end
end