-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (53 loc) · 1.8 KB
/
main.cpp
File metadata and controls
65 lines (53 loc) · 1.8 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
/** Eric Karpovits - ICS3U - Dodge the falling rocks summative - June 12 2020
* In this game the user dodges the falling rocks to obtain points.
* Check out the instructions in game to know how to play.
*/
#include "declarations.h"
#include "prototype.h"
Application app;
/// Main
int main(int argc, char *argv[]) {
//Declare variables
bool continuePlaying = true;
int returnCode = 0;
int gameMode = START_MENU;
//Declare struct variables
Character mainCharacter;
Rocks fallingRocks[NUMBER_OF_ROCKS];
Keyboard userKeyboard;
Paused timerPaused;
Lives userLives[NUMBER_OF_LIVES];
PowerUp fallingPowerUps[NUMBER_OF_POWERUPS];
Button clickableButton [NUMBER_OF_BUTTONS];
InstructionImages displayImages;
// Initialize restart key bool
userKeyboard.keyR = false;
// Function to set up the game
// Returns a non 0 if something went wrong
returnCode = setupMain(mainCharacter, userLives, fallingRocks, userKeyboard, fallingPowerUps, displayImages);
if (returnCode != 0) {
return returnCode;
}
// Set up the clickable buttons
buttonSetup(clickableButton, gameMode);
while (continuePlaying) {
// A play game function which allows the whole game to operate
returnCode = playGame(
continuePlaying,
userKeyboard,
mainCharacter,
fallingRocks,
userLives,
fallingPowerUps,
gameMode,
clickableButton,
timerPaused,
displayImages);
if (returnCode != 0) {
return returnCode;
}
}
//A function to exit the program
exitProgram(mainCharacter, displayImages);
return 0;
}