-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetting.lua
executable file
·78 lines (70 loc) · 1.47 KB
/
setting.lua
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
local setting = {}
function toggleFullscreen(dt)
if setting.screen then
setting.screen = false
love.window.setFullscreen(setting.screen)
else
setting.screen = true
love.window.setFullscreen(setting.screen, "desktop")
end
end
function setting:load()
self.settings = {}
self.screen = false
self.buttons = {}
self.buttons = env.butt.new(
self.buttons,
{
txt = "Sound on",
aligne = "center",
y = 200,
paddingLeft = 15,
callback = toggleSound
}
)
self.buttons = env.butt.new(
self.buttons,
{
txt = "Fullscreen",
aligne = "center",
y = 300,
paddingLeft = 5,
callback = toggleFullscreen
}
)
self.buttons = env.butt.new(
self.buttons,
{
txt = "Back",
aligne = "center",
y = 400,
paddingLeft = 45,
callback = function() env.page = 0 end
}
)
return setting
end
function setting:update(dt)
end
function toggleSound(bt)
if bt.txt == 'Sound on' then
bt.txt = 'Sound off'
love.audio.stop()
env.sound = 0
else
bt.txt = 'Sound on'
love.audio.stop()
env.sound = 1
end
end
function setting:mousepressed(x, y, bt)
env.butt.mousepressed(setting.buttons, x, y, bt)
end
function setting:draw()
love.graphics.setColor(255, 255, 255, 255)
love.graphics.setBackgroundColor(70,100,100)
love.graphics.setFont(env.bigFont)
love.graphics.print('Setting', love.window.getWidth() / 2 - 75, 60)
env.butt.draw(setting.buttons)
end
return setting