Commit ac635381 authored by Nelson Phillips's avatar Nelson Phillips

autosave

parent 962b4c8a
......@@ -8,7 +8,6 @@ using namespace std;
Snake bdy;
vector <Body> parts;
void Snake::movement(char input){
if((input == 'w'|| input == 'W')&& direction != 3 )
direction = 1;
......@@ -48,8 +47,8 @@ vector <Body> parts;
parts[0].changeY(0);
}
for (int count = 0; count < parts.size() - 1; count++){
if (count != 0)
for (int count = 0; count < parts.size(); count++){
if (count != 0)
parts[count].follow(count);
}
}
......@@ -58,29 +57,26 @@ vector <Body> parts;
void Snake::draw(){
for (int i = 0; i < 14; i++){
for (int q = 0; q < 30; q++){
if (x < 1)x++;
if (y < 1)y++;
if (x > 11)x--;
if (y > 28)y--;
if (x < 1)bdy.over();
if (y < 1)bdy.over();
if (x > 11)bdy.over();
if (y > 28)bdy.over();
grid[i][q] = whtSpace;
if (h == i || o == q)
grid[h][o] = '*';
if (i == x && q == y)
grid[x][y] = 'S';
if ((i != h || o != q) && (i != x || q != y))
grid[i][q] = whtSpace;
if (i == 12 || i == 0 || q == 0 || q == 29){
grid[i][q] = 'O';
}
for ( int count = 0; count < parts.size(); count++){
grid[parts[count].getX()][parts[count].getY()] = 'B';
}
}
for ( int count = 0; count < parts.size(); count++){
grid[parts[count].getX()][parts[count].getY()] = 'B';
}
if (i == x && q == y)
grid[x][y] = 'S';
}
}
......@@ -100,7 +96,6 @@ if (grid [x][y] == grid[h][o] ){
bdy.lengthed();
bdy.newBody();
}
}
int Snake::snekoScore(){
return score;
......@@ -129,7 +124,14 @@ if (grid [x][y] == grid[h][o] ){
Body segment (x,y);
parts.push_back(segment);
}
void Snake::over(){
quitbool = true;
}
bool Snake::quit(){
return quitbool;
}
......
......@@ -18,6 +18,9 @@ class Snake {
void newBody();
void lengthed();
int getLeng();
void over();
bool quit();
private:
int x = 5, y = 5, i = 0, q = 0, score = 0,
h = (rand() % 14), o = (rand() % 14);
......@@ -26,6 +29,7 @@ class Snake {
char whtSpace = ' ';
int direction = 5;
int length = -1;
bool quitbool = false;
};
......
......@@ -13,7 +13,7 @@ Thread Sneko;
ReadInput inputRead;
void charCall() {
while (1){
while (!BrdSet.quit()){
BrdSet.input = inputRead.collectInput();
if (BrdSet.input == 'q' || BrdSet.input == 'Q')
break;
......@@ -22,7 +22,7 @@ void charCall() {
}
void snakePrint(){
while (1){
while (!BrdSet.quit()){
Sneko.Sleep(1);
system("stty cooked");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment