-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
139 lines (111 loc) · 2.98 KB
/
Copy pathmain.cpp
File metadata and controls
139 lines (111 loc) · 2.98 KB
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
#include "game.h"
#include "game_fun.h"
#include "game_pair.h"
#include "game_great.h"
#include "curses.h"
#include "color.h""
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char** argv)
{
//播放准备阶段的音乐
sf::Music* backgroundMusic1 = gameMusic("waiting.ogg");
backgroundMusic1->play();
//打印背景图
displayImageWithText();
sf::Sound* sound1 = gameSound("game_start.wav");
sound1->play();
bool music = false;
action:
//选择模式
if (music)
backgroundMusic1->play();
int mode = renderMenu();
sound1->play();
if (mode == 0) {
//输入玩家姓名
string s = enterName();
backgroundMusic1->stop();
sound1->play();
//播放游戏阶段的音乐
sf::Music* backgroundMusic2 = gameMusic("African_fun_long.ogg");
backgroundMusic2->play();
//生成相应游戏
Game game;
game.setName(s);
game.startGame();
backgroundMusic2->stop();
if (game.getBack()) {
music = true;
goto action;
}
delete backgroundMusic1;
delete backgroundMusic2;
delete sound1;
}
else if (mode == 1) {
string s1;
string s2;
enterNamePair(s1, s2);
backgroundMusic1->stop();
sound1->play();
sf::Music* backgroundMusic2 = gameMusic("African_fun_long.ogg");
backgroundMusic2->play();
GamePair game_pair;
game_pair.setName(s1,s2);
game_pair.startGame();
backgroundMusic2->stop();
if (game_pair.getBack()) {
music = true;
goto action;
}
delete backgroundMusic1;
delete backgroundMusic2;
delete sound1;
}
else if (mode == 2) {
//输入玩家姓名
string s = enterName();
backgroundMusic1->stop();
sound1->play();
//播放游戏阶段的音乐
sf::Music* backgroundMusic2 = gameMusic("African_fun_long.ogg");
backgroundMusic2->play();
//生成相应游戏
GameFun game_fun;
game_fun.setName(s);
game_fun.startGame();
backgroundMusic2->stop();
if (game_fun.getBack()) {
music = true;
goto action;
}
delete backgroundMusic1;
delete backgroundMusic2;
delete sound1;
}
else if (mode == 3) {
//输入玩家姓名
string s = enterName();
backgroundMusic1->stop();
sound1->play();
//播放游戏阶段的音乐
sf::Music* backgroundMusic2 = gameMusic("African_fun_long.ogg");
backgroundMusic2->play();
//生成相应游戏
Game_great game_great;
game_great.setName(s);
game_great.startGame();
backgroundMusic2->stop();
if (game_great.getBack()) {
music = true;
goto action;
}
delete backgroundMusic1;
delete backgroundMusic2;
delete sound1;
}
return 0;
}