//put mouse.h in bin directory or change the path respectively
#include "c:\\turboc3\\bin\\mouse.h"#include <stdlib.h>
#include<math.h>
#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
void maingame();
void gameborder();
void welcome();
void inter();
void main()
{
int gd=0,gm=0,cnt=0;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
char ch[50]= "Welcome to World of Game Zone by ++ C ";
char str[50][3];
int l;
border(6);
l = strlen(ch);
// cout << l;
int i;
for(i=0;i<l;i++)
{
str[i][0] = ch[i];
str[i][1] = '\0';
}
float x,y;
int x1,y1,b,l1;
i=0;
welcome();
char c[] = "CONTROL D SHAPE WITH MOUSE & HAve FUN ";
char str1[30][2];
l1 = strlen(c);
for(i=0;i<l1;i++)
{
str1[i][0] = c[i];
str1[i][1] = '\0';
}
cleardevice();
if(1)
{
i=l1;
int temp;
x1 = 300;
y1 = 450;
border(6);
for(float k=0;k<180 ;k+=4.5)
{
setcolor(random(15)+1);
x = 315+ x1*cos(k/180 * 3.14);
y = y1*sin(k/180 * 3.14);
i--;
settextstyle(0,0,2);
outtextxy(x,y,str1[i]);
delay(50);
}
delay(100);
border(6);
}
getch();
while(1)
{
i=l;
cnt++;
int temp;
if(b==0)
show_ptr(&temp,&temp,&b);
else
{
show_ptr(&x1,&y1,&b);
}
for(float k=0;k<180 ;k+=4.5)
{
setcolor(random(15));
x = 315+ x1*cos(k/180 * 3.14);
y = y1*sin(k/180 * 3.14);
i--;
settextstyle(0,0,2);
outtextxy(x,y,str[i]);
}
delay(100);
cleardevice();
border(6);
if(x1>=300 && y1>=450)
if(cnt>=40)
break;
}
flushall();
inter();
getch();
cleardevice();
outtextxy(10,10,"5 CHARACTERS MISSING = GAME OVER");
setcolor(13);
outtextxy(10,60,"ALL D BEST");
getch();
cleardevice();
maingame();
}
void maingame()
{
int gd=0,gm=0,i,x,y,xt,k=1,s=1,cl;
char ch[100][2],c;
for(i=0;i<26;i++)
{
ch[i][0] =i + 65;
ch[i][1] = '\0';
}
gameborder();
x=10;
y=12;
for(i=0;i<26;i++,x+=24)
{
settextstyle(0,0,2);
cl = random(15);
if(cl==0)
cl++;
setcolor(cl);
outtextxy(x,12,ch[i]);
}
S:
gameborder();
xt = random(26);
x = 10 + (24 * xt);
for(y=12,i=0;y<470;y+=15,i++)
{
if(i%2==0)
{
cl = random(15);
if(cl==0);
cl++;
setcolor(cl);
settextstyle(0,0,2);
outtextxy(x,y,ch[xt]);
delay(50-(s/2));
setcolor(0);
outtextxy(x,y,ch[xt]);
gameborder();
}
else
{
cl = random(15);
if(cl==0);
cl++;
setcolor(cl);
settextstyle(0,0,2);
outtextxy(x+5,y,ch[xt]);
delay(50-(s/2));
setcolor(0);
outtextxy(x+5,y,ch[xt]);
gameborder();
}
if(kbhit())
{
c = getche();
if(c == ch[xt][0])
{
settextstyle(0,0,2);
cl = random(15);
if(cl==0)
cl++;
settextstyle(0,0,7);
setcolor(cl);
outtextxy(320,240,ch[xt]);
delay(500);
setcolor(0);
outtextxy(320,240,ch[xt]);
setcolor(cl);
settextstyle(0,0,2);
circle(260,240,120);
outtextxy(150,240,"Scored a point");
delay(500);
setcolor(0);
outtextxy(150,240,"Scored a point");
circle(260,240,120);
s+=8;
gameborder();
goto S;
}
if(c == 'p')
goto Y;
}
settextstyle(0,0,2);
if(y>=410)
{
cl = random(15);
if(cl==0)
cl++;
setcolor(cl);
circle(260,240,120);
outtextxy(150,240,"Missed a point");
delay(500);
setcolor(0);
circle(260,240,120);
outtextxy(150,240,"Missed a point");
gameborder();
k++;
if(k>5)
goto Y;
else
goto S;
}
delay(50);
}
Y:
cleardevice();
char chh[40];
strcpy(chh,"YOUR SCORE = ");
strcat(chh,itoa(s,chh,10));
settextstyle(0,0,2);
outtextxy(10,20,"YOUR SCORE = ");
gameborder();
outtextxy(210,20,chh);
getch();
}
void gameborder() //border formation
{
int x,y,cl;
char ch[10]="CSPIT ";
setcolor(1);
rectangle(0,0,639,479);
for(x=2,y=2;x<639;x+=40)
{
settextstyle(0,0,1);
cl = random(15);
if(cl == 0)
cl++;
setcolor(cl);
outtextxy(x,y,ch);
outtextxy(x,y+470,ch);
}
for(x=10,y=1;y<480;y+=40)
{
settextstyle(0,1,1);
cl = random(15);
if(cl == 0)
cl++;
setcolor(cl);
outtextxy(x,y,ch);
outtextxy(x+630,y,ch);
}
setcolor(random(15));
rectangle(10,10,630,470);
}
void inter()
{
setcolor(random(15)+1);
outtextxy(10,10,"HERE");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(130,50,"IS");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(270,90,"THE");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(420,130,"SIMPLE");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(560,180,"GAME.");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(10,250,"CAPTURE");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(130,310,"FALLING");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(270,360,"CHARACTER");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(420,410,"OVER");
delay(150);
setcolor(random(15)+1);
delay(150);
outtextxy(530,450,"SCREEN.");
}
void welcome()
{
settextstyle(0,0,2);
setcolor(9);
outtextxy(10,40,"WELCOME TO MY SIMPLE GAME-WORLD BY C++ GRAPHICS");
setcolor(12);
setcolor(9);
outtextxy(10,270,"Press Any Key to Continue..");
getch();
}
No comments:
Post a Comment