Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Allegro turotial.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <allegro5\allegro.h>
- #include <allegro5\allegro_image.h>
- int main()
- {
- al_init();
- ALLEGRO_DISPLAY * display = al_create_display(640, 480);
- ALLEGRO_EVENT_QUEUE * queue;
- ALLEGRO_TIMER * timer;
- ALLEGRO_BITMAP * bitmap = NULL;
- queue = al_create_event_queue();
- timer = al_create_timer(1.0 / 60);
- al_install_keyboard();
- al_register_event_source(queue, al_get_keyboard_event_source());
- al_register_event_source(queue, al_get_display_event_source(display));
- al_register_event_source(queue, al_get_timer_event_source(timer));
- al_init_image_addon();
- //haken kruis "as.jpg"
- bitmap = al_load_bitmap("haje.jpg");
- assert(bitmap != NULL);
- float x = 0;
- bool running = true;
- int width = al_get_display_width(display);
- al_start_timer(timer);
- while (running) {
- ALLEGRO_EVENT event;
- al_wait_for_event(queue, &event);
- if (event.type == ALLEGRO_EVENT_KEY_UP || event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
- running = false;
- if (event.type == ALLEGRO_EVENT_TIMER) {
- //rode kleur voor hakenkruis: 221,0,0
- al_clear_to_color(al_map_rgb(30, 20, 20));
- al_draw_bitmap(bitmap, x += 2, 0, 0);
- al_flip_display();
- }
- if (x > width)
- {
- x = -al_get_bitmap_width(bitmap);
- }
- }
- al_destroy_timer(timer);
- al_destroy_display(display);
- al_uninstall_keyboard();
- al_destroy_bitmap(bitmap);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement