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(void) { puts("Teste da lib compartilhada:"); puts(hora()); return 0; }
void correr(void){ const int CANTIBOTONES=4; ALLEGRO_TIMER *timer=NULL; ALLEGRO_EVENT_QUEUE *queue=NULL; ALLEGRO_BITMAP *main=NULL, *icons[CANTIBOTONES]; bool redraw=false; ALLEGRO_FONT *font=NULL; boton items[CANTIBOTONES]; void (*p2buttonf[CANTIBOTONES])(void); //create display, event queue and timer display = al_create_display(SCREEN_W, SCREEN_H); queue = al_create_event_queue(); timer = al_create_timer(1.0/FPS); //register events al_register_event_source(queue, al_get_display_event_source(display)); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_mouse_event_source()); al_register_event_source(queue, al_get_timer_event_source(timer)); //load bitmap main=al_load_bitmap("main.jpg"); al_draw_bitmap(main,0,0,0); //mainfondo switch((wallnumber=get_wallp())){ // carga de wallpaper por archivo de configuracion case 1:cambiarfondo1(); break; case 2:cambiarfondo2(); break; case 3:cambiarfondo3(); break; case 4:cambiarfondo4(); break; } exitmenu=false; //wallpaper icon icons[0]=al_load_bitmap("wallpaper-icon.png"); botones(&items[0], 30,OFFSETDOWN-BUTTONSIZE-25, BUTTONSIZE, BUTTONSIZE); p2buttonf[0]=correrwallp; //message icon icons[1]=al_load_bitmap("message-icon.png"); botones(&items[1], 30*2+BUTTONSIZE*1,OFFSETDOWN-BUTTONSIZE-25, BUTTONSIZE, BUTTONSIZE); p2buttonf[1]=corrercontactos; //music icon icons[2]=al_load_bitmap("musica.png"); botones(&items[2], 30*3+BUTTONSIZE*2,OFFSETDOWN-BUTTONSIZE-25, BUTTONSIZE, BUTTONSIZE); p2buttonf[2]=corrermusica; //fractal icon icons[3]=al_load_bitmap("fractal.png"); botones(&items[3], 30*4+BUTTONSIZE*3,OFFSETDOWN-BUTTONSIZE-25, BUTTONSIZE, BUTTONSIZE); p2buttonf[3]=correrfractal; //start timer and font al_start_timer(timer); font=al_load_font("digital.ttf",72,0); while(!doexit) // main loop { ALLEGRO_EVENT ev; al_wait_for_event(queue, &ev); // espero a timer, salida o keyboard if(ev.type == ALLEGRO_EVENT_TIMER) redraw = true; // si es el timer de refresco, redibujo salio(ev);// salio del celular= presionobotones(ev, items, p2buttonf,CANTIBOTONES); // presiono en los icons al_flush_event_queue(queue); if(redraw){ // si hay que redibujar drawfondo();// fondo drawbotones(items, icons,CANTIBOTONES);// dibujo icons hora(font);//horario redraw=false; al_flush_event_queue(queue); al_flip_display();//flipeo } } al_destroy_display(display); al_destroy_timer(timer); al_destroy_bitmap(main); al_destroy_bitmap(mainfondo); al_destroy_event_queue(queue); }