void Game::cleanup() { //delete the timers delete mpLoopTimer; mpLoopTimer = NULL; delete mpMasterTimer; mpMasterTimer = NULL; //delete the graphics system delete mpGraphicsSystem; mpGraphicsSystem = NULL; delete mpGraphicsBufferManager; mpGraphicsBufferManager = NULL; delete mpSpriteManager; mpSpriteManager = NULL; al_destroy_font(mpFont); mpFont = NULL; //shutdown components al_uninstall_audio(); al_shutdown_image_addon(); al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); }
void shutdown_allegro(al_defs *al){ unload_resources(al); al_destroy_display(al->disp); al_destroy_event_queue(al->queue); al_shutdown_image_addon(); al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_uninstall_keyboard(); }
void shutdown() { al_shutdown_image_addon(); al_shutdown_ttf_addon(); al_shutdown_font_addon(); al_shutdown_primitives_addon(); al_uninstall_keyboard(); al_uninstall_mouse(); al_uninstall_audio(); al_uninstall_system(); }
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; }
void mw2_Application::Exit() { mIsExit = true; al_shutdown_image_addon(); al_shutdown_primitives_addon(); al_shutdown_font_addon(); // from unknown reasons this causes a crash //al_shutdown_ttf_addon(); al_destroy_display(mWindow); }
void finalize_video (void) { destroy_bitmap (icon); destroy_bitmap (uscreen); destroy_bitmap (effect_buffer); destroy_bitmap (black_screen); al_destroy_font (builtin_font); al_destroy_timer (video_timer); al_destroy_display (display); al_shutdown_image_addon (); al_shutdown_font_addon (); al_shutdown_primitives_addon (); }
void closeAllegro(void){ al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_uninstall_system(); }
GUI::~GUI() { al_stop_timer(timer); al_unregister_event_source(queue, al_get_keyboard_event_source()); al_unregister_event_source(queue, al_get_display_event_source(display)); al_unregister_event_source(queue, al_get_timer_event_source(timer)); al_destroy_event_queue(queue); al_destroy_bitmap(tiles); al_destroy_display(display); al_uninstall_keyboard(); al_shutdown_font_addon(); al_shutdown_primitives_addon(); al_shutdown_image_addon(); al_uninstall_system(); }
int main(int argc, char *argv[]) { int res = 0; if (!al_init()) { fprintf(stderr, "Failed to initialize Allegro\n"); res = 1; goto X0; } al_init_font_addon(); if (!al_init_ttf_addon()) { fprintf(stderr, "Failed to initialize the TTF addong\n"); res = 3; goto X1; } const char *font_name = "../resources/font.ttf"; ALLEGRO_FONT *font = al_load_ttf_font(font_name, 12, 0); if (font == NULL) { fprintf(stderr, "Failed to load font %s\n", font_name); res = 4; goto X2; } ALLEGRO_DISPLAY *display = al_create_display(640,480); if (display == NULL) { fprintf(stderr, "Failed to creat display\n"); res = 5; goto X3; } al_draw_text(font, al_map_rgb(255,255,255), 0, 0, 0, "Hello Явор"); al_flip_display(); al_rest(3); al_destroy_display(display); X3: al_destroy_font(font); X2: al_shutdown_ttf_addon(); X1: al_shutdown_font_addon(); X0: return res; }
Framework::~Framework() { Settings->Save( "settings.cfg" ); #ifdef WRITE_LOG printf( "Framework: Shutdown\n" ); #endif al_destroy_event_queue( eventQueue ); al_destroy_display( displaySurface ); al_destroy_mutex( extraEventsMutex ); delete imageMgr; delete audioMgr; delete fontMgr; delete networkMgr; delete downloadMgr; // Shutdown Allegro if( mixer != 0 ) { al_destroy_mixer( mixer ); } if( voice != 0 ) { al_destroy_voice( voice ); } al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_shutdown_font_addon(); al_uninstall_audio(); al_uninstall_joystick(); }
int main(int argc, char **argv) { // Initialize Allegro if (!al_init()) { fprintf(stderr, "Fatal Error: Allegro initialization failed!\n"); return -1; } // Initialize the Allegro Image addon, used to load sprites and maps if (!al_init_image_addon()) { fprintf(stderr, "Fatal Error: Allegro Image Addon initialization failed!\n"); return -1; } // Initialize primitives for drawing if (!al_init_primitives_addon()) { fprintf(stderr, "Fatal Error: Could not initialize primitives module!"); throw -1; } // Initialize keyboard modules if (!al_install_keyboard()) { fprintf(stderr, "Fatal Error: Could not initialize keyboard module!"); throw -1; } // Initialize mouse if (!al_install_mouse()) { fprintf(stderr, "Fatal Error: Could not initialize mouse module!"); throw -1; } // Initialize networking system if (enet_initialize()) { fprintf(stderr, "Fatal Error: Could not initialize enet!"); throw -1; } // Create a display ALLEGRO_DISPLAY *display; al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE); al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_RESIZABLE); display = al_create_display(1280, 720); if(!display) { // FIXME: Make the error argument mean anything? fprintf(stderr, "Fatal Error: Could not create display\n"); throw -1; } //load font //gg2 font as placeholder for now i guess al_init_font_addon(); al_init_ttf_addon(); ALLEGRO_FONT *font = al_load_font("Vanguard Main Font.ttf", 12, ALLEGRO_TTF_MONOCHROME); if (!font) { fprintf(stderr, "Could not load 'gg2bold.ttf'.\n"); throw -1; } // MainMenu *mainmenu = new MainMenu(display); bool isserver; if (argc >= 2) { // If there are any arguments isserver = false; } else { isserver = true; } // double lasttimeupdated = al_get_time(); // bool run = true; // while (run) // { // if (al_get_time() - lasttimeupdated >= MENU_TIMESTEP) // { // run = mainmenu->run(display, &gametype); // lasttimeupdated = al_get_time(); // } // } // delete mainmenu; Engine engine(isserver); Renderer renderer; InputCatcher inputcatcher(display); Gamestate renderingstate(&engine); std::unique_ptr<Networker> networker; if (isserver) { networker = std::unique_ptr<Networker>(new ServerNetworker()); } else { networker = std::unique_ptr<Networker>(new ClientNetworker()); } engine.loadmap("lijiang"); // FIXME: Hack to make sure the oldstate is properly initialized engine.update(&(networker->sendbuffer), 0); EntityPtr myself(0); if (isserver) { myself = engine.currentstate->addplayer(); engine.currentstate->get<Player>(myself)->spawntimer.active = true; } else { ClientNetworker *n = reinterpret_cast<ClientNetworker*>(networker.get()); while (not n->isconnected()) { n->receive(engine.currentstate.get()); } myself = engine.currentstate->playerlist[engine.currentstate->playerlist.size()-1]; } InputContainer held_keys; double mouse_x; double mouse_y; double enginetime = al_get_time(); double networkertime = al_get_time(); while (true) { try { while (al_get_time() - enginetime >= ENGINE_TIMESTEP) { networker->receive(engine.currentstate.get()); inputcatcher.run(display, &held_keys, &mouse_x, &mouse_y); if (not isserver) { Character *c = engine.currentstate->get<Player>(myself)->getcharacter(engine.currentstate.get()); if (c != 0) { ClientNetworker *n = reinterpret_cast<ClientNetworker*>(networker.get()); n->sendinput(held_keys, mouse_x/renderer.zoom+renderer.cam_x, mouse_y/renderer.zoom+renderer.cam_y); } } engine.setinput(myself, held_keys, mouse_x/renderer.zoom+renderer.cam_x, mouse_y/renderer.zoom+renderer.cam_y); engine.update(&(networker->sendbuffer), ENGINE_TIMESTEP); networker->sendeventdata(engine.currentstate.get()); enginetime += ENGINE_TIMESTEP; } if (isserver) { if (al_get_time() - networkertime >= NETWORKING_TIMESTEP) { ServerNetworker *n = reinterpret_cast<ServerNetworker*>(networker.get()); n->sendframedata(engine.currentstate.get()); networkertime = al_get_time(); } } renderingstate.interpolate(engine.oldstate.get(), engine.currentstate.get(), (al_get_time()-enginetime)/ENGINE_TIMESTEP); renderer.render(display, &renderingstate, myself, networker.get()); } catch (int e) { if (e != 0) { fprintf(stderr, "\nError during regular loop."); fprintf(stderr, "\nExiting.."); } al_destroy_display(display); return 0; } } al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_destroy_display(display); enet_deinitialize(); return 0; }
int main( int argc, char* argv[] ) { ALLEGRO_EVENT e; ALLEGRO_TIMER* t; int64_t framesToUpdate = 0; if( !al_init() ) { return -1; } al_init_font_addon(); if( !al_install_keyboard() || !al_install_mouse() || !al_init_primitives_addon() || !al_init_ttf_addon() || !al_init_image_addon() ) { return -1; } #if NETWORK_SUPPORT != 0 if( !install_network() ) { return -1; } #endif #if HTTP_SUPPORT if( !install_http() ) { return -1; } #ifdef PANDORA Downloads = new HttpManager(2); #else Downloads = new HttpManager(6); #endif #endif #if EXIT_IF_NO_AUDIO != 0 if( !al_install_audio() || !al_init_acodec_addon() ) { return -1; } voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); if (!voice) return 1; mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); if (!mixer) return 1; if (!al_attach_mixer_to_voice(mixer, voice)) return 1; #else if( al_install_audio() ) { if( al_init_acodec_addon() ) { voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); if( voice != 0 ) { mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); if( mixer != 0 ) al_attach_mixer_to_voice(mixer, voice); } } } #endif // EXIT_IF_NO_AUDIO // Random number is guarenteed to be random srand( 5 ); GameStack = new StageStack(); CurrentConfiguration = new Configuration(); if( CurrentConfiguration->FullScreen ) al_set_new_display_flags( ALLEGRO_FULLSCREEN_WINDOW ); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); bool foundMode = false; int fallbackW = 640; int fallbackH = 480; if( CurrentConfiguration->ForceResolution ) { foundMode = true; } else { for( int modeIdx = 0; modeIdx < al_get_num_display_modes(); modeIdx++ ) { if( al_get_display_mode( modeIdx, &ScreenMode ) != NULL ) { if( ScreenMode.width == CurrentConfiguration->ScreenWidth && ScreenMode.height == CurrentConfiguration->ScreenHeight ) { foundMode = true; } else { fallbackW = ScreenMode.width; fallbackH = ScreenMode.height; } } if( foundMode ) break; } } if( foundMode ) { Screen = al_create_display( CurrentConfiguration->ScreenWidth, CurrentConfiguration->ScreenHeight ); } else { Screen = al_create_display( fallbackW, fallbackH ); CurrentConfiguration->ScreenWidth = fallbackW; CurrentConfiguration->ScreenHeight = fallbackH; } al_hide_mouse_cursor( Screen ); t = al_create_timer( 1.0 / SCREEN_FPS ); if( t == NULL ) Quit = true; al_start_timer( t ); EventQueue = al_create_event_queue(); al_register_event_source( EventQueue, al_get_display_event_source( Screen ) ); al_register_event_source( EventQueue, al_get_keyboard_event_source() ); al_register_event_source( EventQueue, al_get_mouse_event_source() ); al_register_event_source( EventQueue, al_get_timer_event_source( t ) ); #if NETWORK_SUPPORT != 0 al_register_event_source( EventQueue, get_network_event_source() ); #endif #if HTTP_SUPPORT Downloads->urlDownloads = CurrentConfiguration->MaxConcurrentDownloads; al_register_event_source( EventQueue, get_http_event_source() ); #endif Fonts = new FontManager(); Images = new ImageManager(); Audio = new SoundManager(); al_set_blender( ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA ); GameStack->Push( (Stage*)new BootUp() ); while( !Quit ) { if( GameStack->IsEmpty() ) { Quit = true; } else { while( al_get_next_event( EventQueue, &e ) ) { #if HTTP_SUPPORT Downloads->Event( &e ); #endif switch( e.type ) { case ALLEGRO_EVENT_DISPLAY_CLOSE: Quit = true; break; case ALLEGRO_EVENT_JOYSTICK_CONFIGURATION: al_reconfigure_joysticks(); break; case ALLEGRO_EVENT_TIMER: if( e.timer.source == t ) framesToUpdate++; else if( !GameStack->IsEmpty() ) GameStack->Current()->Event( &e ); break; default: if( !GameStack->IsEmpty() ) GameStack->Current()->Event( &e ); switch( e.type ) { #if HTTP_SUPPORT case ALLEGRO_EVENT_HTTP: #endif #if NETWORK_SUPPORT case ALLEGRO_EVENT_NETWORK_CONNECTION: case ALLEGRO_EVENT_NETWORK_RECEIVEPACKET: case ALLEGRO_EVENT_NETWORK_DISCONNECTION: #endif case ALLEGRO_EVENT_BUTTON_CLICK: case ALLEGRO_EVENT_MOUSEEX_MOVE: case ALLEGRO_EVENT_MOUSEEX_DOWN: case ALLEGRO_EVENT_MOUSEEX_UP: case ALLEGRO_EVENT_MOUSEEX_CLICK: case ALLEGRO_EVENT_MOUSEEX_DOUBLECLICK: case ALLEGRO_EVENT_MOUSEEX_BOXED: case ALLEGRO_EVENT_MOUSEEX_WHEEL: al_unref_user_event( &e.user ); break; } break; } } if( framesToUpdate > 0 ) { for( int frmUp = 0; frmUp < framesToUpdate; frmUp++ ) { if( !GameStack->IsEmpty() ) GameStack->Current()->Update(); } framesToUpdate = 0; } al_clear_to_color( al_map_rgb( 128, 128, 128 ) ); if( !GameStack->IsEmpty() ) GameStack->Current()->Render(); al_flip_display(); Images->Tidy(); Fonts->Tidy(); Audio->Tidy(); } } while( !GameStack->IsEmpty() ) { GameStack->Pop(); } delete Downloads; delete Fonts; delete Images; delete Audio; al_destroy_event_queue( EventQueue ); al_destroy_display( Screen ); #if HTTP_SUPPORT uninstall_http(); #endif #if NETWORK_SUPPORT != 0 uninstall_network(); #endif al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_uninstall_audio(); al_shutdown_font_addon(); return 0; }
int main(void) { int X_ROOMS=13; int Y_ROOMS=16; int X_ROOM_SIZE=256; int Y_ROOM_SIZE=128; int SCALE_FACTOR=4; int X_TILE_SIZE=8; int Y_TILE_SIZE=8; int LAST_OBJECT=0; int actid=0; int error=0; ALLEGRO_CONFIG *cfg; ALLEGRO_BITMAP *bmp,*virt,*tmp=NULL; ALLEGRO_DISPLAY *display; ALLEGRO_KEYBOARD_STATE key; ALLEGRO_FONT *font; signed int xcursor=0; signed int ycursor=0; signed char x=0; signed char y=0; signed char finex=0; signed char finey=0; char finish=0; ALLEGRO_COLOR black,white,red,color; int scale_cursor_x=0; int scale_cursor_y=0; int i=0; int a=0; unsigned char r,g,b=0; char pngfilename[20]; char *tmpbuf; char buf[5]; char buf2[5]; /* Iniciar el rollo */ tmpbuf=(char *)malloc(sizeof(char)*X_ROOM_SIZE*Y_ROOM_SIZE); memset(tmpbuf,0,sizeof(char)*X_ROOM_SIZE*Y_ROOM_SIZE); al_init(); al_init_image_addon(); al_init_primitives_addon(); al_init_font_addon(); al_init_ttf_addon(); cfg=al_load_config_file("sacagraf.cfg"); if (cfg==NULL) { cfg=al_create_config(); al_add_config_section(cfg,"Ajustes"); al_add_config_section(cfg,"Objetos"); al_set_config_value(cfg,"Ajustes","Habitaciones en horizontal","13"); al_set_config_value(cfg,"Ajustes","Habitaciones en vertical","16"); al_set_config_value(cfg,"Ajustes","Ancho de la habitacion original en pixels","256"); al_set_config_value(cfg,"Ajustes","Alto de la habitacion original en pixels","128"); al_set_config_value(cfg,"Ajustes","Ancho minimo del caracter original","8"); al_set_config_value(cfg,"Ajustes","Alto minimo del caracter original","8"); al_set_config_value(cfg,"Ajustes","Factor de escalado","4"); al_set_config_value(cfg,"Objetos","Ultimo","0"); al_save_config_file("sacagraf.cfg",cfg); } X_ROOMS=atoi(al_get_config_value(cfg,"Ajustes","Habitaciones en horizontal")); Y_ROOMS=atoi(al_get_config_value(cfg,"Ajustes","Habitaciones en vertical")); X_ROOM_SIZE=atoi(al_get_config_value(cfg,"Ajustes","Ancho de la habitacion original en pixels")); Y_ROOM_SIZE=atoi(al_get_config_value(cfg,"Ajustes","Alto de la habitacion original en pixels")); SCALE_FACTOR=atoi(al_get_config_value(cfg,"Ajustes","Factor de escalado")); X_TILE_SIZE=atoi(al_get_config_value(cfg,"Ajustes","Alto minimo del caracter original")); Y_TILE_SIZE=atoi(al_get_config_value(cfg,"Ajustes","Ancho minimo del caracter original")); LAST_OBJECT=atoi(al_get_config_value(cfg,"Objetos","Ultimo")); actid=LAST_OBJECT; al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_WINDOWED); display=al_create_display(X_ROOM_SIZE*SCALE_FACTOR,192*SCALE_FACTOR); bmp=al_load_bitmap("map.png"); virt=al_create_bitmap(X_ROOM_SIZE*SCALE_FACTOR,Y_ROOM_SIZE*SCALE_FACTOR); font=al_load_ttf_font("proggy.ttf",6*SCALE_FACTOR,0); al_install_keyboard(); black=al_map_rgb(0,0,0); white=al_map_rgba_f(1,1,1,1); red=al_map_rgba_f(1,0,0,0.7); /* Que empiece la fiesta */ while(!finish) { al_get_keyboard_state(&key); if (al_key_down(&key,ALLEGRO_KEY_ESCAPE)) { finish=1; } if (al_key_down(&key,ALLEGRO_KEY_LCTRL)) { finex=0; finey=0; if (al_key_down(&key,ALLEGRO_KEY_RIGHT)) { x++; if (x==X_ROOMS) x=X_ROOMS-1; } if (al_key_down(&key,ALLEGRO_KEY_LEFT)) { x--; if (x<0) x=0; } if (al_key_down(&key,ALLEGRO_KEY_UP)) { y--; if (y<0) y=0; } if (al_key_down(&key,ALLEGRO_KEY_DOWN)) { y++; if (y>Y_ROOMS-1) y=Y_ROOMS-1; } } else if (al_key_down(&key,ALLEGRO_KEY_LSHIFT)) { if (al_key_down(&key,ALLEGRO_KEY_RIGHT)) { finex++; if (finex>X_TILE_SIZE) finex=X_TILE_SIZE; } if (al_key_down(&key,ALLEGRO_KEY_LEFT)) { finex--; if (finex<-X_TILE_SIZE) finex=-X_TILE_SIZE; } if (al_key_down(&key,ALLEGRO_KEY_UP)) { finey--; if (finey<-Y_TILE_SIZE) finey=-Y_TILE_SIZE; } if (al_key_down(&key,ALLEGRO_KEY_DOWN)) { finey++; if (finey>Y_TILE_SIZE) finey=Y_TILE_SIZE; } } else if (al_key_down(&key,ALLEGRO_KEY_ALT)) { if (al_key_down(&key,ALLEGRO_KEY_RIGHT)) { scale_cursor_x++; //if (finex>8) finex=8; } if (al_key_down(&key,ALLEGRO_KEY_LEFT)) { scale_cursor_x--; //if (finex<0) finex=0; } if (al_key_down(&key,ALLEGRO_KEY_UP)) { scale_cursor_y--; //if (finey<0) finey=0; } if (al_key_down(&key,ALLEGRO_KEY_DOWN)) { scale_cursor_y++; //if (finey>8) finey=8; } } else { if (al_key_down(&key,ALLEGRO_KEY_RIGHT)) { xcursor+=X_TILE_SIZE*SCALE_FACTOR; } if (al_key_down(&key,ALLEGRO_KEY_LEFT)) { xcursor-=X_TILE_SIZE*SCALE_FACTOR; } if (al_key_down(&key,ALLEGRO_KEY_UP)) { ycursor-=Y_TILE_SIZE*SCALE_FACTOR; } if (al_key_down(&key,ALLEGRO_KEY_DOWN)) { ycursor+=Y_TILE_SIZE*SCALE_FACTOR; } } al_clear_to_color(black); al_set_target_bitmap(virt); //al_set_blender(ALLEGRO_ALPHA,ALLEGRO_INVERSE_ALPHA,white); al_draw_bitmap_region(bmp,0+(x*X_ROOM_SIZE)+finex,0+(y*Y_ROOM_SIZE)+finey,X_ROOM_SIZE,Y_ROOM_SIZE,0,0,0); al_set_target_bitmap(al_get_backbuffer(display)); al_draw_scaled_bitmap(virt,0,0,X_ROOM_SIZE,Y_ROOM_SIZE,0,0,X_ROOM_SIZE*SCALE_FACTOR,Y_ROOM_SIZE*SCALE_FACTOR,0); al_draw_line(0,512,1024,512,white,0); al_draw_textf(font,al_map_rgba(200,200,200,200),0,520,0,"mapa x: %d mapa y: %d habitacion nº: %d ajuste fino x: %d ajuste fijo y: %d",x,y,x+(y*13),finex,finey); if (error) { al_draw_textf(font,al_map_rgba(200,200,200,200),0,540,0,"Patron repetido"); al_flip_display(); al_rest(1); error=0; } if (al_key_down(&key,ALLEGRO_KEY_ENTER)) { tmp=al_create_bitmap((X_TILE_SIZE*SCALE_FACTOR)+(X_TILE_SIZE*SCALE_FACTOR*scale_cursor_x),(Y_TILE_SIZE*SCALE_FACTOR)+(Y_TILE_SIZE*SCALE_FACTOR*scale_cursor_y)); al_set_target_bitmap(tmp); al_draw_bitmap_region(al_get_backbuffer(display),xcursor,ycursor,(X_TILE_SIZE*SCALE_FACTOR*scale_cursor_x)+(X_TILE_SIZE*SCALE_FACTOR),(Y_TILE_SIZE*SCALE_FACTOR*scale_cursor_y)+(Y_TILE_SIZE*SCALE_FACTOR),0,0,0); memset(tmpbuf,0,sizeof(char)*X_ROOM_SIZE*Y_ROOM_SIZE); memset(buf,0,5); for (i=0;i<(Y_TILE_SIZE*scale_cursor_y*SCALE_FACTOR)+(Y_TILE_SIZE*SCALE_FACTOR);i+=SCALE_FACTOR) { for (a=0;a<(X_TILE_SIZE*scale_cursor_x*SCALE_FACTOR)+(X_TILE_SIZE*SCALE_FACTOR);a+=SCALE_FACTOR) { color=al_get_pixel(tmp,a,i); al_unmap_rgb(color,&r,&g,&b); if (!r && !g && !b) { strcat(tmpbuf,"0"); } else { strcat(tmpbuf,"1"); } } } /* Ya está la secuencia del gráfico en tmpbuf, examinamos todas las secuencias anteriores */ error=0; for (i=0;i<actid;i++) { memset(buf2,0,5); sprintf(buf2,"%d",i); if (!strcmp(al_get_config_value(cfg,"Objetos",buf2),tmpbuf)) { error=i; } } /* Si no hay secuencias repetidas lo grabamos */ if (!error) { sprintf(buf,"%d",actid); al_set_config_value(cfg,"Objetos",buf,tmpbuf); memset(pngfilename,0,20); sprintf(pngfilename,"dec%d.png",actid); al_save_bitmap(pngfilename,tmp); actid++; } al_destroy_bitmap(tmp); } al_set_target_bitmap(al_get_backbuffer(display)); //al_set_blender(ALLEGRO_ALPHA,ALLEGRO_INVERSE_ALPHA,red); al_draw_filled_rectangle(xcursor,ycursor,xcursor+((X_TILE_SIZE*SCALE_FACTOR)+(X_TILE_SIZE*SCALE_FACTOR*scale_cursor_x)),ycursor+((Y_TILE_SIZE*SCALE_FACTOR)+(Y_TILE_SIZE*SCALE_FACTOR*scale_cursor_y)),red); al_flip_display(); al_rest(0.1); } memset(buf,0,5); sprintf(buf,"%d",actid); al_set_config_value(cfg,"Objetos","Ultimo",buf); al_save_config_file("sacagraf.cfg",cfg); al_destroy_font(font); al_uninstall_keyboard(); al_destroy_bitmap(bmp); al_destroy_bitmap(virt); al_destroy_display(display); al_destroy_config(cfg); al_shutdown_ttf_addon(); al_shutdown_font_addon(); al_shutdown_image_addon(); al_shutdown_primitives_addon(); free(tmpbuf); return 0; }
Render::~Render() { al_shutdown_font_addon(); } // ~Render()