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(); }
int main() { initscr(); start_color(); init_pair(1, COLOR_GREEN, COLOR_BLACK); init_pair(2, COLOR_BLUE, COLOR_BLACK); init_pair(3, COLOR_RED, COLOR_BLACK); init_pair(4, COLOR_YELLOW, COLOR_BLACK); init_pair(5, COLOR_WHITE, COLOR_BLACK); int x =37; int y =22; int t; curs_set(0); keypad(stdscr, TRUE); noecho(); //attron(COLOR_PAIR(1)); //attroff(COLOR_PAIR(1)); while (1) { attron(COLOR_PAIR(5)); nave(x,y); attroff(COLOR_PAIR(5)); attron(COLOR_PAIR(1)); limites(); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(2)); mon1(22,4); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); mon2(12,4); attroff(COLOR_PAIR(3)); attron(COLOR_PAIR(4)); mon3(50,4); attroff(COLOR_PAIR(4)); attron(COLOR_PAIR(1)); mvprintw( 2,8,"puntaje:0 "); attroff(COLOR_PAIR(1)); t = getch(); switch(t){ case KEY_DOWN: (y<25) ? y++: 0; clear(); break; case KEY_UP: (y>4) ? y--: 0; clear(); break; case KEY_LEFT: (x>3) ? x--: 0; clear(); break; case KEY_RIGHT: (x<70) ? x++: 0; clear(); break; } refresh(); } endwin(); return 0; }