Work in progress
This commit is contained in:
parent
bd8f0464d0
commit
dcbc403a8b
BIN
Snakes/snakes
Executable file
BIN
Snakes/snakes
Executable file
Binary file not shown.
52
Snakes/snakes.cpp
Normal file
52
Snakes/snakes.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#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;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user