Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

BALLO A C++ GAME

Ballo is a c++ game i developed for my school project.I am sorry for not replying for any of the comments in previous posts.I had an entrance exam i was preparing for and could not spend too much time online.You can always email me at davichristiek@gmail.com.

You can download it form here
https://drive.google.com/file/d/0B3kz1y1YuVuJVUZ2Tk1tb3FrMFU/view?usp=sharing

`#include<iostream.h>

include<graphics.h>

include<conio.h>

include<stdlib.h>

include<dos.h>

void ballo()
{
int score=0;
char scor[10];
char key;
int speed=1,life=3,movementspeed=5;
randomize();
clrscr();
unsigned int size;
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\tc\BGi\");
setbkcolor(WHITE);
setfillstyle(1,BLUE);
bar(200,200,500,300);
settextstyle(3,0,6);
outtextxy(210,200,"C");
delay(500);
outtextxy(250,200,"O");
delay(500);
outtextxy(280,200,"N");
delay(500);
outtextxy(310,200,"N");
delay(500);
outtextxy(340,200,"E");
delay(500);
outtextxy(370,200,"C");
delay(500);
outtextxy(400,200,"T");
delay(500);
outtextxy(430,200,"O");
delay(1000);
settextstyle(5,0,4);
setcolor(YELLOW);
outtextxy(240,240,"Innovations");
setcolor(RED);
rectangle(200,200,500,300);
getch();
cleardevice();

//HEART FOR LIFE
setbkcolor(LIGHTBLUE);
cout<<(char)3;
void *heart;
size=imagesize(0,0,12,12);
heart=malloc(size);
getimage(0,0,12,12,heart);
cleardevice();

//ENEMY
setfillstyle(1,RED);
setcolor(YELLOW);
line(2.5,0,2.5,40);
bar(0,0,5,40);
struct
{
void *enemy;
int x,y;
}enemy[3];
size=imagesize(0,0,5,40);
for(int i=0;i<3;i++)
{
enemy[i].enemy=malloc(size);
getimage(0,0,10,40,enemy[i].enemy);
}

//now for PLAYER
cleardevice();
setbkcolor(LIGHTBLUE);
setcolor(YELLOW);
circle(20,20,20);
setfillstyle(1,YELLOW);
floodfill(20,20,YELLOW);
struct
{
void *player;
int x,y;
}player;
size=imagesize(0,0,40,40);
player.player=malloc(size);
getimage(0,0,40,40,player.player);
cleardevice();

//Food
struct
{
void *cake;
int x,y;
}cake;
{
int T[6]={0,0,0,30,30,30};
setfillstyle(2,YELLOW);
fillpoly(3,T);
}
size=imagesize(0,0,30,30);
cake.cake=malloc(size);
getimage(0,0,30,30,cake.cake);
cleardevice();

//The Screen

setbkcolor(RED);
setcolor(YELLOW);
settextstyle(6,0,6);
outtextxy(200,20,"INSTRUCTIONS");
settextstyle(1,0,3);
outtextxy(20,100,"1.Don't get hit by the lasers");
outtextxy(20,200,"2.Eat as much cakes as you can");
outtextxy(20,300,"3.Press space to exit.....AND HAVE FUN");
outtextxy(20,400,"4.Use W,A,S,D to move");
outtextxy(100,450,"PRESS ANY KEY TO PLAY");
getche();
cleardevice();
setbkcolor(LIGHTBLUE);
setfillstyle(9,YELLOW);
setcolor(YELLOW);
line(500,0,500,480);
floodfill(550,20,YELLOW);
setcolor(GREEN);
line(0,50,640,50);
setfillstyle(9,GREEN);
floodfill(25,25,GREEN);
settextstyle(3,0,6);
setcolor(RED);
outtextxy(200,-2,"BALL-O");
setcolor(RED);
settextstyle(3,0,4);
outtextxy(520,60,"Life");
setfillstyle(1,YELLOW);
bar(520,100,580,110);
setcolor(RED);
outtextxy(520,150,"SCORE");
setfillstyle(1,YELLOW);
bar(520,200,600,250);
settextstyle(3,0,2);
outtextxy(520,380,"CREATED BY");
setcolor(YELLOW);
bar(520,420,600,450);
setcolor(RED);
settextstyle(4,0,4);
outtextxy(520,420,"CONNECTO");

//beauty
for(i=0;i<5000;i++)
{
putpixel(random(500),random(480)+50,i%16);
delay(1);
}

//The initial coordinates
cake.x=random(420);
cake.y=random(410)+50;
player.x=250;
player.y=230;
for(i=0;i<3;i++)
{
enemy[i].x=random(480);
enemy[i].y=80;
for(int j=0;j<i;j++)
{
if(abs(enemy[i].x-enemy[j].x)<50)
i--;
}
}
//THE Mechanism
key='o';
int temp=520;
putimage(cake.x,cake.y,cake.cake,XOR_PUT);
while(key!=' ')
{
//lives
temp=520;

for(i=0;i<life;i++)
{
putimage(temp,100,heart,COPY_PUT);
temp+=20;
}
//score;
settextstyle(4,0,4);
itoa(score,scor,10);
setcolor(RED);
outtextxy(530,200,scor);
putimage(player.x,player.y,player.player,OR_PUT);
for(i=0;i<3;i++)
putimage(enemy[i].x,enemy[i].y,enemy[i].enemy,XOR_PUT);
// bad
int loopcanceller=0;
for(i=0;i<3;i++)
{
if(abs(enemy[i].x-player.x)<20&&abs(enemy[i].y-player.y)<40)
{
if(life==0)
{
setcolor(RED);
settextstyle(4,0,6);
outtextxy(250,200,"Game Over");
delay(2000);
cleardevice();
setbkcolor(YELLOW);
settextstyle(5,0,6);
outtextxy(100,40,"Thank you for playing");
outtextxy(100,100,"You have scored:");
outtextxy(100,175,scor);
outtextxy(100,250,"Press space to exit....");
char ch='w';
while(ch!=' ')
ch=getch();

   return;
  }
setcolor(RED);
settextstyle(3,0,2);
if(life!=1)
 outtextxy(520,295,"LIFE LOST");
else
 outtextxy(520,295,"LAST LIFE");
setfillstyle(1,YELLOW);
bar(520,100,580,110);
delay(1000);
setcolor(LIGHTBLUE);
if(life!=1)
 outtextxy(520,295,"LIFE LOST");
else
 outtextxy(520,295,"LAST LIFE");
life--;
loopcanceller=1;

}
}
if(loopcanceller==1)
{
//DELETING
putimage(player.x,player.y,player.player,XOR_PUT);
player.x=250;
player.y=220;
loopcanceller=0;
i--;
for(int j=0;j<3;j++)
putimage(enemy[j].x,enemy[j].y,enemy[j].enemy,XOR_PUT);
enemy[i].x=random(480);
enemy[i].y=80;
continue;
}
//good
setfillstyle(1,LIGHTBLUE);
bar(520,280,640,320);
setfillstyle(1,YELLOW);
if(abs(player.x-cake.x)<30&&abs(player.y-cake.y)<30)
{
settextstyle(4,0,4);
setcolor(LIGHTBLUE);
outtextxy(530,200,scor);
score+=10;
putimage(cake.x,cake.y,cake.cake,XOR_PUT);
cake.x=random(420);
cake.y=random(400)+50;
putimage(cake.x,cake.y,cake.cake,OR_PUT);
setcolor(YELLOW);
bar(520,200,600,250);
}
//player movement
if(kbhit())
{
key=getche();
putimage(player.x,player.y,player.player,XOR_PUT);//DELETING
switch(key)
{
case 'a':
case 'A':
if(player.x>10);
{
player.x-=movementspeed;
break;
}

case 'd':
case 'D':
if(player.x<460)
 {player.x+=movementspeed;
  break;
 }

case 'w':
case 'W':
if(player.y>80)
 {
  player.y-=movementspeed;
  break;
 }

case 's':
case 'S':
if(player.y<450)
 player.y+=movementspeed;
break;

}
}
//Enemy movement
for(i=0;i<3;i++)
{
putimage(enemy[i].x,enemy[i].y,enemy[i].enemy,XOR_PUT);//DELETING
enemy[i].y+=movementspeed0.15(random(3)+1);
if(enemy[i].y>460)
{
enemy[i].y=0;
enemy[i].x=random(420);
}
}
delay(speed);
}
}
void main()
{
ballo();
}`

Tagged:
Sign In or Register to comment.