Commit 5a963088 authored by Nelson Phillips's avatar Nelson Phillips
Browse files

autosave

parent 19e0fbe5
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#include <unistd.h> #include <unistd.h>
#include <vector>
#include "Snake.h" #include "Snake.h"
using namespace std; using namespace std;
...@@ -23,31 +24,34 @@ using namespace std; ...@@ -23,31 +24,34 @@ using namespace std;
void Snake::draw(){ void Snake::draw(){
for (int i = 0; i < 14; i++){ for (int i = 0; i < 14; i++){
cout << endl; cout << endl;
for (int q = 0; q < 30; q++){ for (int q = 0; q < 30; q++){
if (x < 0)x++; if (x < 0)x++;
if (y < 0)y++; if (y < 0)y++;
if (x > 12)x--; if (x > 12)x--;
if (y > 29)y--; if (y > 29)y--;
if (h == i || o == q)
if (h == i || o == q)
grid[h][o] = '*'; grid[h][o] = '*';
if (i == x && q == y) if (i == x && q == y)
grid[x][y] = 'S'; grid[x][y] = 'S';
else if (i != h || o != q) else if (i != h || o != q)
grid[i][q] = whtSpace; grid[i][q] = whtSpace;
cout << grid[i][q] << " ";
} cout << grid[i][q] << " ";
} }
if (grid [x][y] == grid[h][o] ){ }
h = (rand() % 13); if (grid [x][y] == grid[h][o] ){
o = (rand() % 30); h = (rand() % 13);
score++; o = (rand() % 30);
} score++;
}
}
}
int Snake::snekoScore(){ int Snake::snekoScore(){
return score; return score;
} }
...@@ -56,4 +60,14 @@ using namespace std; ...@@ -56,4 +60,14 @@ using namespace std;
for (int p = 0; p < 40; p++){ for (int p = 0; p < 40; p++){
cout << endl; cout << endl;
} }
} }
\ No newline at end of file
bool Snake::direction(){
}
\ No newline at end of file
...@@ -12,14 +12,23 @@ class Snake { ...@@ -12,14 +12,23 @@ class Snake {
int snekoScore(); int snekoScore();
void clrScreen(); void clrScreen();
char input; char input;
bool direction(char input);
private: private:
int x = 0, y = 0, i = 0, q = 0, score = 0,
int x = 0, y = 0, i = 0, q = 0, score = 0, h = (rand() % 14), o = (rand() % 14);
h = (rand() % 14), o = (rand() % 14); char grid[15][30];
int randChar = (rand() % 5);
char grid[15][30]; char whtSpace = ' ';
int randChar = (rand() % 5); vector<Body>parts();
char whtSpace = ' ';
}; };
class Body {
public:
private:
int x, y;
char piece;
};
#endif #endif
\ No newline at end of file
...@@ -48,8 +48,7 @@ int main() ...@@ -48,8 +48,7 @@ int main()
// synchronize threads: // synchronize threads:
first.join(); // pauses until first finishes first.join(); // pauses until first finishes
second.join(); second.join();
cout << " lkfnwefnwefnwdklfnd";
return 0; return 0;
} }
......
g++ *.cpp -o main.out -pthread -std=c++11 && ./main.out
\ No newline at end of file
Supports Markdown
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