From cbf987617afb09d2d75c03f9ee7e1a81da80ca45 Mon Sep 17 00:00:00 2001 From: Nelson Phillips Date: Mon, 11 Mar 2019 19:30:58 +0000 Subject: [PATCH] autosave --- Testings/Snake/Snake.cpp | 23 +++++++++++++++-------- Testings/Snake/Snake.h | 1 + Testings/Snake/SnakeTest.cpp | 1 - 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Testings/Snake/Snake.cpp b/Testings/Snake/Snake.cpp index 314439f..681c7e9 100644 --- a/Testings/Snake/Snake.cpp +++ b/Testings/Snake/Snake.cpp @@ -5,8 +5,7 @@ #include "Snake.h" using namespace std; - - bool hi = 0; + Snake bdy; vector parts; @@ -116,14 +115,25 @@ if (grid [x][y] == grid[h][o] ){ int Snake::getY(){ return y; } - + int Snake::getLeng(){ + return length; + } + void Snake::lengthed(){ + length++; + } void Snake::newBody(){ - Body segment (x - length, y); - cout << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl << x << endl; + Body segment (x,y);//parts[bdy.getLeng()].getX(), parts[bdy.getLeng()].getY() parts.push_back(segment); } + + + + + + + void Body::changeX(bool updown){ if (updown) x--; @@ -151,7 +161,4 @@ if (grid [x][y] == grid[h][o] ){ return y; } - void Snake::lengthed(){ - length++; - } \ No newline at end of file diff --git a/Testings/Snake/Snake.h b/Testings/Snake/Snake.h index ec60fde..a7ab872 100644 --- a/Testings/Snake/Snake.h +++ b/Testings/Snake/Snake.h @@ -17,6 +17,7 @@ class Snake { int getY(); void newBody(); void lengthed(); + int getLeng(); private: int x = 5, y = 5, i = 0, q = 0, score = 0, h = (rand() % 14), o = (rand() % 14); diff --git a/Testings/Snake/SnakeTest.cpp b/Testings/Snake/SnakeTest.cpp index e2b8bf1..54088dc 100644 --- a/Testings/Snake/SnakeTest.cpp +++ b/Testings/Snake/SnakeTest.cpp @@ -43,7 +43,6 @@ void charCall() { } int main() { - BrdSet.newBody(); thread first (charCall); // spawn new thread that calls input() thread second (snakePrint); // spawn new thread that calls snakePrint(0) -- GitLab