-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.adept
74 lines (62 loc) · 2.99 KB
/
menu.adept
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
// ----------------------------- menu.adept -----------------------------
// Module for handling the main menu
// ----------------------------------------------------------------------
import 'glfw/glfw.adept'
import 'sys/cstdio.adept'
import 'sys/cstdlib.adept'
import 'gamedata.adept'
import 'resources.adept'
func menuInput(window *GLFWwindow, resources *Resources, gamedata *GameData) void {
if glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS {
unless gamedata.menu_up_lock {
// Move up one
if gamedata.menu_selection == 0, gamedata.menu_selection = gamedata.max_menu_selection
else gamedata.menu_selection -= 1
gamedata.menu_up_lock = true
}
} else gamedata.menu_up_lock = false
if glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS {
unless gamedata.menu_down_lock {
// Move down one
if gamedata.menu_selection == gamedata.max_menu_selection, gamedata.menu_selection = 0
else gamedata.menu_selection += 1
gamedata.menu_down_lock = true
}
} else gamedata.menu_down_lock = false
if glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS {
unless gamedata.menu_space_lock {
// Select item
selectMenuItem(window, gamedata)
gamedata.menu_space_lock = true
}
} else gamedata.menu_space_lock = false
}
func selectMenuItem(window *GLFWwindow, gamedata *GameData) void {
if gamedata.menu_selection == 0, gamedata.sceneGame()
else glfwSetWindowShouldClose(window, true)
}
func menuRender(resources *Resources, gamedata *GameData) void {
resources.shader.use()
resources.shader.uploadMatrix4f(gamedata.projection_location, gamedata.projection)
gamedata.transformation.identity()
gamedata.transformation.translate(gamedata.width / 2.0f - 128.0f, gamedata.height / 2 - 64.0f, 0.0f)
resources.shader.uploadMatrix4f(gamedata.transformation_location, gamedata.transformation)
bindTexture(resources.start)
resources.model_256x64.draw()
gamedata.transformation.identity()
gamedata.transformation.translate(gamedata.width / 2.0f - 128.0f, gamedata.height / 2 + 32.0f, 0.0f)
resources.shader.uploadMatrix4f(gamedata.transformation_location, gamedata.transformation)
bindTexture(resources.quit)
resources.model_256x64.draw()
gamedata.transformation.identity()
gamedata.transformation.translate(gamedata.width / 2.0f - 128.0f, gamedata.height / 2 - 64.0f + 96.0f * cast float gamedata.menu_selection, 0.0f)
resources.shader.uploadMatrix4f(gamedata.transformation_location, gamedata.transformation)
bindTexture(resources.selection)
resources.model_256x64.draw()
gamedata.transformation.identity()
gamedata.transformation.translate(0.0f, gamedata.height - 128.0f, 0.0f)
gamedata.transformation.scale(2.0f, 2.0f, 0.0f)
resources.shader.uploadMatrix4f(gamedata.transformation_location, gamedata.transformation)
bindTexture(resources.credits_text)
resources.model_256x64.draw()
}