|
O ryl? Ya rly.
Senior Member
Posts: 1,530
Last Seen: 02-04-2010
Age: 20
From: Kingsport, TN
|
C ++ Cant get this to compile
Alright this is a game I found, I am doing a project in C++ right now and Im trying to use some functions from this game but they just wont compile in Dev c++ or borland. The main thing thats giving me problems is the sleep() function. Can someone help me fix this only using Dev C ++ or Borland? Thanks for any input.
Also all the background colors wont work in Dev but they dont show up as errors in Borland. Im clueless on what I should do.
Quote:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <iostream.h>
#include <iomanip.h>
void main()
{
int i, j, r, c, s, main;
char ans, opt;
menu:
textbackground(BLUE);
textcolor(YELLOW + BLINK);
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
do
{
gotoxy(24, 6);
printf("%c", 15);
gotoxy(33, 4);
printf("%c", 15);
gotoxy(40, 6);
printf("%c", 15);
gotoxy(50, 5);
printf("%c", 15);
gotoxy(60, 7);
printf("%c", 15);
gotoxy(70, 3);
printf("%c", 15);
gotoxy(18, 2);
printf("%c", 15);
gotoxy(7, 6);
printf("%c", 15);
gotoxy(18, 9);
printf("%c", 15);
gotoxy(63, 11);
printf("%c", 15);
gotoxy(20, 14);
printf("%c", 15);
gotoxy(57, 14);
printf("%c", 15);
//B
for(i = 8; i <= 12; i++)
{
gotoxy(26, i);
printf("%c", 173);
gotoxy(30, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 2)
{
gotoxy(27, i);
printf("%c%c%c", 173, 173, 173);
}
//O
for(i = 8; i <= 12; i++)
{
gotoxy(33, i);
printf("%c", 173);
gotoxy(37, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 4)
{
gotoxy(34, i);
printf("%c%c%c", 173, 173, 173);
}
//M
for(i = 8; i <= 12; i++)
{
gotoxy(40, i);
printf("%c", 173);
gotoxy(42, i);
printf("%c", 173);
gotoxy(44, i);
printf("%c", 173);
}
gotoxy(41, 8);
printf("%c", 173);
gotoxy(43, 8);
printf("%c", 173);
//B
for(i = 8; i <= 12; i++)
{
gotoxy(47, i);
printf("%c", 173);
gotoxy(51, i);
printf("%c", 173);
}
for(i = 8; i <= 12; i = i + 2)
{
gotoxy(48, i);
printf("%c%c%c", 173, 173, 173);
}
gotoxy(28, 15);
printf("T H E G A M E");
gotoxy(28, 19);
printf("1. New Game");
gotoxy(28, 20);
printf("2. Instructions.");
gotoxy(28, 21);
printf("3. Exit");
opt = getche();
if(opt == '1')
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
printf("ENTER THE SPEED WITH WHICH YOU WANT YOUR AEROPLANE TO MOVE ( > than 0 and < than 100): ");
scanf("%d", &s);
for(main = 1; main <= 3; main++)
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
gotoxy(37, 20);
printf("%c", 219);
gotoxy(1, 2);
printf(">%c--->", 173);
getch();
while(!kbhit())
{
for(i = 1; i < 75; i++)
{
if(kbhit())
{
getch();
nosound();
goto drop;
}
else
{
gotoxy(i, 2);
printf(">%c--->", 173);
r = 2;
c = i;
gotoxy(37, 20);
printf("%c", 219);
sound(100);
delay(100 - s);
if(i != 36 && !kbhit())
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
}
}
}
}
drop:
for(j = 3; j <= 20; j++)
{
gotoxy(c, r);
printf(">---->");
gotoxy(37, 20);
printf("%c", 219);
gotoxy(i, j);
printf("%c", 173);
delay(50);
sound(3000);
if(j != 15)
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
}
}
nosound();
if(i == 37)
{
gotoxy(34, 20);
printf("%cBOOM!!!%c", 15, 15);
gotoxy(29, 21);
//delay(100);
printf("%c %c %c", 15, 15, 15);
gotoxy(33, 19);
//delay(100);
printf("%c %c", 15, 15);
for(i = 0; i < 10; i++)
{
delay(30);
sound((i * 100) + 50);
delay(30);
nosound();
}
getch();
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
break;
}
else
{
gotoxy(i, 20);
clreol();
gotoxy(30, 15);
printf("SORRY, YOU MISSED THE TARGET");
sound(2000);
delay(100);
nosound();
}
getch();
}
}
}
while(opt == '1');
if(opt == '2')
{
clrscr();
textbackground(BLUE);
textcolor(YELLOW + BLINK);
printf("INSTRUCTIONS :-");
printf("\n\n\n");
printf("1. The objective of this game is to destroy the target by dropping a bomb on it.\n2. The player needs to drop the bomb from an aeroplane.\n\n3. Press any key to start flying the aeroplane.\n\n4. Then again press any key to drop the bomb when you are above the target.\n\n5. The target will look like this %c.", 219);
getch();
goto menu;
}
if(opt == '3')
{
}
else
{
goto menu;
}
}
|
|