-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.lua
55 lines (44 loc) · 1.41 KB
/
menu.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
Gamestate = require "lib/hump.gamestate"
menu = {}
soundactivated = true
function menu:init()
self.background = loadImage("menuback")
self.logo = loadImage("logo")
self.botonjugar = Button(660, 400, loadImage("botonjugar"))
self.botonsalir = Button(660, 560, loadImage("botonsalir"))
self.botonsonido = SmallButton(40, 26, loadImage("sonido-on"), loadImage("sonido-off"))
self.botonventana = SmallButton(180, 26, loadImage("pantalla-completa"), loadImage("pantalla-ventana"))
end
function menu:update(dt)
self.botonjugar:update(dt)
self.botonsalir:update(dt)
self.botonsonido:update(dt)
self.botonventana:update(dt)
end
function menu:mousereleased(x, y, button)
print(string.format("button: %d\n", button))
-- if right click ignore
if button ~= 1 then
return
end
if self.botonjugar.hovered then
Gamestate.switch(game)
elseif self.botonsalir.hovered then
love.event.quit()
elseif self.botonsonido.hovered then
self.botonsonido:activate()
soundactivated = not soundactivated
elseif self.botonventana.hovered then
self.botonventana:activate()
fullscreen, fstype = love.window.getFullscreen()
love.window.setFullscreen(not fullscreen, "exclusive")
end
end
function menu:draw()
love.graphics.draw(self.background, 0, 0)
love.graphics.draw(self.logo, 485, 16)
self.botonjugar:draw()
self.botonsalir:draw()
self.botonsonido:draw()
self.botonventana:draw()
end