THE HIT GAME…..in c


/*BS ->26/5/12
its just a simple game u have to hit target,which will change its position in randomly.
there’r 2 gamemode 1.UP-DOWN–> target will move in row until u hits it accurately,then it will step down
afther reaching towrds ur gun it wil step up as u hit it accurately.
2.RANDOM->target will place at random at delay of 200 ms hit it to get scored….
comment here to give suggestions plz……
its just 2 hours coded and case 3 is not defined….
i’ll upload link to directly download .c file.
*/

#include “graphics.h”
#include “stdio.h”
#include “dos.h”
#include “conio.h”
int xm1,ym1,xm2,ym2,level,red;
int maxx,maxy,left,top=20;
union REGS i,o;
init_mouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
show_mouse()
{
i.x.ax=1;
int86(0x33,&i,&o);
}

hide_mouse()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
get_mouse_pos(int *x,int *y,int *button)
{
i.x.ax=3;
int86(0x33,&i,&o);
*x=o.x.cx;
*y=o.x.dx;
*button=o.x.bx&1;
}

void main()
{
int i,j,k,score=0,incr,factor,missed=0;
int gdriver = DETECT, gmode, errorcode,button,x1,y1,x2,y2,x;
initgraph(&gdriver, &gmode, “..\\bgi”);
// setviewport(0,0,maxx,maxy,1);
score_board(score,missed);
init_mouse();
show_mouse();
maxx=getmaxx();
maxy=getmaxy();
//GUN();
//TARGET();
//select_level();
/*
while(!kbhit())
{
button=0;
get_mouse_pos(&x1,&y1,&button);
if(button==1)
{
if(x1>xm1&&x1219)
{
if(y1<249)
{ level=0; //training
goto levelis;
}
else if(y1<279)
level=1; //beginer goto levelis;
}
else if(y1maxx/2-50&&x1maxy-50&&y1left&&x1top&&y1<top+20)
{
if(score%10==0)
{
factor=score/10;
if(factor%2==0)
incr=1;
else incr=0;
}
if(incr==1||scoreleft&&x1top&&y110)
printf(“\ncongrats u have scored above 10”);
getch();
}
GUN()
{
int i,k;
rectangle(maxx/2-5,maxy-20,maxx/2+5,maxy-5);
setfillstyle(1,BLUE);
bar(maxx/2-5,maxy-20,maxx/2+5,maxy-5);
setfillstyle(1,RED);
bar(maxx/2-3,maxy-40,maxx/2+3,maxy-20);
if(level==1){
setfillstyle(1,YELLOW);
bar(0,maxy-100,maxx,maxy-97);
//line(0,maxy-100,maxx,maxy-100);
} }
TARGET()
{

srand(time(0));
left=rand()%1000+18;
if(level==1||level==2)
{
do{
top=rand()%500+18;
} while(top>maxy-130);
}
if(left<maxx-25)
{
setfillstyle(1,BLUE);
rectangle(left,top,left+20,top+30);
bar(left,top,left+20,top+30);
}
}
fire(int x,int y)
{
int i;
//setviewport(0,70,maxx,maxy-70,1);
setfillstyle(1,WHITE);
bar(x-5,y-5,x+5,y+5);
setcolor(WHITE);
line(maxx/2,maxy-10,x,y);
for(i=0;i<3;i++)
line(maxx/2+i,maxy-10+i,x+i,y+i);
delay(200);
}
aim(int x,int y)
{
clearviewport();
setcolor(RED);
//circle(x,y,5);
//setfillstyle(1,BLUE);
//fillellipse(x,y,5,5);
line(x-3,y,x+3,y);
line(x,y-3,x,y+3);
}
int select_level()
{
int i;
xm1=maxx/2-50;
ym1=maxy/2-50;
xm2=maxx/2+50;
ym2=maxy/2+50;
rectangle(xm1,ym1,xm2,ym2);
for(i=1;i in this mode target will come closer to u step by step “);
printf(“\n if u hit the target accurately target will step ahead “);
printf(“\n it will go back step wise after coming closer to u “);
printf(“\n ENTER 1->”);
printf(“\n in this mode target will mode random places on screen \n hit it accurately and earn points”);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s