fl3kaucicpp/Snakes/snakes.cpp

52 lines
737 B
C++
Raw Normal View History

2024-05-15 14:29:11 +00:00
#include <iostream>
#include <cstdlib>
using namespace std;
const int width = 80;
const int height = 20;
bool gameover;
const int snakeX = width/2;
const int snakeY = height/2;
void start(){
gameover=false;
}
void draw(){
//Change "clear" to "cls" if compiling for Windows
system("clear");
for(int i=0; i<width; i++){
cout << "#";
}
cout << endl;
for(int i=0; i<height; i++){
for(int j=0; j<=width; j++){
if(j==0 || j==width){
cout<<"#";
}
if(j==snakeX && i==snakeY)
cout<<"o";
else
cout<<" ";
}cout<<endl;
}
for(int i=0; i<width; i++){
cout << "#";
}
cout<<endl;
}
int main(){
while(!gameover)
draw();
return 0;
}