1 /* 2 This file is part of cave9. 3 4 cave9 is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 cave9 is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with cave9. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef game_h_included 19 #define game_h_included 20 21 #include "score.h" 22 #include "vec.h" 23 #include "args.h" 24 25 #define SECTOR_COUNT 32 26 #define SEGMENT_COUNT 64 27 28 #define ROOM_SPACING 1000 29 #define ROOM_START (2*ROOM_SPACING) 30 #define ROOM_LEN 100.0 31 #define ROOM_MUL 4.0 32 33 typedef struct Ship_struct 34 { 35 float radius; 36 Vec3 pos, vel, lookAt; 37 float roll; 38 bool lefton, righton; 39 float dist; // distance to cave wall 40 Vec3 repulsion; // normal to collision 41 float start; 42 } Ship; 43 44 typedef struct Digger_struct 45 { 46 Ship ship; // parent class 47 48 float x_right_radius; 49 float x_left_radius; 50 float y_top_radius; 51 float y_bottom_radius; 52 } Digger; 53 54 #define SHIP(digger) (&((digger)->ship)) 55 56 typedef struct Cave_struct 57 { 58 Vec3 segs[SEGMENT_COUNT][SECTOR_COUNT]; 59 bool dirty[SEGMENT_COUNT]; 60 Vec3 centers[SEGMENT_COUNT]; 61 int i; // circular array index 62 63 Vec3 monolith_pos; 64 float monolith_yaw; 65 66 enum { 67 STALACT_DISABLED, 68 STALACT_NONE, 69 STALACT_SOME, 70 STALACT_MANY 71 } stalactites_status; 72 } Cave; 73 74 typedef struct Game_struct 75 { 76 Cave cave; 77 Ship player; 78 Digger digger; 79 Score score; 80 81 int caveseed; 82 int start; 83 84 int mode; 85 bool monoliths; 86 } Game; 87 88 enum GameMode 89 { 90 ONE_BUTTON = 1, 91 TWO_BUTTONS = 2 92 }; 93 94 void game_init (Game* game, Args* args); 95 float cave_len (Cave*); 96 void cave_gen (Cave*, Digger* digger); 97 void ship_move (Ship*, float dt); 98 void digger_control (Digger*, int game_mode); 99 void autopilot (Game*, float dt); 100 float collision (Cave*, Ship*); 101 bool game_nocheat(Game *game); 102 int game_score (Game *game); 103 void game_score_update (Game *game); 104 float ship_hit (Ship*); 105 float ship_speed (Ship*); 106 107 extern const char* data_paths[]; 108 #define FIND(f) find_file(f,data_paths,true) 109 110 #define FPS 30 111 #define SEGMENT_LEN 2.0 112 #define SHIP_RADIUS 1.0 113 114 #define GRAVITY 9.8 115 #define THRUST (GRAVITY*2) 116 #define VELOCITY 30.0 117 118 #define MAX_CAVE_RADIUS (SHIP_RADIUS*30) 119 #define MIN_CAVE_RADIUS (SHIP_RADIUS*5) 120 #define MIN_CAVE_RADIUS_DEPTH 10000 121 122 #define WALL_MULT_MIN 1.0 123 #define WALL_MULT_MAX 2.0 124 125 #define MAX_VEL_X GRAVITY 126 #define MAX_VEL_Y (GRAVITY*4) 127 #define MAX_VEL_Z VELOCITY 128 129 #define MONOLITH_DEPTH (1*1) 130 #define MONOLITH_WIDTH (2*2) 131 #define MONOLITH_HEIGHT (3*3) 132 133 #endif 134 135 // vim600:fdm=syntax:fdn=1: 136