SoloCodigo
Programación General => C/C++ => Mensaje iniciado por: 010011010 en Jueves 15 de Diciembre de 2005, 13:02
-
//librerias
#include <stdio.h>
#include <iostream.h>
#include <graphics.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
//globales y constantes
const char DERECHA=77;
const char IZQUIERDA=75;
int velball=3;
int x1=300,x2=350;
const int y1=478,y2=469;
int c1=320,c2=11;
int dirx=rand()%1,diry=1;
int vidas=5,puntos=0;
char vidasypuntos[25];
//prototipos
void instrucciones(void);
void raqueta(void);
void mover(void);
void iniciarmodografico(void);
void ball(void);
void mover_ball(void);
void recuadro(void);
void limpia(void);
void fin(void);
//main
void main()
{
textcolor(666);
clrscr();
instrucciones();
iniciarmodografico();
recuadro();
for(;;)
{
if(vidas<=0) {gotoxy(1,1);cout<<"Perdiste Loooooossssssseeeeerrr"<<endl<<"PUNTOS: "<<puntos;cin.get();closegraph();fin();}
do
{
if(puntos==1000)outtextxy(315,225,"NIVEL 2"),cin.get(),puntos+=100,velball++;
if(puntos==2000)outtextxy(315,225,"NIVEL 3"),cin.get(),puntos+=100,velball+=2;
if(puntos==3000)outtextxy(315,225,"NIVEL 4"),cin.get(),puntos+=100,velball+=2;
if(puntos==4000)outtextxy(315,225,"NIVEL 5"),cin.get(),puntos+=100,velball+=3;
limpia();
raqueta();
ball();
if(vidas<=0) {gotoxy(1,1);cout<<"Perdiste Loooooossssssseeeeerrr"<<endl<<"PUNTOS: "<<puntos;cin.ignore();cin.get();closegraph();fin();}
sprintf(vidasypuntos,"VIDAS=%d PUNTOS=%d",vidas,puntos),
outtextxy(1,1,vidasypuntos);
mover_ball();
}while(!kbhit());
while(kbhit())
{
mover();
};
}
}
//definicion de funciones
void iniciarmodografico(void)
{
int controlador=DETECT,mode,error;
initgraph(&controlador,&mode,"c:\\tdm");
error=graphresult();
if(error!=grOk)
{
cout<<"Error al inicializar modo grafico"<<endl;
cout<<grapherrormsg(error)<<endl;
getch();
exit(1);
}
}
void instrucciones(void)
{
cout<<"\t\t\t\tCONTROLES"<<endl;
cout<<"\t\t\t\tLEFT...izquierda"<<endl;
cout<<"\t\t\t\tRIGHT...derecha"<<endl;
cout<<"\t\t\t\tENTER...Pause"<<endl;
cout<<"\t\t\t\tx...Salir"<<endl;
cout<<"\t\t\t\t\"ENTER\" para continuar...";
cin.get();
sound(980),delay(350),
sound(150),delay(50),
sound(165),delay(100),
sound(700),delay(50),
sound(250),delay(150),
sound(1000),delay(400),
nosound();
}
void mover(void)
{
char move;
move=getch();
switch(move)
{
case DERECHA:x1+=15;
x2+=15;
if(x2>=639)
{
x2=637;
x1=x2-50;
}
break;
case IZQUIERDA:x1-=15;
x2-=15;
if(x1<=0)
{
x1=2;
x2=50;
}
break;
case 'x': closegraph();
fin();
break;
case 13:outtextxy(315,238,"PAUSE");
sound(500),delay(200),sound(750),delay(150),sound(1111),delay(100),nosound();
cin.get();
}
}
void raqueta()
{
setfillstyle(XHATCH_FILL,WHITE);
rectangle(x1,y1,x2,y2);
floodfill(x2-1,y2+1,WHITE);
}
void ball()
{
circle(c1,c2,3);
setcolor(RED);
circle(c1,c2,2);
setcolor(BLACK);
circle(c1,c2,1);
setcolor(YELLOW);
circle(c1,c2,0);
setcolor(WHITE);
}
void mover_ball()
{
delay(10);
putch(0);
if(dirx==1)
{
c1+=velball;
if(c1>=633){sound(600),delay(50),nosound();dirx=0;cleardevice();recuadro();}
}
else
{
c1-=velball;
if(c1<=5){sound(500),delay(50),nosound();dirx=1;cleardevice();recuadro();}
}
if(diry==1)
{
c2+=2;
if(c2>=466&&c2<476)
{
for(int i=x1;i<=x2;i++)
{
if(c1==i)
{
sound(300),delay(50),sound(150),delay(50),nosound();
puntos+=100;
diry=0;
cleardevice();
recuadro();
}
}
}
if(c2>=478)
{
sound(900),delay(150),sound(450),delay(200),sound(50),delay(250),nosound();
vidas-=1;
diry=1;
c1=rand()%639;
c2=15;
dirx=rand()%1;
cleardevice();
recuadro();
}
}
else
{
c2-=2;
if(c2<=11) {sound(350),delay(100),nosound();diry=1;cleardevice();recuadro();}
}
}
void limpia()
{
setfillstyle(SOLID_FILL,BLACK);
setcolor(BLACK);
bar(2,9,638,478);
setcolor(WHITE);
}
void recuadro()
{
setcolor(BLUE);
rectangle(1,8,639,479);
setcolor(WHITE);
}
void fin()
{
textcolor(666);
clrscr();
cin.get();
exit(0);
}
lo q no entiendo es q sale este error
graphics.h(19,52):Error directive: BGI graphics not supported under windows
me urge, por fis alguien me dice como o hacer q funcione
soy nuevo en esto de c
gracias
-
graphics.h(19,52):Error directive: BGI graphics not supported under windows
eHHH
eeee
estas usando un driver que no funciona para windows sino para DOS o versiones de wiondows 95,98 incluso ME.
-
si es C++
VE AL MENU Y EN OPTIONS->LINKER->LIBRARIES... Y SELECCIONAS LA OPCION GRAPHICS LIBRARY QUE QUEDE MARCADA CON UNA [X]
-
una pregunta:
¿Escribiste todo ese código sin saber que no te funciona graph.h?
yo creo que no :ph34r:
-
si es C++
VE AL MENU Y EN OPTIONS->LINKER->LIBRARIES... Y SELECCIONAS LA OPCION GRAPHICS LIBRARY QUE QUEDE MARCADA CON UNA [X]
A pesar de eso....La librería BGI tiene problemas en Windows....En algunas PC's va a funcionar.....y en otras no.... :( A mi me ha pasado :(
Mejor trata de utilizar Dev-C++ con Allegro B)
Saludos,
Blag :devil:
-
:o JAJAJAJAJA :lol:
oye ENKO creo que diste en el clavo :P
:lol: JAJAJAJA
:devil: