int initializeAllegro(void){ if(!al_init()){ fprintf(stderr,"No se pudo inicializar Allegro\n"); return ERROR; } if(!al_install_mouse()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); return ERROR; } if(!al_init_primitives_addon()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); return ERROR; } al_init_font_addon(); //esta funcion en su declaracion dice que devuelve VOID, por eso no puedo hacer el chequeo if(!al_init_ttf_addon()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); return ERROR; } if(!al_init_image_addon()){ fprintf(stderr,"No se inicializo el addon de imagenes\n"); fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); al_shutdown_ttf_addon(); return ERROR; } return 0; }
int main(int argc, char **argv) { ALLEGRO_BITMAP *bitmap; double t0; double t1; if (argc < 3) { fprintf(stderr, "Usage: exnew_convert <infile> <outfile>\n"); fprintf(stderr, "\tPossible file types: BMP PCX PNG TGA\n"); return 1; } if (!al_init()) { fprintf(stderr, "Could not init Allegro.\n"); return 1; } al_init_image_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_NO_PREMULTIPLIED_ALPHA); bitmap = al_load_bitmap(argv[1]); if (!bitmap) { fprintf(stderr, "Error loading input file\n"); return 1; } t0 = al_get_time(); if (!al_save_bitmap(argv[2], bitmap)) { fprintf(stderr, "Error saving bitmap\n"); return 1; } t1 = al_get_time(); printf("Saving took %.4f seconds\n", t1 - t0); al_destroy_bitmap(bitmap); return 0; }
int main(void) { if (!al_init()) { abort_example("Could not init Allegro.\n"); return 1; } al_install_keyboard(); al_init_image_addon(); if (al_get_num_video_adapters() < 2) { abort_example("You need 2 or more adapters/monitors for this example.\n"); return 1; } go(); return 0; }
bool init(void) { srand(time(NULL)); if (!al_init()) { debug_message("Error initialising Allegro.\n"); return false; } al_init_image_addon(); al_init_font_addon(); al_init_acodec_addon(); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA); if (!loadResources()) { debug_message("Error loading resources.\n"); return false; } return true; }
int main (int argc, char *argv[]) { if (!al_init()) { fprintf(stderr, "Failed to initialize Allegro\n"); return 1; } ALLEGRO_DISPLAY *display = al_create_display(640,480); if (display == NULL) { fprintf(stderr, "Failed to create a display\n"); return 2; } al_clear_to_color(al_map_rgb(255,0,0)); al_flip_display(); al_rest(3.0); al_destroy_display(display); return 0; }
int main(void) { if (!al_init()) { abort_example("Could not init Allegro.\n"); return 1; } al_init_primitives_addon(); al_install_keyboard(); al_init_image_addon(); al_init_font_addon(); display = al_create_display(640, 480); if (!display) { abort_example("Error creating display\n"); return 1; } queue = al_create_event_queue(); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_display_event_source(display)); myfont = al_load_font("data/font.tga", 0, 0); if (!myfont) { abort_example("font.tga not found\n"); return 1; } while (!quit) { if (al_get_new_bitmap_flags() & ALLEGRO_FORCE_LOCKING) al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); else al_set_new_bitmap_flags(ALLEGRO_FORCE_LOCKING); run(); } al_destroy_event_queue(queue); return 0; }
int main(int argc, char **argv) { ALLEGRO_DISPLAY *display; ALLEGRO_TIMER *timer; (void)argc; (void)argv; if (!al_init()) { abort_example("Could not init Allegro.\n"); } al_install_keyboard(); al_install_mouse(); al_init_image_addon(); al_init_font_addon(); init_platform_specific(); display = al_create_display(640, 480); if (!display) { abort_example("Error creating display\n"); } init(); timer = al_create_timer(1.0 / ex.FPS); ex.queue = al_create_event_queue(); al_register_event_source(ex.queue, al_get_keyboard_event_source()); al_register_event_source(ex.queue, al_get_mouse_event_source()); al_register_event_source(ex.queue, al_get_display_event_source(display)); al_register_event_source(ex.queue, al_get_timer_event_source(timer)); al_start_timer(timer); run(); al_destroy_event_queue(ex.queue); return 0; }
int main(int argc, const char *argv[]) { const char *url; ALLEGRO_DISPLAY *display; ALLEGRO_BITMAP *bmp; if (argc > 1) url = argv[1]; else url = "http://liballeg.org/images/logo.png"; if (!al_init()) { abort_example("Could not init Allegro.\n"); } open_log(); al_init_image_addon(); al_install_keyboard(); display = al_create_display(640, 480); if (!display) { abort_example("Unable to create display.\n"); } curl_global_init(CURL_GLOBAL_ALL); al_set_new_file_interface(&curl_file_vtable); bmp = al_load_bitmap(url); if (bmp) { show_image(bmp); al_destroy_bitmap(bmp); } curl_global_cleanup(); close_log(true); return 0; }
int main(int argc, char **argv) { al_init(); al_init_image_addon(); Display d (500, 500); Engine g (&d); ALLEGRO_BITMAP *bmp = al_load_bitmap("m.png"); if (!bmp) { printf("Could not load bmp!\n"); return -1; } BaseSprite s (bmp); g.display->addRenderable(&s); g.setState(ERUNNING); while (1) { while (g.getState() == ERUNNING) { g.engineTick(); g.engineRender(); g.engineSleep(); } printf("BREAK\n"); if (g.getState() == EPAUSED) { while (g.getState() == EPAUSED) { g.engineTick(); g.engineSleep(1); } } if (g.getState() == EQUIT) { g.engineQuit(); break; } } d.del(); return 0; }
int main() { al_init(); ALLEGRO_DISPLAY *display; al_set_new_display_flags(ALLEGRO_WINDOWED); display = al_create_display(800, 600); al_install_keyboard(); ALLEGRO_EVENT_QUEUE *event_queue = al_create_event_queue(); al_register_event_source(event_queue, (ALLEGRO_EVENT_SOURCE *)display); al_register_event_source(event_queue, al_get_keyboard_event_source()); while(1) { ALLEGRO_EVENT event; if (al_get_next_event(event_queue, &event)) { if (ALLEGRO_EVENT_DISPLAY_CLOSE == event.type) { break; } if(ALLEGRO_EVENT_KEY_UP == event.type) { if(event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { break; } } } al_flip_display(); al_clear_to_color(al_map_rgb(0, 0, 0)); al_rest(0.001); } al_destroy_event_queue(event_queue); al_destroy_display(display); }
DrawingClass::DrawingClass (int w, int h, Interface *interface) { al_init(); mDisplay = al_create_display(w, h); al_set_window_title(mDisplay, "Tower Defense"); mEventQueue = al_create_event_queue(); mTimer = al_create_timer (1.0/((float)ConstFps)); mInterface = interface; al_init_font_addon(); al_init_ttf_addon(); al_init_primitives_addon(); al_install_mouse(); al_install_keyboard(); assert(al_install_audio()); assert(al_init_acodec_addon()); assert(al_reserve_samples(1)); al_init_image_addon(); al_register_event_source(mEventQueue, al_get_display_event_source(mDisplay)); al_register_event_source(mEventQueue, al_get_timer_event_source(mTimer)); al_register_event_source(mEventQueue, al_get_mouse_event_source()); al_register_event_source(mEventQueue, al_get_keyboard_event_source()); float tileSize = interface->GetTileSize(); mBigFont = al_load_font("DejaVuSans.ttf", tileSize, 0); mFont = al_load_font("DejaVuSans.ttf", tileSize/2, 0); mSmallFont = al_load_font("DejaVuSans.ttf", tileSize/4, 0); mMusic = 0; // mBackground = al_create_bitmap(tileSize, tileSize); mBackground = al_load_bitmap("Images/grass.png"); /* al_set_target_bitmap(mBackground); * al_draw_filled_circle(tileSize/2, tileSize/2, tileSize/2, al_map_rgb(0, 255, 0)); * al_set_target_bitmap(al_get_backbuffer(mDisplay)); */ CreateMap(); }
void initialize() { srand((unsigned int) time(NULL)); #ifdef DEBUG printf("Allegro v%i.%i.%i\n", al_get_allegro_version() >> 24, (al_get_allegro_version() >> 16) & 255, (al_get_allegro_version() >> 8) & 255); #endif //DEBUG if (!al_init()) { printf("Failed to initialize allegro!\n"); exit(EXIT_FAILURE); } if (!al_install_audio()) { fprintf(stderr, "Failed to initialize audio!\n"); exit(EXIT_FAILURE); } if (!al_init_acodec_addon()) { fprintf(stderr, "Failed to initialize audio codecs!\n"); exit(EXIT_FAILURE); } if (!al_reserve_samples(1)) { fprintf(stderr, "Failed to reserve samples!\n"); exit(EXIT_FAILURE); } if (!al_install_mouse()) { fprintf(stderr, "Failed to initialize the mouse!\n"); exit(EXIT_FAILURE); } if (!al_install_keyboard()) { fprintf(stderr, "al_install_keyboard Failed!\n"); exit(EXIT_FAILURE); } al_init_primitives_addon(); al_init_font_addon(); al_init_ttf_addon(); al_init_image_addon(); }
bool Init() { if (LoadConfigurationData(applicationConfig, styleConfig) == false) return false; al_init(); if (applicationConfig.bfullscreen == true) { al_set_new_display_flags(ALLEGRO_FULLSCREEN); } al_set_app_name(applicationConfig.strAppName.c_str()); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_REQUIRE); display = al_create_display(applicationConfig.iDispW, applicationConfig.iDispH); al_install_keyboard(); al_install_mouse(); al_init_primitives_addon(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); timer = al_create_timer(applicationConfig.dFps); queue = al_create_event_queue(); textFont = al_load_ttf_font(styleConfig.strFontPath.c_str(), styleConfig.iFontSize, NULL); if ((display == nullptr) || (timer == nullptr) || (queue == nullptr) || (textFont == nullptr)) { std::cout << "ERROR: Either the display, timer, queue or font failed to initialize!" << std::endl << "0x" << display << " 0x" << timer << " 0x" << queue << " 0x" << textFont << std::endl; return false; } 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_display_event_source(display)); al_register_event_source(queue, al_get_timer_event_source(timer)); return true; }
void Core::Init() { // Attempt to initialize allegro; if unsuccessful, show an error. if (!al_init()) { al_show_native_message_box(NULL, "Error", "Error", "Failed to initialize Allegro.", NULL, NULL); } // Attempt to create display; if unsuccessful, show an error. al_set_new_display_flags(ALLEGRO_OPENGL); display = al_create_display(SCREEN_WIDTH, SCREEN_HEIGHT); if (!display) { al_show_native_message_box(NULL, "Error", "Error", "Failed to create display.", NULL, NULL); } // Install keyboard, mouse and image addons al_install_keyboard(); al_install_mouse(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); // Create timer timer = al_create_timer(1.0f / FPS); // Create event queue and register event sources evQueue = al_create_event_queue(); al_register_event_source(evQueue, al_get_keyboard_event_source()); al_register_event_source(evQueue, al_get_timer_event_source(timer)); al_register_event_source(evQueue, al_get_display_event_source(display)); player.Init(this); food.Init(player); powerup.Init(player); overlay.Init(); }
static int expand_test( const wchar_t *in, int flags, ... ) { array_list_t out; va_list va; int i=0; int res=1; wchar_t *arg; al_init( &out ); if( expand_string( 0, wcsdup(in), &out, flags) ) { } va_start( va, flags ); while( (arg=va_arg(va, wchar_t *) )!= 0 ) { if( al_get_count( &out ) == i ) { res=0; break; } if( wcscmp( al_get( &out, i ),arg) != 0 ) { res=0; break; } i++; } va_end( va ); al_foreach( &out, &free ); return res; }
void init(void) { if (!al_init()) abort_game("Failed to initialize allegro"); if (!al_install_keyboard()) abort_game("Failed to install keyboard"); if (!al_init_primitives_addon()) abort_game("Failed to install primitives"); al_init_font_addon(); // initialize the font addon al_init_ttf_addon();// initialize the ttf (True Type Font) addon timer = al_create_timer(1.0 / 60); if (!timer) abort_game("Failed to create timer"); ALLEGRO_DISPLAY_MODE disp_data; al_get_display_mode(0, &disp_data); al_set_new_display_flags(ALLEGRO_WINDOWED); //display = al_create_display(disp_data.width, disp_data.height); display = al_create_display(800, 480); if (!display) abort_game("Failed to create display"); event_queue = al_create_event_queue(); if (!event_queue) abort_game("Failed to create event queue"); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_display_event_source(display)); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); font = al_load_ttf_font("src/Atari_Full.ttf", 16,0 ); done = false; }
int main(int argc, char *argv[]) { ALLEGRO_DISPLAY *display; ALLEGRO_FONT *font; (void)argc; (void)argv; if (!al_init()) { abort_example("Could not init Allegro\n"); return 1; } al_init_primitives_addon(); al_install_keyboard(); al_install_mouse(); al_init_font_addon(); al_init_ttf_addon(); al_set_new_display_flags(ALLEGRO_GENERATE_EXPOSE_EVENTS); display = al_create_display(640, 480); if (!display) { abort_example("Unable to create display\n"); return 1; } font = al_load_font("data/DejaVuSans.ttf", 12, 0); if (!font) { abort_example("Failed to load data/DejaVuSans.ttf\n"); return 1; } Theme theme(font); Prog prog(theme, display); prog.run(); al_destroy_font(font); return 0; }
int test_allegro() { ALLEGRO_DISPLAY *display = NULL; if(!al_init()) { std::cerr << "failed to initialize allegro!\n"; return -1; } display = al_create_display(640, 480); if(!display) { std::cerr << "failed to create display!\n"; return -1; } al_clear_to_color(al_map_rgb(0xAA,0,0)); al_flip_display(); al_rest(5.0); al_destroy_display(display); return 0; }
void Juego::init(){ //Iniciando Componentes (Imagenes y teclado) al_init(); al_init_image_addon(); al_install_keyboard(); //Iniciando Pantalla "display" display = al_create_display(this->filas*50,this->cols*50); //Creando Timer y Eventero this->timer = al_create_timer(1.0/ this->FPS); this->event_queue = al_create_event_queue(); //Registradores de eventos al_register_event_source(this->event_queue, al_get_display_event_source(this->display)); al_register_event_source(this->event_queue, al_get_keyboard_event_source()); al_register_event_source(this->event_queue, al_get_timer_event_source(this->timer)); al_flip_display(); al_start_timer(this->timer); }
void GameEngine::Init() { done = false; input = new InputHandler(); collisionDetector = new CollisionDetector(); menuState = new State_Menu(); gameState = new State_Game(); states.push_back(menuState); states.push_back(gameState); al_init(); //Initialises the allegro library al_install_keyboard(); al_install_mouse(); al_set_new_display_flags(ALLEGRO_RESIZABLE); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR); al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 6, ALLEGRO_SUGGEST); display = al_create_display(WIDTH, HEIGHT); al_set_window_title(display, "Vinctus Arce"); eventQueue = al_create_event_queue(); al_register_event_source(eventQueue, al_get_display_event_source(display)); al_register_event_source(eventQueue, al_get_keyboard_event_source()); al_register_event_source(eventQueue, al_get_mouse_event_source()); timer = al_create_timer(1.0f / FPS); al_register_event_source(eventQueue, al_get_timer_event_source(timer)); al_start_timer(timer); PushState(menuState); }
void init_allegro(){ if(!al_init()) { fprintf(stderr, "Failed to initialize allegro!\n"); } if(!al_install_keyboard()) { fprintf(stderr, "Failed to initialize the keyboard!\n"); } if(!al_init_primitives_addon()) { fprintf(stderr, "failed to create primitives addon!\n"); } al_init_font_addon(); default_font = al_create_builtin_font(); if (!default_font) fprintf(stderr, "Failed to create builtin font"); timer = al_create_timer(1.0 / FPS); if(!timer) { fprintf(stderr, "failed to create timer!\n"); } display = al_create_display(SCREEN_WIDTH, SCREEN_HEIGHT); if(!display){ fprintf(stderr, "Failed to create display!\n"); } event_queue = al_create_event_queue(); if(!event_queue) { fprintf(stderr, "failed to create event_queue!\n"); } al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_timer_event_source(timer)); atexit(destroy_allegro); }
void error_display(const char *text) { ALLEGRO_DISPLAY *disp; ALLEGRO_EVENT_QUEUE *ev_queue; ALLEGRO_FONT *font; al_init(); al_install_keyboard(); al_install_mouse(); al_init_font_addon(); al_set_new_display_flags(ALLEGRO_WINDOWED); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); disp = al_create_display(640, 480); al_set_window_title(disp, "mruby-minigame"); ev_queue = al_create_event_queue(); al_register_event_source(ev_queue, al_get_display_event_source(disp)); al_register_event_source(ev_queue, al_get_keyboard_event_source()); al_register_event_source(ev_queue, al_get_mouse_event_source()); font = al_create_builtin_font(); for (;;) { ALLEGRO_EVENT ev; while (al_get_next_event(ev_queue, &ev)) { if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) goto done; } al_clear_to_color(al_map_rgb(200, 120, 120)); al_draw_multiline_text(font, al_map_rgb(255, 255, 255), 64, 64, 640-64, 10, ALLEGRO_ALIGN_LEFT, text); al_flip_display(); } done: return; }
int main(){ ALLEGRO_DISPLAY *display = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; al_init(); display = al_create_display(640,480); event_queue = al_create_event_queue(); al_register_event_source(event_queue,al_get_display_event_source(display)); al_clear_to_color(al_map_rgb(0,61,236)); al_flip_display(); while(1) { ALLEGRO_EVENT ev; ALLEGRO_TIMEOUT timeout; al_init_timeout(&timeout, 0.06); bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout); if(get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } al_clear_to_color(al_map_rgb(156,10,20)); al_flip_display(); } al_destroy_display(display); al_destroy_event_queue(event_queue); return 0; }
int main(void) { int i; if (!al_init()) { abort_example("Could not init Allegro.\n"); return 1; } al_install_keyboard(); open_log(); display = al_create_display(640, 100); if (!display) { abort_example("Could not create display.\n"); return 1; } if (!al_install_audio()) { abort_example("Could not init sound.\n"); return 1; } al_reserve_samples(N); al_set_mixer_postprocess_callback(al_get_default_mixer(), update_waveform, NULL); mainloop(); close_log(false); for (i = 0; i < N; i++) { al_destroy_audio_stream(stream[i]); } al_uninstall_audio(); return 0; }
int init_allegro(Camera *cam) { if (!al_init()) return 1; if (!al_install_mouse()) return 1; if (!al_install_keyboard()) return 1; al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_OPENGL | ALLEGRO_OPENGL_FORWARD_COMPATIBLE | ALLEGRO_RESIZABLE); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); dpy = al_create_display(cam->left + cam->width, cam->bottom + cam->height); glViewport(cam->left, cam->bottom, cam->width, cam->height); ev_queue = al_create_event_queue(); al_register_event_source(ev_queue, al_get_display_event_source(dpy)); al_register_event_source(ev_queue, al_get_mouse_event_source()); al_register_event_source(ev_queue, al_get_keyboard_event_source()); return 0; }
int main(){ al_init(); float velocity[2] = {2.0, 3.0}; float acceleration[2] = {5.0, 10.8}; VisualBullet b1 (10, 20, velocity, acceleration); display = al_create_display(640, 480); al_set_target_bitmap(al_get_backbuffer(display)); for (int i=0; i<20; i++){ b1.draw(); b1.tick(); al_flip_display(); al_rest(0.1); } al_rest(1.0); al_destroy_display(display); return 1; }
int main() { al_init(); al_init_image_addon(); al_install_mouse(); al_init_primitives_addon(); al_init_font_addon(); al_init_ttf_addon(); al_install_keyboard(); equipAligner *editorWindow = new equipAligner(); //Initialize essential resource management resourceManager::resourcePack::initializeAllegroInterface(); gameEngine::resources::graphics.load("../../../Assets/compiledAssets/Graphics.gtd"); //Load the graphics package gameEngine::resources::data.load("../../../Assets/compiledAssets/Data.gtd"); //Load the graphics package editorWindow->initialize(); float timeLastFrame = al_get_time(); while (1) { double delta = 60/(1/(al_get_time()-timeLastFrame)); timeLastFrame = al_get_time(); static double accumulatedTime = 0; accumulatedTime += delta; const double fixedFrameTime = (double)1/(double)60; while( accumulatedTime > fixedFrameTime ) { accumulatedTime -= fixedFrameTime; editorWindow->update(fixedFrameTime); //update the world } editorWindow->render(); al_rest(0.0); } }
// TODO: remove init_core_sprites, put instead ini_base_images. // Game entry point, calls all initialization functions before calling main_loop int main(int argc, char** argv) { // Declare main struct containing the important data data = (GDATAPTR)malloc(sizeof(GDATA)); // Initialize Allegro 5 and addon routines al_init(); al_init_primitives_addon(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); PHYSFS_init(argv[0]); // Initialize the core game data structure if(!data_init()) exit(EXIT_FAILURE); // Creates a player sprite if(!init_core_sprites()) exit(EXIT_FAILURE); // Initializes the buttons if(!init_buttons()) exit(EXIT_FAILURE); // Initializes the physics and collision detection if(!init_chipmunk()) exit(EXIT_FAILURE); // Create the progress bar loader(); // Enters the main loop, where everything happens main_loop(); // Cleanup before exit cleanup(data); // Return 0 before exit return 0; }
void GameEngine::Init() { running = true; al_init(); //Initialises the allegro library al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); display = al_create_display(scrx, scry); al_set_window_title(display, "Knights"); al_install_keyboard(); //Installs keyboard driver eventQueue = al_create_event_queue(); redrawQueue = al_create_event_queue(); al_register_event_source(eventQueue, al_get_display_event_source(display)); al_register_event_source(eventQueue, al_get_keyboard_event_source()); redrawTimer = al_create_timer(1.0f / FPS); al_register_event_source(redrawQueue, al_get_timer_event_source(redrawTimer)); al_start_timer(redrawTimer); srand((int)time(NULL)); //Randomises the numbers used in program so that it's not the same each time. }
void Environment::draw() { // Check if Allegro Env is Initialized if (!al_init()) { printf( "Error: Environment::draw() : Allegro Environment Not Initialized Yet\n"); return; } // Draw if Allegro Display exists if (obstacles.size()) { std::list<Obstacle>::iterator itr = obstacles.begin(); while (itr != obstacles.end()) { //printf("obstacle draw called\n"); al_draw_filled_rectangle(itr->tlc.x, itr->tlc.y, itr->tlc.x + itr->width, itr->tlc.y + itr->height, al_map_rgb(255, 255, 255)); itr++; } } if (targets.size()) { std::list<Obstacle>::iterator itr1 = targets.begin(); while (itr1 != targets.end()) { //printf("obstacle draw called\n"); al_draw_filled_rectangle(itr1->tlc.x, itr1->tlc.y, itr1->tlc.x + itr1->width, itr1->tlc.y + itr1->height, al_map_rgb(0, 255, 0)); itr1++; } } if (withGrid) { drawGrid(true); } }