static int tst_RIS(MENU_ARGS) { vt_move(1,1); println(the_title); println("(VT100 & up, not recommended)"); println(""); printf ("The terminal will now be RESET. "); holdit(); ris(); zleep(5000); /* Wait 5.0 seconds */ did_reset = TRUE; reset_level(); input_8bits = FALSE; output_8bits = FALSE; return MENU_HOLD; }
void reset_game_state(void) { extern int last_highscore; SDL_ShowCursor(SDL_DISABLE); last_highscore = -1; gc.score = 0; gc.ships_left = 2; gc.level_tics = 0; gc.multiplier = 1; gc.cur_level = settings.static_settings->start_level; ship.is_alive = 0; gc.tics_remaining = 0; /* last_death_tic = -70; */ memset(&game_stat_counters, 0, sizeof(game_stat_counters)); ships_text_width = string_width_in_pixels(font_small, "ships"); reset_level(); reset_eye(); reset_water(); reset_background(); reset_arena(); reset_particles(); reset_explosions(); reset_missiles(); reset_bombs(); reset_lasers(); reset_foes(); reset_powerups(); reset_in_game_texts(); reset_ship_powerups(); set_inner_state(IS_WAVE_TITLE); play_music(MUS_STAGE_1); }
int main( int argc, const char** argv ) { std::signal(SIGINT, aqsisSignalHandler); std::signal(SIGABRT, aqsisSignalHandler); RtInt returnCode = 0; StartMemoryDebugging(); { ArgParse ap; ap.usageHeader( ArgParse::apstring( "Aqsis command line renderer\nUsage: " ) + argv[ 0 ] + " [options] [RIB file...]" ); ap.argFlag( "help", "\aPrint this help and exit", &g_cl_help ); ap.alias( "help" , "h" ); ap.argFlag( "version", "\aPrint version information and exit", &g_cl_version ); ap.argFlag( "pause", "\aWait for a keypress on completion", &g_cl_pause ); ap.argFlag( "progress", "\aPrint progress information", &g_cl_progress ); ap.argFlag( "Progress", "\aPrint PRMan-compatible progress information (ignores -progressformat)", &g_cl_Progress ); ap.argString( "progressformat", "=string\aprintf-style format string for -progress", &g_cl_strprogress ); ap.argInt( "endofframe", "=integer\aEquivalent to \"endofframe\" RIB option", &g_cl_endofframe ); ap.argInt( "verbose", "=integer\aSet log output level\n" "\a0 = errors\n" "\a1 = warnings (default)\n" "\a2 = information\n" "\a3 = debug", &g_cl_verbose ); ap.alias( "verbose", "v" ); ap.argFlag( "echoapi", "\aEcho all RI API calls to the log output (experimental)", &g_cl_echoapi); ap.argInt( "priority", "=integer\aControl the priority class of aqsis.\n" "\a0 = idle\n" "\a1 = normal\n" "\a2 = high\n" "\a3 = RT", &g_cl_priority); ap.alias( "priority", "z"); ap.argString( "type", "=string\aSpecify a display device type to use", &g_cl_type ); ap.argString( "addtype", "=string\aSpecify a display device type to add", &g_cl_addtype ); ap.argString( "mode", "=string\aSpecify a display device mode to use", &g_cl_mode ); ap.argFlag( "fb", "\aSame as --type=\"framebuffer\" --mode=\"rgb\"", &g_cl_fb ); ap.alias( "fb", "d" ); ap.argFloats( "crop", " x1 x2 y1 y2\aSpecify a crop window, values are in screen space.", &g_cl_cropWindow, ArgParse::SEP_ARGV, 4); ap.argFlag( "nocolor", "\aDisable colored output", &g_cl_no_color ); ap.argFlag( "beep", "\aBeep on completion of all ribs", &g_cl_beep ); ap.alias( "nocolor", "nc" ); ap.argInts( "res", " x y\aSpecify the resolution of the render.", &g_cl_res, ArgParse::SEP_ARGV, 2); ap.argStrings( "option", "=string\aA valid RIB Option string, can be specified multiple times.", &g_cl_options); # ifdef AQSIS_SYSTEM_POSIX ap.argFlag( "syslog", "\aLog messages to syslog", &g_cl_syslog ); # endif // AQSIS_SYSTEM_POSIX # if ENABLE_MPDUMP ap.argFlag( "mpdump", "\aOutput MP list to a custom 'dump' file", &g_cl_mpdump ); # endif // ENABLE_MPDUMP ap.argString( "shaders", "=string\aOverride the default shader searchpath(s)", &g_cl_shader_path ); ap.argString( "archives", "=string\aOverride the default archive searchpath(s)", &g_cl_archive_path ); ap.argString( "textures", "=string\aOverride the default texture searchpath(s)", &g_cl_texture_path ); ap.argString( "displays", "=string\aOverride the default display searchpath(s)", &g_cl_display_path ); ap.argString( "procedurals", "=string\aOverride the default procedural searchpath(s)", &g_cl_procedural_path ); ap.allowUnrecognizedOptions(); if ( argc > 1 && !ap.parse( argc - 1, argv + 1 ) ) { Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg(); return( 1 ); } // Check that the number of arguments to crop are valid if specified. if ( g_cl_cropWindow.size() > 0 && g_cl_cropWindow.size() != 4 ) { Aqsis::log() << Aqsis::error << "Invalid number of arguments to -crop, expected 4, got " << g_cl_cropWindow.size() << std::endl; g_cl_help = true; } if ( g_cl_help ) { std::cout << ap.usagemsg(); return( 0 ); } if ( g_cl_version ) { std::cout << "aqsis version " << AQSIS_VERSION_STR_FULL # ifdef _DEBUG << " (debug build)" # endif << "\n" << "compiled " << __DATE__ << " " << __TIME__ << "\n"; return( 0 ); } # ifdef AQSIS_SYSTEM_WIN32 std::auto_ptr<std::streambuf> ansi( new Aqsis::ansi_buf(Aqsis::log()) ); # endif std::auto_ptr<std::streambuf> reset_level( new Aqsis::reset_level_buf(Aqsis::log()) ); std::auto_ptr<std::streambuf> show_timestamps( new Aqsis::timestamp_buf(Aqsis::log()) ); std::auto_ptr<std::streambuf> fold_duplicates( new Aqsis::fold_duplicates_buf(Aqsis::log()) ); std::auto_ptr<std::streambuf> color_level; if(!g_cl_no_color) { std::auto_ptr<std::streambuf> temp_color_level( new Aqsis::color_level_buf(Aqsis::log()) ); color_level = temp_color_level; } std::auto_ptr<std::streambuf> show_level( new Aqsis::show_level_buf(Aqsis::log()) ); Aqsis::log_level_t level = Aqsis::ERROR; if( g_cl_verbose > 0 ) level = Aqsis::WARNING; if( g_cl_verbose > 1 ) level = Aqsis::INFO; if( g_cl_verbose > 2 ) level = Aqsis::DEBUG; std::auto_ptr<std::streambuf> filter_level( new Aqsis::filter_by_level_buf(level, Aqsis::log()) ); # ifdef AQSIS_SYSTEM_POSIX if( g_cl_syslog ) std::auto_ptr<std::streambuf> use_syslog( new Aqsis::syslog_buf(Aqsis::log()) ); # endif // AQSIS_SYSTEM_POSIX if (g_cl_priority != 1) { // Set the priority on the main thread setPriority(g_cl_priority); } RiBegin(RI_NULL); setupOptions(); try { if ( ap.leftovers().size() == 0 ) { // If no files specified, take input from stdin. // // TODO: We'd like to turn off stdio synchronisation to allow fast // buffering... unfortunately this causes very odd problems with // the aqsis logging facility as of svn r2804 // //std::ios_base::sync_with_stdio(false); Aqsis::QGetRenderContextI()->parseRibStream(std::cin, "stdin"); } else { for(ArgParse::apstringvec::const_iterator fileName = ap.leftovers().begin(); fileName != ap.leftovers().end(); fileName++) { std::ifstream inFile(fileName->c_str()); if(inFile) { Aqsis::QGetRenderContextI()->parseRibStream(inFile, *fileName); returnCode = RiLastError; } else { Aqsis::log() << Aqsis::error << "Cannot open file \"" << *fileName << "\"\n"; returnCode = RIE_NOFILE; } } } } catch(const std::exception& e) { Aqsis::log() << Aqsis::error << e.what() << std::endl; returnCode = RIE_BUG; } catch(...) { Aqsis::log() << Aqsis::error << "unknown exception has been encountered\n"; returnCode = RIE_BUG; } RiEnd(); } StopMemoryDebugging(); if(g_cl_beep) std::cout << "\a" << std::ends; if(g_cl_pause) { std::cout << "Press any key..." << std::ends; std::cin.ignore(std::cin.rdbuf()->in_avail() + 1); } return returnCode; }
static void update_inner_state(void) { static int prev_level_tics; inner_state.tics++; switch (inner_state.state) { case IS_WAVE_TITLE: if (inner_state.tics >= WAVE_TITLE_TICS) { set_inner_state(IS_IN_GAME); /* set_inner_state(IS_PRE_WAVE_CLEARED); */ } else { if (inner_state.tics == WAVE_TITLE_TICS/2) { if (!ship.is_alive) spawn_new_ship(); else reset_ship(); } } break; case IS_IN_GAME: level_stat_counters.tics++; game_stat_counters.tics++; if (gc.tics_remaining <= 0) { /* boom. */ hit_ship(&ship.pos, 1.f); trigger_game_over(); } else { gc.tics_remaining--; if (!ship.is_alive) { prev_level_tics = inner_state.tics; set_inner_state(IS_RESPAWNING_SHIP); } else if (!gc.foes_left) { level_stat_counters.waves++; game_stat_counters.waves++; if (gc.tics_remaining > TIME_BONUS_MIN_TICS) gc.score += gc.tics_remaining*TIME_BONUS_PER_TIC; set_inner_state(IS_PRE_WAVE_CLEARED); } else { spawn_new_foes(); } } break; case IS_PRE_WAVE_CLEARED: if (inner_state.tics >= PRE_WAVE_CLEARED_TICS) { gen_ship_implosion(); reset_powerups(); reset_missiles(); reset_bombs(); reset_lasers(); vec2_set(&ship.pos, 0.f, 0.f); /* HACK */ play_fx(FX_WAVE_TRANSITION); set_inner_state(IS_WAVE_CLEARED); } break; case IS_RESPAWNING_SHIP: if (inner_state.tics >= TICS_UNTIL_RESPAWN) { if (gc.ships_left) { spawn_new_ship(); set_inner_state(IS_IN_GAME); inner_state.tics = prev_level_tics; } else { trigger_game_over(); } } break; case IS_GAME_OVER: break; case IS_RANK: if (inner_state.tics >= RANK_TOTAL_TICS) { stop_music(); if (is_highscore(gc.score)) { set_inner_state(IS_HIGHSCORE_INPUT); SDL_ShowCursor(SDL_ENABLE); start_highscore_input(); } else { /* loser. */ SDL_ShowCursor(SDL_ENABLE); start_main_menu(); } } break; case IS_WAVE_CLEARED: if (gc.cur_wave == levels[gc.cur_level]->num_waves - 1 && inner_state.tics >= WAVE_CLEARED_TICS/2) { initialize_stats_table(&level_stat_counters); set_inner_state(IS_LEVEL_CLEARED); } else if (inner_state.tics >= WAVE_CLEARED_TICS) { gc.cur_wave++; assert(gc.cur_wave < levels[gc.cur_level]->num_waves); reset_wave(); set_inner_state(IS_WAVE_TITLE); } break; case IS_HIGHSCORE_INPUT: break; case IS_LEVEL_CLEARED: break; case IS_LEVEL_TRANSITION: if (inner_state.tics >= LEVEL_TRANSITION_TOTAL_TICS) { gc.cur_level = (gc.cur_level + 1)%NUM_LEVELS; set_inner_state(IS_WAVE_TITLE); reset_level(); } break; default: assert(0); } }
void init_level() { reset_level(1); }