-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
139 lines (115 loc) · 3.47 KB
/
main.cpp
File metadata and controls
139 lines (115 loc) · 3.47 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
#include <iostream>
#include "SubSpace.h"
using namespace std;
using namespace SubSpace;
//void sub(int gameWorld,int& i,int intNumBombs);
int main(int argc, char* argv[])
{
//Seed the random number generator
srand(time(0));
//No Wells
int intNoBombs = 0;
intNoBombs = ArgToInt(argv[1]);
//Check the argument count
if(argc != 2)
{
cerr << "Wrong number of arguments or second argument has uneven number" << endl;
exit(ERR_ARGS);
}
//intNoWells = ArgToInt(argv[1]);
//cout << "No Wells: " << intNoWells << endl;
int GameMatrix[TOTAL_ROWS][TOTAL_COLS];
//Initialize Game World
initGameWorld(GameMatrix);
int i=1;
int m=0;
//The main Loop
bool blnContinue = true;
char chInput = '\0';
char chInput1='\0';
do{
//Clear the screen
system("cls");
//Print Game World
//while(tolower(chInput)=='p')
//SubArea(GameMatrix);
//Menu
cout << "No of Bouys and sea mines: " << intNoBombs << endl;
cout << "T - Surface" << endl;
cout << "B - Submerge " << endl;
cout << "X - Exit the Game" << endl;
cin>>chInput1;
while(tolower(chInput1)=='t')
{
system("cls");
cout<<"M = BOUYS"<<endl;
cout<<"L = LAUNCH POSITION"<<endl;
if( i==1)
{
sub1(GameMatrix,i,intNoBombs/2);
}
SubArea(GameMatrix);
cout << "PLEASE CHOOSE AN OPTION" << endl;
cout << "W - Move Up" << endl;
cout << "S - Move Down" << endl;
cout << "A - Move Left" << endl;
cout << "D - Move Right" << endl;
cout << "R - Return to submerge,float or exit the game option" << endl;
cin >> chInput;
switch(tolower(chInput))
{
case 'w':
case 's':
case 'a':
case 'd':
movePlayer(GameMatrix, chInput);
break;
default:
cerr << "Incorrect Entry, Please Retry" << endl;
cin.ignore(100, '\n');
}
if(tolower(chInput)=='r')
break;
}
while(tolower(chInput1)=='b')
{
system("cls");
cout<<"O = SEA MINES"<<endl;
cout<<"L = LAUNCH POSITION"<<endl;
if( m==1)
{
sub2(GameMatrix,m,intNoBombs/2);
}
SurfArea(GameMatrix);
cout << "PLEASE CHOOSE AN OPTION" << endl;
cout << "W - Move Up" << endl;
cout << "S - Move Down" << endl;
cout << "A - Move Left" << endl;
cout << "D - Move Right" << endl;
cout << "R - Return to submerge,float or exit the game option" << endl;
cin >> chInput;
switch(tolower(chInput))
{
case 'w':
case 's':
case 'a':
case 'd':
movePlayer(GameMatrix, chInput);
break;
default:
cerr << "Incorrect Entry, Please Retry" << endl;
cin.ignore(100, '\n');
}
if(tolower(chInput)=='r')
break;
}
if(tolower(chInput1)=='x')
{
cout << "Thanks for playing the Game" << endl;
blnContinue = false;
break;
}
}
while(blnContinue);
return 0;
}