NXEngine v1.0.0.6
[NXEngine.git] / game.h
blob7175d7d6f3e2e64cdfb1c977cd13f7e53cf107c8
2 #ifndef _GAME_H
3 #define _GAME_H
5 enum Directions
7 RIGHT = 0,
8 LEFT = 1,
9 UP = 2,
10 DOWN = 3,
11 CENTER = 5
14 #define GAME_FPS 50
16 // for UpdateBlockedStates
17 #define RIGHTMASK 0x01
18 #define LEFTMASK 0x02
19 #define UPMASK 0x04
20 #define DOWNMASK 0x08
21 #define ALLDIRMASK (LEFTMASK | RIGHTMASK | UPMASK | DOWNMASK)
23 // highest addressable flag by tsc scripts etc
24 #define NUM_GAMEFLAGS 8000
26 // switchstage.mapno is set to this to load a game
27 #define MAPNO_SPECIALS 1000
28 #define LOAD_GAME 1000
29 #define NEW_GAME 1001
30 #define NEW_GAME_FROM_MENU 1002 // new game (include Kazuma cutscene)
31 #define LOAD_GAME_FROM_MENU 1003 // load game (from title screen, include weapon slide)
32 #define START_REPLAY 1004
34 // game modes (changes *tickfunction)
35 enum GameModes
37 GM_NONE, // default mode at startup & shutdown
38 GM_NORMAL, // playing the game
39 GM_INVENTORY, // in inventory screen
40 GM_MAP_SYSTEM, // viewing Map System
41 GM_ISLAND, // XX1 good-ending island-crash cutscene
42 GM_CREDITS, // <CRE credits
43 GM_INTRO, // intro
44 GM_TITLE, // title screen
46 GP_PAUSED, // pausemode: Pause (use game.pause())
47 GP_OPTIONS, // pausemode: Options (use game.pause())
49 NUM_GAMEMODES
52 // note: this structure is memsetted at 0 at startup.
53 // ensure it doesn't contain any non-POD types that would be harmed by this.
54 struct Game
56 bool running;
57 bool frozen;
59 int mode;
60 int paused;
62 int curmap;
63 int showmapnametime;
64 int mapname_x;
66 uint32_t counter; // Nikumaru counter value
68 struct
70 bool god;
71 //bool debugmode;
72 bool infinite_damage;
73 bool DrawBoundingBoxes;
74 } debug;
76 // if mapno becomes >= 0 the stage ends and we switch to the new stage
77 struct
79 int mapno;
80 int playerx, playery;
81 int eventonentry;
82 int param;
83 } switchstage;
85 // game flags and skipflags as set by scripts
86 bool flags[NUM_GAMEFLAGS];
87 bool skipflags[NUM_GAMEFLAGS];
89 // earthquake effect; <QUA command
90 int quaketime;
91 int megaquaketime;
93 // stuff for boss bar
94 struct
96 Object *object; // if != NULL, a boss bar is shown displaying this object's remaining health
97 int starting_hp; // HP boss had when <BSL was called
98 bool defeated; // set to true when boss is defeated
99 PercentBar bar;
100 } bossbar;
102 StageBossManager stageboss;
104 // set by enemies in Labyrinth M and by Almond Core to tell
105 // curly where to shoot at (it's like a hint)
106 struct
108 int x, y, timeleft;
109 } curlytarget;
111 int fullscreen;
112 int ffwdtime; // debug option: disables speed-limiting for ffwdtime ticks
114 // ---------------------------------------
116 // static member functions--not private (Game is an object, not a namespace)
117 static bool init();
118 static bool initlevel();
119 static bool createplayer();
121 static void switchmap(int mapno, int scriptno=0, int px=0, int py=0);
122 static void reset();
124 static bool setmode(int newmode, int param=0, bool force=false);
125 static bool pause(int pausemode, int param=0);
126 static void tick();
128 static void close();
131 // NPC flags definitions
132 #define FLAG_SOLID_MUSHY 0x0001 // object blocks player but is a little "mushy" (normal solid state for enemies)
133 #define FLAG_IGNORETILE44 0x0002
134 #define FLAG_INVULNERABLE 0x0004
135 #define FLAG_IGNORE_SOLID 0x0008
136 #define FLAG_BOUNCY 0x0010 // when SOLID_BRICK also set, acts like a mini trampoline
137 #define FLAG_SHOOTABLE 0x0020
138 #define FLAG_SOLID_BRICK 0x0040 // object's entire bbox is rock-solid, just like a solid tile
139 #define FLAG_NOREARTOPATTACK 0x0080
140 #define FLAG_SCRIPTONTOUCH 0x0100
141 #define FLAG_SCRIPTONDEATH 0x0200
142 #define FLAG_DROP_POWERUPS_DONTUSE 0x0400 // not used here because it doesn't seem to be set on some npc.tbl entries which DO in fact spawn powerups; see the nxflag which replaces it
143 #define FLAG_APPEAR_ON_FLAGID 0x0800
144 #define FLAG_FACES_RIGHT 0x1000
145 #define FLAG_SCRIPTONACTIVATE 0x2000
146 #define FLAG_DISAPPEAR_ON_FLAGID 0x4000
147 #define FLAG_SHOW_FLOATTEXT 0x8000
149 // NXEngine flag definitions
150 #define NXFLAG_FOLLOW_SLOPE 0x0001 // enable moving up/down slopes when moving horizontally
151 #define NXFLAG_SLOW_X_WHEN_HURT 0x0002 // move at half X speed when shaking from damage
152 #define NXFLAG_SLOW_Y_WHEN_HURT 0x0004 // move at half Y speed when shaking from damage
153 #define NXFLAG_THUD_ON_RIDING 0x0008 // if set there is a "thud" sound when player lands on it
154 #define NXFLAG_NO_RESET_YINERTIA 0x0010 // don't zero yinertia on blocku/blockd
155 #define NXFLAG_CONSOLE_ANIMATE 0x0020 // spawned at console and is implicit target of subsequent animate commands
157 #define NXFLAG_SLOW_WHEN_HURT (NXFLAG_SLOW_X_WHEN_HURT | NXFLAG_SLOW_Y_WHEN_HURT)
159 extern Game game;
160 extern TextBox textbox;
162 extern Object *onscreen_objects[MAX_OBJECTS];
163 extern int nOnscreenObjects;
165 void debug(const char *fmt, ...);
166 void quake(int quaketime, int snd=-1);
167 void megaquake(int quaketime, int snd=-1);
169 struct Profile;
170 bool game_load(int num);
171 bool game_load(Profile *p);
172 bool game_save(int num);
173 bool game_save(Profile *p);
175 #endif