Jump to content

Search the Community

Showing results for tags 'allegro5'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Q&A Desenvolvimento
    • Perguntas e respostas rápidas
  • Desenvolvimento e Banco de Dados
    • HTML e CSS
    • Java
    • Javascript
    • .NET
    • PHP
    • Python
    • Ruby
    • Mobile
    • Ambientes de Desenvolvimento
    • Arquitetura e Métodos Ágeis
    • Banco de Dados
    • DevOps
    • Desenvolvimento de Games
    • E-Commerce e Pagamentos Online
    • SEO e Otimizações
    • WordPress
    • Algoritmos & Outras Tecnologias
  • Design e Produto
    • Fotografia
    • Photoshop
    • Design de interfaces e UX
    • Edição/Produção de Vídeos
    • Marketing Online
    • Desenho, Ilustração e 3D
  • Entretenimento e uso pessoal
    • Geral
    • Segurança & Malwares
    • Gadgets e wearable
    • Softwares e Apps
    • Entretenimento

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Google+


Hangouts


Skype


Twitter


deviantART


Github


Flickr


LinkedIn


Pinterest


Facebook


Site Pessoal


Localização


Interesses

Found 2 results

  1. Mario Viero

    Adicionar imagens que percorram a tela

    olá, gostaria de uma ajuda para saber como adicionar imagens que "fiquem descendo a tela" constantemente de tempo em tempo com o objetivo de criar obstáculos com elas. #include <stdio.h> #include <allegro5/allegro.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_acodec.h> #include <allegro5/allegro_audio.h> const float FPS = 60; const int SCREEN_W = 640; const int SCREEN_H = 480; const int AVIAO_SIZE = 80; enum MYKEYS { KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_SPACE }; int main(int argc, char **argv) { ALLEGRO_DISPLAY *display = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; ALLEGRO_BITMAP *aviao_principal = NULL; ALLEGRO_SAMPLE *sample=NULL;//Audio float bouncer_x = SCREEN_W/2 - AVIAO_SIZE / 2.0; float bouncer_y = SCREEN_H-90 - AVIAO_SIZE / 2.0; bool key[4] = { false, false, false, false }; bool redraw = true; bool doexit = false; if(!al_init()) { fprintf(stderr, "failed to initialize allegro!\n"); return -1; } if(!al_install_keyboard()) { fprintf(stderr, "failed to initialize the keyboard!\n"); return -1; } timer = al_create_timer(1.0 / FPS); if(!timer) { fprintf(stderr, "failed to create timer!\n"); return -1; } if(!al_install_audio()){ fprintf(stderr, "failed to initialize audio!\n"); return -1; } if(!al_init_acodec_addon()){ fprintf(stderr, "failed to initialize audio codecs!\n"); return -1; } if (!al_reserve_samples(1)){ fprintf(stderr, "failed to reserve samples!\n"); return -1; } sample = al_load_sample("audio/somambiente.wav"); if (!sample) { fprintf(stderr, "Falha ao carregar sample.\n"); al_destroy_display(display); return false; } display = al_create_display(SCREEN_W, SCREEN_H); if(!display) { fprintf(stderr, "failed to create display!\n"); al_destroy_timer(timer); return -1; } al_init_image_addon(); aviao_principal = al_load_bitmap("imagens/aviaoprincipal.png"); if(!aviao_principal) { fprintf(stderr, "failed to create avio_principal bitmap!\n"); al_destroy_display(display); al_destroy_timer(timer); return -1; } al_set_target_bitmap(aviao_principal); // al_clear_to_color(al_map_rgb(255, 0, 255)); al_set_target_bitmap(al_get_backbuffer(display)); event_queue = al_create_event_queue(); if(!event_queue) { fprintf(stderr, "failed to create event_queue!\n"); al_destroy_bitmap(aviao_principal); al_destroy_display(display); al_destroy_timer(timer); return -1; } al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_clear_to_color(al_map_rgb(0,0,0)); al_flip_display(); al_start_timer(timer); while(!doexit) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); al_play_sample(sample, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_LOOP,NULL); if(ev.type == ALLEGRO_EVENT_TIMER) { if(key[KEY_UP] && bouncer_y >= SCREEN_H/2) { aviao_principal=al_load_bitmap("imagens/aviaoup.png"); bouncer_y -= 4.0; } if(key[KEY_DOWN] && bouncer_y <= SCREEN_H - AVIAO_SIZE - 50) { aviao_principal=al_load_bitmap("imagens/aviaoprincipal.png"); bouncer_y += 4.0; } if(key[KEY_LEFT] && bouncer_x >= 7.0) { aviao_principal=al_load_bitmap("imagens/aviaoleft.png"); bouncer_x -= 4.0; } if(key[KEY_RIGHT] && bouncer_x <= SCREEN_W - AVIAO_SIZE - 7) { aviao_principal=al_load_bitmap("imagens/aviaoright.png"); bouncer_x += 4.0; } redraw = true; } else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: key[KEY_UP] = true; break; case ALLEGRO_KEY_DOWN: key[KEY_DOWN] = true; break; case ALLEGRO_KEY_LEFT: key[KEY_LEFT] = true; break; case ALLEGRO_KEY_RIGHT: key[KEY_RIGHT] = true; break; } } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: aviao_principal=al_load_bitmap("imagens/aviaoprincipal.png"); key[KEY_UP] = false; break; case ALLEGRO_KEY_DOWN: aviao_principal=al_load_bitmap("imagens/aviaoprincipal.png"); key[KEY_DOWN] = false; break; case ALLEGRO_KEY_LEFT: aviao_principal=al_load_bitmap("imagens/aviaoprincipal.png"); key[KEY_LEFT] = false; break; case ALLEGRO_KEY_RIGHT: aviao_principal=al_load_bitmap("imagens/aviaoprincipal.png"); key[KEY_RIGHT] = false; break; case ALLEGRO_KEY_ESCAPE: doexit = true; break; } } if(redraw && al_is_event_queue_empty(event_queue)) { redraw = false; al_clear_to_color(al_map_rgb(135,206,250)); al_draw_bitmap(aviao_principal, bouncer_x, bouncer_y, 0); al_flip_display(); } } al_destroy_bitmap(aviao_principal); al_destroy_timer(timer); al_destroy_display(display); al_destroy_event_queue(event_queue); al_destroy_sample(sample); return 0; }
  2. #include <allegro5\allegro.h> #include <allegro5\allegro_native_dialog.h> #include <allegro5\allegro_image.h> const float FPS = 60; const int SCREEN_W = 850; const int SCREEN_H = 640; const int BLUE = 64; enum TECLADO { CIMA, BAIXO, DIREITA, ESQUERDA, END }; int main() { //_______VARIAVEIS DO JOGO________ ALLEGRO_DISPLAY *display = NULL; ALLEGRO_BITMAP *blue = NULL; ALLEGRO_BITMAP *Cenario = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; float bouncer_x = SCREEN_W / 2.0 - BLUE / 2.0; float bouncer_y = SCREEN_H / 2.0 - BLUE / 2.0; bool key[] = { false, false, false, false }; bool redraw = true; bool doexit = false; bool desenha = true; bool fim = false; //________INICIALIZAÇÃO DO ALLEGRO 5__________ if (!al_init()) { al_show_native_message_box(display, "Error", "Error", "Failed to initialize allegro!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return 0; } if (!al_init_image_addon()) { al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return 0; } //al_set_new_display_flags(ALLEGRO_FULLSCREEN); display = al_create_display(800, 600); if (!display) { al_show_native_message_box(display, "Error", "Error", "Failed to initialize display!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return 0; } blue = al_load_bitmap("Blue.bmp"); Cenario = al_load_bitmap("Cubo.bmp"); if (!Cenario) { al_show_native_message_box(display, "Error", "Error", "Failed to load image!", NULL, ALLEGRO_MESSAGEBOX_ERROR); al_destroy_display(display); return 0; } event_queue = al_create_event_queue(); if (!event_queue) { al_show_native_message_box(display, "Error", "Error", "Failed to create event_queue!", NULL, ALLEGRO_MESSAGEBOX_ERROR); al_destroy_display(display); return 0; } timer = al_create_timer(1.0 / FPS); if (!timer) { al_show_native_message_box(display, "Error", "Error", "failed to create timer!", NULL, ALLEGRO_MESSAGEBOX_ERROR); al_destroy_display(display); return 0; } al_set_target_bitmap(al_get_backbuffer(display)); //______INSTALAÇÃO________ al_install_keyboard(); //________REGISTRO___________ al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_flip_display(); al_start_timer(timer); //_________LOOP PRINCIPAL__________ while (!doexit) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { fim = true; } if (ev.type == ALLEGRO_EVENT_TIMER) { desenha = false; if (key[CIMA] && bouncer_y >= 4.0) { bouncer_y -= 4.0; } if (key[bAIXO] && bouncer_y <= SCREEN_H - BLUE - 4.0) { bouncer_y += 4.0; } if (key[ESQUERDA] && bouncer_x >= 4.0) { bouncer_x -= 4.0; } if (key[DIREITA] && bouncer_x <= SCREEN_W - BLUE - 4.0) { bouncer_x += 4.0; } if (key[END]) redraw = true; } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch (ev.keyboard.keycode) { case ALLEGRO_KEY_W: key[CIMA] = true; break; case ALLEGRO_KEY_S: key[bAIXO] = true; break; case ALLEGRO_KEY_A: key[ESQUERDA] = true; break; case ALLEGRO_KEY_D: key[DIREITA] = true; break; } } else if (ev.type == ALLEGRO_EVENT_KEY_UP) { switch (ev.keyboard.keycode) { case ALLEGRO_KEY_W: key[CIMA] = false; break; case ALLEGRO_KEY_S: key[bAIXO] = false; break; case ALLEGRO_KEY_A: key[ESQUERDA] = false; break; case ALLEGRO_KEY_D: key[DIREITA] = false; break; case ALLEGRO_KEY_ESCAPE: doexit = true; break; } } if (redraw && al_is_event_queue_empty(event_queue)) { redraw = false; al_clear_to_color(al_map_rgb(255, 255, 255)); al_draw_bitmap(Cenario, 80, 0, 0); al_draw_bitmap(blue, bouncer_x, bouncer_y, 0); al_flip_display(); } } while (1); //________DESTRUIR_________ al_destroy_display(display); //al_destroy_bitmap(Correndo); al_destroy_bitmap(Cenario); al_destroy_event_queue(event_queue); al_destroy_timer(timer); al_destroy_bitmap(blue); return 0; }
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.