| Rattle Snake In C |
|
|
|
| Written by Ravi maggon | ||||||
| Saturday, 09 May 2009 15:34 | ||||||
Page 1 of 4 #include<graphics.h>#include<string.h> #include<dos.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> #include<iostream.h> int main() { int gdriver = DETECT, gmode, errorcode; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } char cha=16,chain[20]; int crx[20]={19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0},cry[20]={10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10}; int l=2,n,p,maxx,maxy,x,y,rx,ry,z,fposx,fposy; char ch,arrow=30; maxx=getmaxx(); maxy=getmaxy(); /* make game screen */ settextstyle(2,0,5); setcolor(MAGENTA); setfillstyle(SOLID_FILL,BLACK); bar(0,0,maxx,maxy); floodfill(10,20,BLACK); setcolor(MAGENTA); rectangle(0,20,maxx,maxy); rectangle(450,20,maxx,maxy); setcolor(MAGENTA); setfillstyle(SOLID_FILL,GREEN); bar(2,22,8,maxy-2); bar(2,22,maxx-190,31); bar(440,22,maxx-190,477); bar(2,467,maxx-190,477); floodfill(10,20,BLACK); setcolor(MAGENTA); rectangle(0,20,maxx,maxy); rectangle(450,20,maxx,maxy); setfillstyle(SOLID_FILL,MAGENTA); bar(452,22,maxx-2,100); setcolor(BLACK); outtextxy(500,55,"Rattle"); delay(200); outtextxy(557,55,"Snake"); setcolor(WHITE); rectangle(452,110,maxx-2,270); delay(200); setcolor(YELLOW); outtextxy(500,115,"Instructions"); delay(200); setcolor(RED); settextstyle(3,0,2); outtextxy(480,135,"Up"); delay(200); setcolor(RED); settextstyle(3,0,2); gotoxy(75,10); cout<<arrow; delay(200); setcolor(RED); settextstyle(3,0,2); outtextxy(480,165,"Down"); delay(200); setcolor(RED); arrow=31; gotoxy(75,12); cout<<arrow; |
||||||
| Last Updated on Sunday, 31 May 2009 13:38 |