1 /* 2 * This software is licensed under the terms of the MIT License. 3 * See COPYING for further information. 4 * --- 5 * Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>. 6 * Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>. 7 */ 8 9 #ifndef IGUARD_global_h 10 #define IGUARD_global_h 11 12 #include "taisei.h" 13 14 #include <SDL.h> 15 #include <SDL_platform.h> 16 17 #include "util.h" 18 #include "color.h" 19 20 #include "resource/sfx.h" 21 #include "resource/bgm.h" 22 #include "resource/font.h" 23 #include "resource/animation.h" 24 25 #include "menu/menu.h" 26 27 #include "player.h" 28 #include "projectile.h" 29 #include "enemy.h" 30 #include "item.h" 31 #include "boss.h" 32 #include "laser.h" 33 #include "dialog.h" 34 #include "list.h" 35 #include "refs.h" 36 #include "config.h" 37 #include "resource/resource.h" 38 #include "replay.h" 39 #include "random.h" 40 #include "events.h" 41 #include "difficulty.h" 42 #include "color.h" 43 #include "audio/audio.h" 44 #include "rwops/all.h" 45 #include "cli.h" 46 #include "hirestime.h" 47 #include "log.h" 48 #include "framerate.h" 49 #include "renderer/api.h" 50 51 enum { 52 // defaults 53 #ifdef __SWITCH__ 54 RESX = 1280, 55 RESY = 720, 56 #else 57 RESX = 800, 58 RESY = 600, 59 #endif 60 61 VIEWPORT_X = 40, 62 VIEWPORT_Y = 20, 63 VIEWPORT_W = 480, 64 VIEWPORT_H = 560, 65 66 MAX_CONTINUES = 3, 67 68 EVENT_DEATH = -8999, 69 EVENT_BIRTH, 70 EVENT_KILLED, 71 ACTION_DESTROY, 72 ACTION_ACK, 73 ACTION_NONE, 74 75 FPS = 60, 76 77 GAMEOVER_SCORE_DELAY = 60, 78 }; 79 80 #define VIEWPORT_OFFSET { VIEWPORT_X, VIEWPORT_Y } 81 #define VIEWPORT_SIZE { VIEWPORT_W, VIEWPORT_H } 82 #define VIEWPORT_RECT { VIEWPORT_X, VIEWPORT_Y, VIEWPORT_W, VIEWPORT_H } 83 84 typedef enum GameoverType { 85 GAMEOVER_NONE, 86 GAMEOVER_DEFEAT = 1, 87 GAMEOVER_WIN, 88 GAMEOVER_ABORT, 89 GAMEOVER_RESTART, 90 GAMEOVER_SCORESCREEN = -1, 91 GAMEOVER_TRANSITIONING = -2, 92 } GameoverType; 93 94 typedef struct { 95 int8_t diff; // this holds values of type Difficulty, but should be signed to prevent obscure overflow errors 96 Player plr; 97 98 ProjectileList projs; 99 ProjectileList particles; 100 EnemyList enemies; 101 ItemList items; 102 LaserList lasers; 103 104 int frames; // stage global timer 105 int timer; // stage event timer (freezes on bosses, dialogs, etc.) 106 int stage_start_frame; 107 108 int frameskip; 109 110 Boss *boss; 111 Dialog *dialog; 112 113 RefArray refs; 114 115 GameoverType gameover; 116 int gameover_time; 117 118 struct { 119 FPSCounter logic; 120 FPSCounter render; 121 FPSCounter busy; 122 } fps; 123 124 Replay replay; 125 ReplayMode replaymode; 126 ReplayStage *replay_stage; 127 128 float shake_view; 129 float shake_view_fade; 130 131 uint voltage_threshold; 132 133 RandomState rand_game; 134 RandomState rand_visual; 135 136 StageInfo *stage; 137 138 uint is_practice_mode : 1; 139 uint is_headless : 1; 140 uint is_replay_verification : 1; 141 } Global; 142 143 extern Global global; 144 145 void init_global(CLIAction *cli); 146 147 void taisei_quit(void); 148 bool taisei_quit_requested(void); 149 void taisei_commit_persistent_data(void); 150 151 // XXX: Move this somewhere? 152 bool gamekeypressed(KeyIndex key); 153 154 #endif // IGUARD_global_h 155