void gui_update_jetpack(var _percentage) { if (panJetpack != NULL) { if (flying_man) { panJetpack.size_y = bmap_height(bmapJetpackColor) - (bmap_height(bmapJetpackColor) / 100 * _percentage); set(panJetpack, SHOW); set(panJetpackBorder, SHOW); } else { reset(panJetpack, SHOW); reset(panJetpackBorder, SHOW); } } }
/** * Calculates the normalization and scaling parameters of a uniformly scaled image * * bmapImg * The image * * refNormX & -Y * Double pointers, which receive the normalization factors for non-power-of-2 images * * refScaleX & -Y * Double pointers, which receive the scaling factors for making the image fit the * screen while being uniformly scaled */ void ppImageCalcScaling (BMAP* bmapImg, double* refNormX, double* refNormY, double* refScaleX, double* refScaleY) { if (bmapImg == NULL) return; double w = bmap_width(bmapImg); double h = bmap_height(bmapImg); // normalization factor for non-power-of-2 images *refNormX = w / ppTrinary(bmapImg->finalwidth < 1, 1, bmapImg->finalwidth+2); *refNormY = h / ppTrinary(bmapImg->finalheight < 1, 1, bmapImg->finalheight+2); // bitmap- and screen aspect ratio double bmapAspect = w / h; double screenAspect = (double)screen_size.x / (double)screen_size.y; // the aspect ratios are compared to determine if the image is relatively wider or // taller than the screen. If the image is taller, it will be fitted on the x-axis and // will be centered on the y-axis; and vice versa. if (bmapAspect < screenAspect) // taller { *refScaleX = 1; *refScaleY = bmapAspect / screenAspect; } else // wider { *refScaleX = screenAspect / bmapAspect; *refScaleY = 1; } }
void game_hotkeys() { panMute = pan_create("", 200); panMute.bmap = bmapMute; while(1) { if (key_f9) { while(key_f9) wait(1); // Reposition because of possible resolution change panMute.pos_x = screen_size.x - bmap_width(bmapMute) - 10; panMute.pos_y = screen_size.y - bmap_height(bmapMute) - 10; if ((master_vol == -1) || (master_vol > 0)) { set(panMute, SHOW); master_vol = 0; } else { reset(panMute, SHOW); master_vol = 100; } } wait(1); } }
void gameOver() { isGameOver = 1; endIngameGUI(); ent_remove(player); panGameOver.pos_x = screen_size.x / 2 - bmap_width(bmapGameOver) / 2; panGameOver.pos_y = screen_size.y / 2 - bmap_height(bmapGameOver) / 2; set(panGameOver, SHOW); vec_set(vecCamTmp, entHut.x); int counter = 1000; while(counter > 0) { cam_angle +=0.005 * time_step; camera.x = cos(cam_angle) * 768; camera.y = sin(cam_angle) * 768; vec_diff(vecCamTmp.x, nullvector, camera.x); vec_to_angle(camera.pan, vecCamTmp); counter--; wait(1); } reset(panGameOver, SHOW); isGameOver = 2; //backToMenu(); }
/* * int main(int argc, char **argl) * * GiN entry point. Initialize variables, structs, video devices, parsing * configuration files, setting up parameters, booting up subsystems, * and handling the main game loop, as well as cleaning up. */ int main(int argc, char **argl) { const char *__err_launcher = "Please run the game through the launcher!"; const char *__err_language = "Language list cannot be found! Run generate_language_list.exe to let the language definition be generated once."; const char *__wrn_lowres = "The game requires a monitor with a resolution of at least 1,024 x 768. The game will still run, but certain GUI elements won't be displayed correctly."; const char *__wrn_lowram = "You need at least 3 GB RAM in order to play the game. If you're having less than 3 GB RAM, clicking \"OK\" will force the game to run, but it may causes unexpected issues. If you want to quit now, open Task Manager and close the game process.\n\nSorry for the inconvenience."; const char *__wrn_redist = "One or more required DLLs for music playback cannot be found.\n\nOn Steam, try verifying game files and make sure you've installed the redistributable files before launching the game.\n\nitch.io users can launch the game through Launcher.bat."; // See if the game was launched through the Go-based launcher. #ifndef DEBUG // ASSERT(game_locker_check() != 0, __err_launcher); #endif if( sys_metrics(0) < 1024.0 && sys_metrics(1) < 768.0 ) printf(__wrn_lowres); if( os_get_ram(S_MB) < 3072 ) printf(__wrn_lowram); String *temp = ""; str_cat(temp, os_get_system_directory()); str_cat(temp, "ogg.dll"); if( !file_exists(temp) ) { printf(__wrn_redist); } #ifndef DEBUG ASSERT(file_exists("./translation/__language.pad") != 0, __err_language); #else if( !file_exists("./translation/__language.pad") ) { printf(__err_language); sys_exit((void *) 0); } #endif // Overrides some of the global variables (their default values are way too low) game_globals_set(); // mouse_lock(true); // Wait for the video device. while( !ready() ) wait(1.0); // After the video device is initialized, parse the video configuration file // and apply video settings to the current video device, and set the new game title. game_video_cfg_parse(); game_title_set(); // Exports the game version to the game folder. This is used by the external launcher // which uses the file for updating purposes. The completed, released version should // have a versioning file ready already. __game_version_export(); // Pops up the GUI to let the user chooses their desired language. // After that, a call to nov_region_init() will be invoked to pick the chosen language and perform string initialization. nov_region_init("en"); // Initializes subsystems (game state, GUI, PhysX, ...) nov_modules_init(); // Static initialization. nov_gui_static_init(); // Initializes the scene list, the scenes, and push them into the list. nov_scene_list_init(); game_gui_set_state(STATE_INTRO); game_gui_render(); Vector3 tx; tx.x = screen_size.x - 150.0; tx.y = 15.0; tx.z = 0; Text *todo = txt_create(1, LAYER_DEBUG_1); todo->font = font_create("UVN remind#30b"); gui_text_set_color(todo, COLOR_DARK_GREY); gui_text_set_pos(todo, __GUIState_singleton->todo_texture->pos_x + 10.0, __GUIState_singleton->todo_texture->pos_y + 10.0); gui_text_set_pos(txtSubtitleHandler, (screen_size.x / 2.0) - 156.0, __GUIState_singleton->todo_texture->pos_y + bmap_height(__GUIState_singleton->todo_texture->bmap) + 25.0); // Main game loop, which can be terminated with the "Alt + F4" key. while(!(__GameState_singleton->exit_switch)) { __GameState_singleton->exit_switch = key_alt && key_f4; // Updates PhysX. game_physx_loop(); // Updates the GUI state. game_gui_update(); // Continuously update the area the player is currently in. #ifndef UI_LESS if( STATE_NULL == game_gui_get_state() && game_intro_done ) // Because draw_*() functions don't take layers into account, // I have to rely a lot on GUI states in order to manage rendering orders of GUI objects. { draw_text(game_region_check(), tx.x, tx.y, COLOR_WHITE); } #endif // Updates FOV. if( NULL != camera ) { if( !var_cmp(fov, camera->arc) ) camera->arc = fov; } // Updates the global volume. if( !var_cmp(volume, game_volume) ) game_volume = volume; // Updates the mouse sensivity. mickey.x *= sensivity_mul; mickey.y *= sensivity_mul; if( key_f1 ) { while ( key_f1 ) wait(1.0); switch( __invert_y ) { case 1: __invert_y = -1; break; case -1: __invert_y = 1; } } if( key_tab && (STATE_NULL == game_gui_get_state()) ) { switch ( game_day_get() ) { case DAY_3: case DAY_4: case DAY_5: case DAY_6: { if( (todo->pstring)[0] != lstr_todo_c3 ) (todo->pstring)[0] = lstr_todo_c3; break; } case DAY_1: { draw_obj( __GUIState_singleton->todo_texture ); if( (todo->pstring)[0] != lstr_todo_c1 ) (todo->pstring)[0] = lstr_todo_c1; break; } case DAY_2: { draw_obj( __GUIState_singleton->todo_texture ); if( (todo->pstring)[0] != lstr_todo_c2 ) (todo->pstring)[0] = lstr_todo_c2; } } draw_obj( todo ); } if( key_esc && __can_press_esc && (game_gui_get_state() != STATE_ENDING) ) { while(key_esc) wait(1.0); wait(1.0); __GameState_singleton->menu_switch = 1 - __GameState_singleton->menu_switch; switch(__GameState_singleton->menu_switch) { case 1: game_gui_set_state(STATE_MAIN_MENU); game_gui_render(); break; case 0: game_gui_set_state(STATE_NULL); game_gui_render(); } } wait(1.0); } RETURN(0); }