void perdeu(){ clock_t tempo; float FPS = 15.0; tempo = clock(); explosao(xnave[e] - 40, ynave[e] - 30); blit(buffer, screen, 0,0,0,0,1280,720); //Limpa a tela clear_bitmap(buffer); //Limpa a tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(screen, inimigo[p], 15,yini); //Põe a nave na tela loser(); while (!key[KEY_ENTER]){ textout(screen, font, "Voce perdeu! Tecle 'Enter' para comecar novamente", 450,350, makecol(255,0,0 ) ); char txt[15]; sprintf(txt,"x + %d = %d", b, a); //Inicializa o texto char txt2[15]; sprintf(txt2,"Score = %d", score); //Inicializa o texto textout(screen,font,txt,5,5,makecol(255,0,0)); //Exibe o texto textout(screen,font,txt2,5,20,makecol(255,0,0)); //Exibe o texto if ( (double)(clock() - tempo) >= 1000/FPS ) { if (p == 10){ p++; } else { if (p == 11){ p++; } else { if (p == 12){ p++; } else { if (p == 13){ p = 10; } } } } blit(buffer, screen, 0,0,0,0,1280,720); //Limpa a tela clear_bitmap(buffer); //Limpa a tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(screen, inimigo[p], 15,yini); //Põe a nave na tela tempo = clock(); } } c = 0; yini = 40.0; score = 0; nivel = 1.0; back = 0; }
void main(void) { int tecla; int x,y,i,desce,dir,c,vida,velo,score,num; int inix[500],iniy[500]; char sco[20]; opengraph(); cleardevice(); x=320;y=240; vida=100; velo=1000; num=0; for(c=0;c<=500;c++) { inix[c]=0;iniy[c]=0; } do{ for(c=0;c<=num;c++) { if((inix[c]==0)&&(iniy[c]==0)) { do{ inix[c]=rand()%620; }while(inix[c]%15!=0); inix[c]=inix[c]+5; iniy[c]=5; inimigo(inix[c],iniy[c]); } } if(desce>=velo) { for(c=0;c<=num;c++) { apainimigo(inix[c],iniy[c]); iniy[c]=iniy[c]+10; dir=rand(); if((dir%4==0)&&(inix[c]+15<=610)) inix[c]=inix[c]+15; else if((dir%4==1)&&(inix[c]-15>=10)) inix[c]=inix[c]-15; inimigo(inix[c],iniy[c]); } desce=0; } for(c=0;c<=num;c++) { if((x==inix[c])&&(y>iniy[c])&&(tecla=='l')) { apainimigo(inix[c],iniy[c]); explosao(inix[c],iniy[c]); inix[c]=0;iniy[c]=0; score=score+1; if(score<200) velo=velo-5; setcolor(BLACK); settextstyle(0,0,2); outtextxy(5,460,"лллллллллллллллллл"); } if(((x==inix[c])&&(y-10==iniy[c]+15))||((x==inix[c])&&(y==iniy[c]))||((x==inix[c])&&(y-10==iniy[c]))||(iniy[c]>=480)) { apainimigo(inix[c],iniy[x]); apaganave(x,y); explosao(x,y); explosao(inix[c],iniy[c]); vida=0; cleardevice(); } } tecla=999; desce=desce+1; nave(x,y); setcolor(BLACK); line(0,477,640,477); hora(); if(score/20*10<100) { num=score*10/20; } setcolor(YELLOW); settextstyle(0,0,2); itoa(score,sco,10); outtextxy(5,460,sco); if(kbhit()) tecla=getch(); if((tecla=='a')&&(x>5)) { apaganave(x,y); x=x-15; } if((tecla=='d')&&(x<610)) { apaganave(x,y); x=x+15; } if((tecla=='w')&&(y>20)) { apaganave(x,y); y=y-15; } if((tecla=='s')&&(y<465)) { apaganave(x,y); y=y+15; } if(tecla=='l') { for(i=y-25;i>=1;i=i-1) { tiro(x,i); } nosound(); } if(vida==0) { cleardevice(); setcolor(YELLOW); settextstyle(0,0,2); outtextxy(210,240,"FIM DE JOGO"); itoa(score,sco,10); outtextxy(220,270,"SCORE:"); outtextxy(350,270,sco); delay(1000); getch(); } }while((tecla!=27)&&(vida!=0)); cleardevice(); }