void bg_draw() { al_set_target_bitmap(bg); std::vector<std::pair<int, int>> newstack; h = h+2.5; if (h > 360) h = 0; v = v - 1.0 / 144.9; if (v <= 0) bg_clear(); for (unsigned int i = 0; i < stack.size(); ++i) { int x = stack[i].first; int y = stack[i].second; float r, g, b; al_color_hsv_to_rgb(h, s, v, &r, &g, &b); al_draw_pixel(x, y, al_map_rgb_f(r,g,b)); if (x != 0 && tab[x - 1][y] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x - 1, y)); } tab[x - 1][y] = 1; } if (x != MAP_SIZE-1 && tab[x + 1][y] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x + 1, y)); } tab[x + 1][y] = 1; } if (y != 0 && tab[x][y-1] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x, y-1)); } tab[x][y-1] = 1; } if (y != MAP_SIZE-1 && tab[x][y+1] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x, y+1)); } tab[x][y+1] = 1; } } stack = newstack; al_set_target_backbuffer(okno); }
int bg_set( const char *filename ) { if( filename && *filename ) { if( bg_texture != bg_clear_texture ) { ogl_free_texture( bg_texture ); } bg_texture = sdl_create_texture( filename ); if( bg_texture == 0 ) { fprintf( stderr, "Warning: couldn't load background image '%s'\n", filename ); return -1; } } else { bg_clear(); } return 0; }
int bg_init( void ) { const struct config *config = config_get(); char filename[CONFIG_FILE_NAME_LENGTH]; if( config->iface.theme.background_image[0] != '\0' ) { location_get_theme_path( config->iface.theme.background_image , filename ); bg_clear_texture = sdl_create_texture( filename ); if( bg_clear_texture == NULL ) { fprintf( stderr, "Warning: couldn't create background texture from '%s'\n", config->iface.theme.background_image ); return -1; } } alpha = 1.0 - (GLfloat)(config->iface.theme.background_transparency)/100; if( config->iface.frame_rate ) angle_step = (GLfloat)config->iface.theme.background_rotation/((GLfloat)config->iface.frame_rate*20); else angle_step = (GLfloat)config->iface.theme.background_rotation/1000; bg_clear(); return 0; }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }