-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamegrid.cpp
More file actions
44 lines (37 loc) · 852 Bytes
/
Copy pathgamegrid.cpp
File metadata and controls
44 lines (37 loc) · 852 Bytes
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
#include "gamegrid.h"
GameGrid::GameGrid(const char (©)[20][10]){
for (int i =0; i < 20; i++){
for (int j =0; j < 10; j++){
data[i][j] = copy[i][j] ;
}
}
}
int GameGrid::lineComplete(){
bool allStarsSoFar;
for(int y = 19;y >= 0;y--){
allStarsSoFar = true;
for(int x = 0;x < 10;x++){
if (!(data[y][x] == '*') ){
allStarsSoFar = false;
break;
}
}
if (allStarsSoFar == true){
return y;
}
}
return -1;
}
char GameGrid::getData(int y, int x){
return data[y][x];
}
void GameGrid::shift(int y){
for (int i = y; i > 0;i--){
for(int j = 0; j< 10; j++){
data[i][j] = data[i-1][j];
}
}
for(int j = 0; j< 10; j++){
data[0][j] = ' ';
}
}