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

autosave

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