Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
Posted: Thu Dec 30, 2010 10:37 am Post subject: Snake the Game !
i spend the last week w/o internet. so i decided to create the game snake.
also i made 2 diferent game modes:
Tron Mode and Shit Mode,
here it goes:
Code:
#include <windows.h>
#include <iostream>
using namespace std;
void cs()
{
system("CLS");
}
int random(int min,int max)
{
int r=rand();
while(r>max || r<min)r=rand();
return r;
}
#define UP 1
#define LEFT 2
#define RIGHT 3
#define DOWN 4
int dificult;
int size = 10;
int p[32][32];
int snake_old_posX[1024];
int snake_old_posY[1024];
int headX=16;
int headY=16;
int tailX=16;
int tailY=16;
int points=0;
int direction=LEFT;
int pointX=6;
int pointY=6;
int grow;
int mode;
void print();
void move_snake();
void loose();
void check();
int main()
{
cs();
pointX=6;
pointY=6;
cout << "Snake - By EdCoFu\n";
cout << "Set the mode:\n\n1-Normal Mode;\n2-Shit Mode;\n3-Tron Mode;\n";
cin >> mode;
switch(mode)
{
case 1:
{grow=2;break;}
case 2:
{grow=-1;break;}
case 3:
{grow=10;break;}
}
while(true)
{
if(GetAsyncKeyState( VK_UP ) && direction!=DOWN)direction=UP;
if(GetAsyncKeyState( VK_DOWN )&& direction !=UP)direction=DOWN;
if(GetAsyncKeyState( VK_RIGHT ) && direction !=LEFT)direction=RIGHT;
if(GetAsyncKeyState( VK_LEFT ) && direction !=RIGHT)direction=LEFT;
move_snake();
check();
if(mode==2){if(size==3)size=10;};
print();
}
}
I did not look at the code, just played it. It does work, but you can't play. The window space, it lags, you can't move nicely. Recode it to something funnies:D
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum