Escolar Documentos
Profissional Documentos
Cultura Documentos
ACKNOWLEDGEMENT
First of all I bow my head to Almighty God who gave command to my hands to make the project a success. A formal statement of acknowledgement will hardly meet the ends of justice in matter of expression of my deep unsound sense of gratitude and obligations to my esteemed, Head of the Department of Engineering, Lovely professional university, Phagwara, for his sincere effort, keen interest and caring nature. Words at my command are insufficient to show my respect to MISS RITU my internal guide for inspiring and providing constructive ideas and rendering thought provoking discussions for the preparation of the project SNAKE GAME . And for providing all types of assistance. I bow my heads to my parents for their generous support, positive attitude, invaluable blessing, financial help and endless sacrifices for my better and bright future.I find it beyond my words to acknowledge the love, help and inspiration offered my friends. Finally, I would also like to thank all those who knowingly or unknowingly helped me all throughout my project.
CONTENTS
1.ACKNOWLEDGEMENT 2.INTRODUCTION 3.RULES 4.ALGORITHM 5.PURPOSE SYSTEM 6.THE LISTING 7.DISCRIPTION 8.HISTORY 9.TYPES 10.SOURCE CODE
Rules:
Don't run the snake into the wall, or his own tail: you die. Use your cursor keys: up, left, right, and down. Keyboard "P" may also be used for "Play" and "Pause" Eat the colored apples to gain points. Higher (and faster) play levels award more points. You will need to click your "Refresh" button to see new high scores.
ALGORITHM
STEP.1: you can download the executable to try out the game
without having to compile it if you wish. Download it is about 123k in length
STEP.7: You get a bonus when you complete the level of 1000, increasing by 1000 each level (e.g. complete level 5, you get a 5000 bonus).There is no concept of lives. STEP.8: Once you hit an obstacle, that's it, game over.Make sure you do not have the caps lock on, otherwise the keys will fail to respond.
THE LISTING
This is the C program for the game. it is reasonably well structured, but by no means perfect. Note that it uses library functions that are not available on all C compilers - it was designed using Borland C++ Builder / Turbo C. Also it uses a few C++ concepts not available in standard C - e.g. const for a constant (you would use #define in normal C). You may also have to change your compiler settings if you have them set to ANSI C to C++ instead - the for loops define a local instance of I as a loop counter, a concept to available in standard C.
History
The Snake variety of games originated with the arcade game Blockade, released by Gremlin in 1976[1] The first known microcomputer version of Snake, titled 'Worm', was programmed in 1978 by P. Trefonas (USA) on the TRS-80 computer, and published by CLOAD magazine the same year. This was followed shortly afterwards with versions from the same author for the PET and Apple II computers. A microcomputer port of Hustle was first written by P. Trefonas in 1979 and published by CLOAD magazine . This was later released by Milton Bradleyfor the TI99/4A in 1980.
Some better-known versions include the Neopets example, which is known as "Meerca Chase". Its revised version is known as "Meerca Chase II". A popular variant called nibbles was also included with MS-DOS for a period of time. An analog joystick-controlled variant of Snake, called Anaconda, was included as a hidden minigame in TimeSplitters 2. The version included on the Nokia N70 and other written by P. Trefonas in 1979 and published by CLOAD magazine . This was later released by Milton Bradleyfor the TI-99/4A in 1980. Some better-known versions include the Neopets example, which is known as "Meerca Chase". Its revised version is known as "Meerca Chase II". A popular variant called nibbles was also included with MS-DOS for a period of time. An analog joystick-controlled variant of Snake, called Anaconda, was included as a hidden minigame in TimeSplitters 2. The version included on the Nokia N70 and other later model Nokia phones is a 3D version, with level goals. The Nokia version has a snake in it as well
Snake - The original, for monochrome phones. Graphics consisted of black squares and it had 4 directions. An example of a phone with it installed is the Nokia 5110. Snake II - Included on monochrome phones. Snake improved to a snake pattern, introduction of bonus bugs etc... An example of a phone with it installed is the Nokia 3310. Snake Xenzia - Included on present-day monochrome phones (and some cheaper colour phones, such as the Nokia 1600). An example of a phone with it installed is the Nokia 1112
Snake EX - Included on colour phones. Graphics improved to SNES quality. It supports multiplayer through Bluetooth and Infra-Red. An example of a phone with it installed is the Nokia 6260. Snake EX2 - This is included in several Series40 handsets by Nokia. Snakes - A 3D version. This game was designed for the N-Gage, developed by IOMO(published by Nokia). It featured multiplayer through Bluetooth. Graphics improved to basic PlayStation quality. Introduction of hex levels, etc. Later Nokia started giving this game pre-installed(without multiplayer feature) in its Nseries phones like N70, N73, N80, etc.
win(); int m[500],n[500],con=20,TEMP; clock_t start,stop; void main(void) { int gd=DETECT,gm,ch,maxx,maxy,x=13,y=14,p,q,spd=100; int a=0,i=0,j,t,temp;
initgraph(&gd,&gm,"..\bgi"setcolor(WHITE);
settextstyle(3,0,6); outtextxy(200,2," SNAKE 2 BY RAJESH "); settextstyle(6,0,2); outtextxy(20,80," Use Arrow Keys To Direct The Snake "); outtextxy(20,140," Avoid The Head Of Snake Not To Hit Any Part Of Snake"); outtextxy(20,160," Pick The Beats Untill You Win The Game "); outtextxy(20,200," Press 'Esc' Anytime To Exit ") ;outtextxy(20,220," Press Any Key To Continue "); outtextxy(20,220," DONT FORGET TO GIVE U R VALUABLE OPINION ");
ch=getch(); if(ch==27) exit(0); cleardevice(); maxx=getmaxx(); maxy=getmaxy(); randomize(); p=random(maxx); temp=p%13; p=p-temp; q=random(maxy); temp=q%14; q=q-temp; start=clock(); while(1) { setcolor(WHITE); setfillstyle(SOLID_FILL,con+5);
circle(p,q,5); floodfill(p,q,WHITE); if( kbhit() ) { ch=getch(); if(ch==0) ch=getch(); if(ch==72&& a!=2)a=1; if(ch==80&& a!=1)a=2; if(ch==75&& a!=4)a=3; if(ch==77&& a!=3) a=4; } else { if(ch==27) break; } if(i<20) { m[i]=x;
n[i]=y; i++; } if(i>=20) { for(j=con;j>=0;j--) { m[1+j]=m[j]; n[1+j]=n[j]; } m[0]=x; n[0]=y; setcolor(WHITE); setfillstyle(SOLID_FILL,con); circle(m[0],n[0],8); floodfill(m[0],n[0],WHITE); setcolor(WHITE); for(j=1;j<con;j++)
{ setfillstyle(SOLID_FILL,con+j%3); circle(m[j],n[j],5); floodfill(m[j],n[j],WHITE); } delay(spd); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); circle(m[0],n[0],8); floodfill(m[0],n[0],BLACK); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); circle(m[j],n[j],5); floodfill(m[j],n[j],BLACK); } stop=clock(); t=(stop-start)/CLK_TCK; //printf(" TIME %d sec ",t);
//printf("SCORE %d",con-5); check(); if(x==p&&y==q) { con=con+5; if(spd>=5) spd=spd-5; else spd=5; if(con>490) win(); p=random(maxx); temp=p%13; p=p-temp; q=random(maxy); temp=q%14; q=q-temp; }
if(a==1) y = y-14; if(y<0) { temp=maxy%14; y=maxy-temp; } if(a==2) y = y+14; if(y>maxy) y=0; if(a==3) x = x-13; if(x<0) { temp=maxx%13; x=maxx-temp; }
else continue;
} end() { int j,i; setcolor(WHITE); for(i=0;i<5;i++) { delay(500); cleardevice(); delay(500); for(j=0;j<=con;j++) { setfillstyle(SOLID_FILL,RED); circle(m[j],n[j],5); floodfill(m[j],n[j],WHITE);
setfillstyle(SOLID_FILL,con); circle(m[j],n[j],5); floodfill(m[j],n[j],WHITE); } delay(500); cleardevice(); delay(500); } settextstyle(3,0,4); outtextxy(210,320," YOU WIN "); getch(); exit(0); }