-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmenu_scene.c
97 lines (83 loc) · 1.99 KB
/
menu_scene.c
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <allegro5/allegro.h>
#include <string.h>
#include "menu_scene.h"
#include "game_scene.h"
#include "setting_scene.h"
#include "loading_scene.h"
#include "utility.h"
#include "UI.h"
#include "game.h"
static Button settingButton;
static void init(void) {
settingButton = button_create(SCREEN_W / 2 - 200, 600, 400, 100, "Assets/UI_Button.png", "Assets/UI_Button_hovered.png");
change_bgm("Assets/audio/menu_bgm.mp3");
}
static void update(void) {
update_button(&settingButton);
if (keyState[ALLEGRO_KEY_ENTER]) {
change_scene(create_loading_scene());
}
/*
[TODO HACKATHON 4-3]
Change scene to setting scene when the button is pressed
*/
}
static void draw(void) {
// Title Text
al_draw_text(
TITLE_FONT,
al_map_rgb(146, 161, 185),
SCREEN_W / 2,
225,
ALLEGRO_ALIGN_CENTER,
"NTHU-RPG ADVENTURE"
);
al_draw_text(
TITLE_FONT,
al_map_rgb(199, 207, 221),
SCREEN_W / 2,
220,
ALLEGRO_ALIGN_CENTER,
"NTHU-RPG ADVENTURE"
);
al_draw_text(
P2_FONT,
al_map_rgb(255, 255, 255),
SCREEN_W / 2,
500,
ALLEGRO_ALIGN_CENTER,
"PRESS [ENTER] TO PLAY"
);
// button
draw_button(settingButton);
// button text
al_draw_text(
P2_FONT,
al_map_rgb(66, 76, 110),
SCREEN_W / 2,
600 + 28 + settingButton.hovered * 11,
ALLEGRO_ALIGN_CENTER,
"SETTING"
);
al_draw_text(
P2_FONT,
al_map_rgb(225, 225, 225),
SCREEN_W / 2,
600 + 31 + settingButton.hovered * 11,
ALLEGRO_ALIGN_CENTER,
"SETTING"
);
}
static void destroy(void) {
destroy_button(&settingButton);
}
Scene create_menu_scene(void) {
Scene scene;
memset(&scene, 0, sizeof(Scene));
scene.name = "menu";
scene.init = &init;
scene.draw = &draw;
scene.update = &update;
scene.destroy = &destroy;
return scene;
}