#include <iostream>
#include <conio.h>
#include <windows.h>
using namespace std;
bool gameOver;
int width=20, height=20;
int x,y, fruitX, fruitY, score;
int tailX[100], tailY[100], nTail;
enum eDir { STOP=0, LEFT, RIGHT, UP, DOWN };
eDir dir;
void Setup() {
gameOver = false;
dir = STOP;
x = width/2;
y = height/2;
fruitX = rand() % width;
fruitY = rand() % height;
score = 0;
}
void Draw() {
system("cls");
for(int i=0; i<width+2; i++) cout << "#";
cout << endl;
}
void Input() {
if(_kbhit()) {
switch(_getch()) {
case 'a': dir = LEFT; break;
case 'd': dir = RIGHT; break;
case 'w': dir = UP; break;
case 's': dir = DOWN; break;
case 'x': gameOver = true; break;
}
}
}
void Logic() {
int prevX = tailX[0];
int prevY = tailY[0];
int prev2X, prev2Y;
tailX[0] = x;
tailY[0] = y;
}
int main() {
Setup();
while(!gameOver) {
Draw();
Input();
Logic();
Sleep(10);
}
return 0;
}