//librerias#include <stdio.h>#include <iostream.h>#include <graphics.h>#include <conio.h>#include <stdlib.h>#include <dos.h>//globales y constantesconst 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];//prototiposvoid 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);//mainvoid 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 funcionesvoid 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);}
graphics.h(19,52):Error directive: BGI graphics not supported under windows
si es C++VE AL MENU Y EN OPTIONS->LINKER->LIBRARIES... Y SELECCIONAS LA OPCION GRAPHICS LIBRARY QUE QUEDE MARCADA CON UNA [X]