-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.cpp
118 lines (102 loc) · 3.03 KB
/
actions.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
#include "gamestates.h"
void Gamestate::actContinue(GameInterface* game)
{
if (game->ifPlaying() == true && game->ifPlayerWon() == false)
{
std::cout<<"yes";
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(game->getLevelPlaying());
}
}
void Gamestate::actStartAgain(GameInterface* game)
{
game->setLevelShouldReset(true, game->getLevelPlaying());
goToLevel(game, game->getLevelPlaying());
}
void Gamestate::goToPauseMenu(GameInterface* game)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_PAUSE_MENU);
}
void Gamestate::goToWinMenu (GameInterface* game)
{
game->setScoresShouldUpdate(true);
game->setScoresMenuShouldUpdate(true);
game->setLevelShouldReset(true, game->getLevelPlaying());
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_WIN_MENU);
game->setPlayerWon(true);
}
void Gamestate::goToNextLevel (GameInterface* game)
{
if (game->getLevelPlaying() < GAME_LEVELS_COUNT)
{
game->setLevelShouldReset(true, game->getLevelPlaying());
goToLevel(game, game->getLevelPlaying() + 1);
}
}
void Gamestate::goToMenu (GameInterface* game)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_MENU);
}
void Gamestate::goToLevelsMenu(GameInterface* game)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_LEVELS_MENU);
}
void Gamestate::goToOptions (GameInterface* game)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_OPTIONS);
}
void Gamestate::goBackFromOptions(GameInterface* game)
{
if (game->getPreviousGameState() == GAME_STATE_MENU)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_MENU);
}
if (game->getPreviousGameState() == GAME_STATE_PAUSE_MENU)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_PAUSE_MENU);
}
}
void Gamestate::goToScores (GameInterface* game)
{
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(GAME_STATE_SCORES);
}
void Gamestate::goToLevel (GameInterface* game, int level_playing)
{
game->setPlayerWon(false);
game->setIfPlaying(true);
game->setPreviousGameState(game->getCurGameState());
game->setCurGameState(level_playing);
game->setLevelPlaying(game->getCurGameState());
}
void Gamestate::actSetBananaType(GameInterface *game, int type)
{
if (game->getBananaType() != type)
{
game->setBananaType(type);
game->setBananaShouldChange(true);
}
}
void Gamestate::actMusicOn (GameInterface *game)
{
if (game->getMusicState() == OFF)
{
game->play_musuc();
game->setMusicState(ON);
}
}
void Gamestate::actMusicOff (GameInterface *game)
{
if (game->getMusicState() == ON)
{
game->stop_music();
game->setMusicState(OFF);
}
}