-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathmenu.cpp
141 lines (129 loc) · 3.01 KB
/
menu.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//寮女꽉데
#include "global.h"
#include "menu.h"
#include "keymsg.h"
#include "graphics.h"
#include "headers.h"
#include "load_screen.h"
#include "level.h"
#include "camera.h"
#include "dirent.h"
#include <sys/types.h>
#include <cstdio>
#include <iostream>
void Menu::reset()
{
NOW_SCENR = 0;
SCORE = 0;
LIVES = 3;
isshow = true;
isrun = true;
music.Play(0);
level.freeze = true;
camera.movecam(0, 0);
level.start();
}
Menu::Menu()
{
title = newimage();
getimage1(title, "resources\\graphics\\title_screen.png", 1, 60, 176, 147);
zoomImage(title, 2.5);
music.OpenFile("resources\\music\\start.mp3");
music.SetVolume(0.5);
music.Play();
}
bool Menu::render()
{
if (!isshow) return false;
option_cursor.update();
//putimage_withalpha(NULL, title, 170, 100, 2, 150, 440, 220); //鞫刻깃痙
putimage_withalpha(NULL, title, 170, 100); //鞫刻깃痙
return true;
}
bool Menu::update()
{
if (!isrun) return false;
if (!isshow) music.Stop();
else {
if (music.GetPlayStatus() == MUSIC_MODE_STOP) {
//닒庫역迦꺄렴
music.Play(0);
}
}
return render();
}
void Menu::start()
{
reset();
}
void Menu::stop()
{
music.Stop();
isrun = false;
load_screen.start("begin");
}
Menu menu;
Option_cursor::Option_cursor()
{
icon = newimage();
getimage1(icon, "resources\\graphics\\title_screen.png", 3, 155, 12, 164);
zoomImage(icon, 2.5);
DIR* dir;
struct dirent* ptr;
dir = opendir("level_data"); //댔역뎠품커쩌
while ((ptr = readdir(dir)) != NULL) {
std::string s = ptr->d_name;
if (s.length() <= 4) continue;
if (s.substr(s.length() - 4, s.length()) != ".mio") continue;
s = s.erase(s.length() - 4, s.length());
levels.push_back(s);
levels_top_score[s] = 0;
}
if (levels.size() > 0) {
level_id = 0;
while (!camera.finish_init) Sleep(10);
level.start(("level_data\\" + levels[0] + ".mio").c_str());
LEVEL_NAME = levels[0];
}
closedir(dir);
}
bool Option_cursor::render()
{
if (!isshow) return false;
putimage_withalpha(NULL, icon, 240, 400);
if (level_id - 1 >= 0)
xyprintf(272, 350, levels[level_id - 1].c_str());
if (level_id >= 0)
xyprintf(272, 395, levels[level_id].c_str());
if (level_id + 1 < levels.size())
xyprintf(272, 440, levels[level_id + 1].c_str());
if (LEVEL_NAME != "") {
char topscore[20];
sprintf(topscore, "TOP - %06d", levels_top_score[LEVEL_NAME]);
xyprintf(272, 480, topscore);
}
return true;
}
bool Option_cursor::update()
{
if (!isrun) return false;
if (level_id != -1) {
key_msg keyMsg;
bool flag = keymsg.getmsg(keyMsg, key_down);
if (flag && keyMsg.msg == key_msg_down &&level_id != levels.size() - 1) {
level_id++;
level.start(("level_data\\" + levels[level_id] + ".mio").c_str());
LEVEL_NAME = levels[level_id];
}
flag = keymsg.getmsg(keyMsg, key_up);
if (flag && keyMsg.msg == key_msg_down && level_id != 0) {
level_id--;
level.start(("level_data\\" + levels[level_id] + ".mio").c_str());
LEVEL_NAME = levels[level_id];
}
flag = keymsg.getmsg(keyMsg, key_enter);
if (flag) menu.stop();
}
return render();
}
Option_cursor option_cursor;