-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tetris.cpp
102 lines (82 loc) · 2.35 KB
/
Tetris.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
#include "Tetris.h"
#include "Manager.h"
void Tetris::playGame(int& score, int& speed)
{
//Set up music
sndPlaySound("next.wav", NULL);
if(manager_.options_.disco_mode_)
PlaySound("bitdust2.wav", NULL, SND_FILENAME|SND_ASYNC|SND_NOSTOP|SND_LOOP);
else
PlaySound("music_game.wav", NULL, SND_FILENAME|SND_ASYNC|SND_NOSTOP|SND_LOOP);
//Set up the screen
manager_.setUpScreen();
manager_.readySetGo();
bool endGame = false;
//Setup game
setSpeedOption(speed);
//Guts of Game
while(!endGame)
{
endGame = manager_.step();
manager_.draw();
}
//Store the score
score = manager_.returnGameStat().score_;
manager_.gameOver();
//char dummy;
//cin.get(dummy);
}
void Tetris::startTetris()
{
char choice;
bool play = true;
bool titleScreenMusicPlaying = false;
int speed = 0;
while(play)
{
//SetUpMusic
if(!titleScreenMusicPlaying)
{
PlaySound("music_title.wav", NULL,SND_FILENAME|SND_ASYNC);
titleScreenMusicPlaying = true;
}
choice = welcomeScreen(); //User's choice entered in welcome screen
//function is returned and stored in choice.
if (choice == '1') //Play the game
{
int score = 0;
playGame(score,speed);
checkForHiScores(score);
highScoreScreen(); // View overall high scores
//Reset the title music to play after a round of game
titleScreenMusicPlaying = false;
}
else if(choice == '2') //Options
{
OptionScreen(speed);
}
else if(choice == '3') //View Instructions ("How to Play")
{
instructionScreen();
}
else if (choice == '4') //View Overall High Scores
{
highScoreScreen();
}
else if (choice == '5') //About
{
aboutScreen();
}
else //if (choice == '6') - Exit
{
play = false;
sndPlaySound("next.wav", NULL);
PlaySound("cupOfTea.wav", NULL, SND_FILENAME|SND_ASYNC|SND_NOSTOP|SND_LOOP);
aboutScreen(); // View the "about this program" screen
}
}
}
void Tetris::setSpeedOption(const int& speedLevel)
{
manager_.setSpeed(speedLevel);
}