ratcatcher/defs.h

570 lines
14 KiB
C
Raw Normal View History

#ifndef __DEFS_H
#define __DEFS_H
#include <SDL_mixer.h>
/* Macros */
//#define OPENGL
// sound channel numbers
#define CH_LASTCHANNEL 21
#define CH_HURRYUP 20
#define MAXDEATHTEXT 4
#define MAXBIFFTEXT 4
// size of flower straem when getting last flower
// (number of gems on each side)
#define STREAMWID 5
// puff of smoke
#define PUFFFRAMES 6
#define PUFFSPEED 4 // how fast it animates (smaller = faster)
#define PUFFAPPEAR 4 // frame at which puff will turn into a gem
// sparkles
#define SPARKLEFRAMES 7
//#define SPARKLESPEED 3 // how fast it animates (smaller = faster)
// text sizes
#define TEXTSIZE_POINTS 10
#define TEXTSIZE_SCORE 14
#define TEXTSIZE_BONUS 20
#define TEXTSIZE_HELP 20
#define TEXTSIZE_DEATH 20
#define TEXTSIZE_LEVEL2 22
#define TEXTSIZE_BIFF 26
#define TEXTSIZE_LEVEL 32
#define TEXTSIZE_LIFE 36
#define TEXTSIZE_BOMB 36
#define TEXTSIZE_HURRY 50
#define TEXTSIZE_PAUSED 50
#define TEXTSIZE_GAMEOVER 50
// text delays
#define TEXTSPEED 2 // how fast text zooms in
// how long to keep various text on the screen
#define POINTSDELAY 40
#define BONUSDELAY 50
#define HURRYDELAY 50
#define LIFEDELAY 50
#define LEVELWINDELAY 80
#define DIEDELAY 80
#define HELPDELAY 80
#define LEVELDELAY 100
#define GAMEOVERDELAY 200
// Sizes
#define TILEH 16 // tile width (in pixels)
#define TILEW 16 // tile height (in pixels)
#define LEVELW 40 // level width (in tiles)
#define LEVELH 30 // level height (in tiles)
// ice effect
#define ICE_NONE 0
#define ICE_INPROGRESS 1
#define ICE_COMPLETE 2
// Game mechanics
#define INVULNTIME 200 // how long player stays invulnerable for
#define SHIELDTIME 500 // how long a shield lasts
#define FALLSPEED 4 // terminal velocity of falling sprites
#define NETSPEED 9 // how fast the player's net moves
#define POWERUPTIME 15 // # secs before a powerup appears
#define PLAYERFAST 2 // how fast player goes with speed powerup
#define CANNONSIZE 10
#define ICESPEED 2 // how fast a level turns to ice
#define MONJUMPSPEED 5 // how high monsters jump
#define BOMBSHAKETIME 100 // time for screen will shake after a bomb
#define RATSHAKETIME 50 // shake time when king rat is stunned
#define BOSSFLASHTIME 15 // how long bosses flash white for when hit
#define BOSSDIETIME 150 // how long bosses flash when dead
#define BELLTIME 20 // how long the bell flash lasts
#define CLOCKTIME 10 // how many seconds a clock lasts
// king rat
#define KR_WALKTIME 100
#define KR_STUNTIME 150
//#define KR_WALKTIME 30
#define KR_MAXJUMP 15 // max initial jumpspeed
#define KR_NUMJUMPS 5
#define KR_CHARGESPEED 8
// king rat states
#define KRS_WALK 0
#define KRS_JUMP 1
#define KRS_WAITFORTOP 2
#define KRS_FALL 3
#define KRS_CHARGEWAIT 4
#define KRS_CHARGE 5
#define KRS_STUN 6
// bell states
#define BELL_DONESOUND 1
#define BELL_DONEFLASH 2
#define MACEEXPX 2 // X size of mace explosion
#define MACEEXPY 2 // Y size of mace explosion
// Limits
#define MAXLEVELS 100
#define MAXMAPPINGS 50
#define MAXMONSTERSPERLEVEL 40
#define MAXLETTERHEIGHT 100
#define MAXFRAMES 18 // max number of frames for sprites
#define MAXHELP 5
#define MAXTILEFRAMES 10 // max number of frames for animated tiles
// Fixed text buffer sizes
#define BUFLEN 512
#define MIDBUFLEN 64
#define SMALLBUFLEN 32
// Boolean values
#define B_TRUE -1
#define B_FALSE 0
// Other
#define WANTFPS 60 // try to run at this many frames per sec
/* enums */
/* sounds */
#define MAXFX 33
#define FX_SHOOT 0
#define FX_SLAM 1
#define FX_KILL 2
#define FX_MULTIKILL 3
#define FX_JUMP 4
#define FX_FRUIT 5
#define FX_POWERUP 6
#define FX_DIE 7
#define FX_WINLEVEL 8
#define FX_HURRYUP 9
#define FX_TOOSLOW 10
#define FX_BONUS 11
#define FX_MORPH 12
#define FX_BOOM 13
#define FX_SPRING 14
#define FX_TELEPORT 15
#define FX_SPLASH 16
#define FX_MACE 17
#define FX_LIFE 18
#define FX_GAMEOVER 19
#define FX_OW 20
#define FX_BELL 21
#define FX_CLOCK 22
#define FX_ARMOR 23
#define FX_FREEZE 24
#define FX_ICEBREAK 25
#define FX_BOSSWINDUP 26
#define FX_BOSSCHARGE 27
#define FX_BOSSDIE 28
#define FX_BOSSHIT 29
#define FX_BOSSWALL 30
#define FX_SPRAY 31
#define FX_CANNON 32
// Slope types
#define S_NOTSOLID 0
#define S_SOLID 1
#define S_SLOPE 2
// Sprite types
#define MAXPTYPES 49
#define P_PLAYER 0
#define P_RAT 1
#define P_CHEESE 2
#define P_SPEED 3
#define P_NUMNETS 4
#define P_BIGNET 5
#define P_BEE 6
#define P_SPIDER 7
#define P_BLACKCLOUD 8
#define P_ICECREAM 9
#define P_CHIPS 10
#define P_BURGER 11
#define P_SNAKE 12
#define P_SPIT 13
#define P_HELP 14
#define P_FLOWERYELLOW 15
#define P_FLOWERRED 16
#define P_FLOWERPURPLE 17
#define P_COKE 18
#define P_GEMRED 19
#define P_PUFF 20
#define P_GEMYELLOW 21
#define P_GEMPURPLE 22
#define P_POWERUPPOS 23
#define P_BOXING 24 // this is the powerup
#define P_GLOVE 25 // this is the glove on the end of the net
#define P_DIAMOND 26
#define P_FTODIAMOND 27
#define P_FTOGEM 28
#define P_BOMB 29
#define P_SHIELD 30
#define P_MACEPOWERUP 31
#define P_MACE 32
#define P_SMASH 33 // explosion from a mace smash
#define P_HELMET 34 // helmet powerup
#define P_ARMOUR 35 // player wearing armour
#define P_GEMBOOST 36
#define P_TROPHY 37
#define P_RINGSILVER 38
#define P_RINGGOLD 39
#define P_SPARKLE 40
#define P_BELL 41
#define P_CLOCK 42
#define P_SNOWMAN 43
#define P_PINKCLOUD 44
#define P_KINGRAT 45
#define P_SPRAY 46
#define P_CANNONPOWERUP 47
#define P_CANNON 48
// powerups
#define PW_NONE 0
#define PW_BOXING 1 // boxing glove
#define PW_BOMB 2 // bomb
#define PW_MACE 3 // mace
#define PW_RINGWALK 4 // points for walking
#define PW_RINGJUMP 5 // points for jumping
#define PW_CLOCK 6 // freeze time
#define PW_SPRAYUP 7 // fly spray
#define PW_SPRAYDOWN 8 // fly spray
#define PW_CANNON 9 // fusion cannon
#define PW_CANNONFIRE 10 // fusion cannon firing
// "virtual" powerup for bosses
#define PW_RATSHAKE 20 // shake screen horizontally
// Frame names
#define F_WALK1 0
#define F_JUMP 1
#define F_FALL 2
#define F_CAUGHT 3
#define F_DEAD 4
#define F_DEAD2 5
#define F_DEAD3 6
#define F_DEAD4 7
#define F_CLIMB1 8
#define F_CLIMB2 9
#define F_SHOOT 10
2008-09-27 20:50:19 +10:00
#define F_SLAM1 11
#define F_SLAM2 12
#define F_SLAM3 13
#define F_SLAM4 14
#define F_SLAM5 15
#define F_SWIM1 16
#define F_SWIM2 17
// Level states
#define LV_INIT 5 // just loaded, waiting for monsters to appear
#define LV_INPROGRESS 0 // regular game play
#define LV_CLEAR 1 // all monsters dead
#define LV_WAIT 2 // LEVEL COMPLETE displayed, delay to collect fruits
#define LV_FINAL 3 // delay 5 seconds more...
#define LV_CLOUD 4 // cloud appearing and tracking player
#define LV_CLOUDLOOP 6 // cloud looping
#define LV_NEXTLEV 7 // cloud done , nextlevel() in 5 seconds
#define LV_GAMEOVER 8 // No lives left.
// movement types
#define MV_NONE 0 // didn't move
#define MV_WALK 1 // walked/climbed on purpose
#define MV_ICE 3 // slid on ice
// Tile types
#define T_BLANK 0
#define T_LAND 1
#define T_SLOPEUP 2
#define T_SLOPEDOWN 3
#define T_FULL 4
#define T_SKY 5
#define T_LADDER 6
#define T_LADDERTOP 7
#define T_RIGHT 8
#define T_LEFT 9
#define T_SPIKES 10
#define T_TELEPORT 11
#define T_TELEPORT2 12
#define T_TELEPORTDEST 13
#define T_WATER 14
#define T_WATERTOP 15
#define T_WATERSPIKES 16
#define T_BRIDGE 17 // like land but you can drop down through it
#define T_TRAMPUP 18
#define T_TRAMPDOWN 19
#define T_ICETOP 20 // slippery
#define T_ICE 21 // slippery
// death states
#define D_INITIAL (1) // Need to trigger death sequence
#define D_BOUNCING (2) // Corpse is bouncing around the screen
#define D_LASTBOUNCE (3) // Final descent, about to turn to fruit(or respawn for player)
#define D_FINAL (4) // ACTUALLY dead, remove the sprite
/// pink cloud
#define PCGROWSPEED (0.02) // how much to grow each turn (0.1 - 0.999)
#define PCSHRINKSPEED (0.06) // how much to shrink each turn (0.1 - 0.999)
#define PCTURN (5) // turn speed while looping
// teleporting states
#define TP_SHRINKING (1) // entering teleporter
// caught by net states
#define C_NETTING (1) // being pulled in to player
#define C_NETTED (2) // being held by player
// directions
#define D_RIGHT (1)
#define D_LEFT (-1)
#define D_UP (-2)
#define D_DOWN (2)
// boss health bar
#define HEALTHBARY 480-100 // y position of health bar
#define HEALTHBARGAP 2 // gap between health bars
// frames of the bar
#define HEALTHFRAMES 3
#define HF_GREEN 0
#define HF_YELLOW 1
#define HF_RED 2
/* data structures */
typedef struct mapping_s {
char ch;
int tnum;
} mapping_t;
typedef struct tiletype_s {
int uniqid;
int id;
char name[SMALLBUFLEN];
int lowness[TILEW];
int solid;
int water;
int spikes;
SDL_Surface *img[MAXTILEFRAMES];
int numframes;
int animspeed;
struct tiletype_s *next;
struct tiletype_s *prev;
} tiletype_t;
tiletype_t *tiletype;
typedef struct initialmonster_s {
int startx;
int starty;
int id;
char *help;
} initialmonster_t;
typedef struct text_s {
int x,y;
int size;
int maxsize;
int state;
int delay; // how long to stay on screen
char txt[BUFLEN];
SDL_Rect bgarea;
SDL_Surface *bg;
SDL_Surface *img;
SDL_Color *c;
struct text_s *next;
struct text_s *prev;
} text_t;
typedef struct level_s {
int id;
int bgtileid;
char bgfile[MIDBUFLEN];
char name[MIDBUFLEN];
char filename[MIDBUFLEN];
int map[LEVELW*LEVELH];
int map2[LEVELW*LEVELH]; // second map layer
int tileframe[LEVELW*LEVELH]; // tracks frame numbers for tiles
int *animtiles; // array of offsets to map positions which are animated
struct level_s *next;
struct level_s *prev;
int p1x; /* player 1 start pos */
int p1y;
int powerupx; /* powerup position */
int powerupy; /* powerup position */
int gotpowerup; /* has the random powerup appeared yet? */
int poweruptype;/* what kind of powerup will appear? */
int exitdir; /* which way to scroll on level completion */
int nummonsters;
initialmonster_t initm[MAXMONSTERSPERLEVEL];
int hurryuptime;
int poweruptime;
int icey,iced; // for ice powerups
} level_t;
level_t *level;
typedef struct levelentry_s {
int id;
char filename[MIDBUFLEN];
char desc[MIDBUFLEN];
} levelentry_t;
typedef struct sprite_s {
int id; // what kind of sprite? (eg. player, cheese, rat)
int score; // player's score, for monsters how much they are worth
// ATTRIBUTES
double speed; // how fast this sprite moves
// CURRENT STATE
// player only
int recoiling; // this happens after you get hit while wearing armour
int slamming; // are we slamming our net (player only)
double slamangle;// are what point around is our net?
int netting; // are we shooting our net out?
int climbing; // are we climbing a laddder
int invuln; // are we invulnerable (ie. just after player respawning)
int netcaught; // how many monsters are in our net?
int netmax; // how many monsters can our net hold?
int netspeed; // how fast does our net shoot out?
int netdir; // which way is our net going (left/right)
int netlen; // how far our is our net?
int nety; // y position of end of net (used when shooting >1 net)
int netxstart; // x position of start of net
int netystart; // y position of start of net
int powerup; // what temp powerup does the player have?
int ontramp; // on a trampoline?
int trampx; // x,y coords for trampoline we are/were on
int trampy; //
// player permenant powerups
int armour; // does the player have armour?
int gemboost; // how many extra gems do you get in a bonus
int netbig; // have we collected a BIG NET powerup?
int hasbell; // got a bell ?
// monster only
int iced; // turned to ice?
SDL_Surface *iceimg; // Image to blit for ice
int willbecome; // what fruit this will become when dead
int angry; // is this sprite in ANGRY mode for its AI?
// normally this is a bool, but for monsters we
// it for flashing them when they are hit. in this
// case it will be a number.
struct sprite_s *caughtby; // who has us in their net? NULL if nobody
int quickdie; // die without bouncing?
int caughtstate; // are we caught by a net? being pulled in or caught?
int jumptimer; // delay before we will jump
int willjumpspeed; // how fast we'll jump when jumptimer expires
int flies; // can we fly?
double xs,ys; // bounce direction after death
struct sprite_s *bullet; // pointer to our bullet
struct sprite_s *owner; // if we ARE a bullet, pointer to the sprite who made us
char name[MIDBUFLEN]; // Help text for help icons, otherwise not really used outside of debugging
// pinkcloud only
double size;
double rotated;
double angle;
// player and monster
int lives; // only for player and bosses
int swimming; // are we in the water?
int falling; // are we falling?
int dropping; // are we purposely dropping through solid ground?
int dropx,dropy;// coords of tile we dropped from
int fallspeed; // how fast are we falling?
int jumping; // are we jumping?
int jumpdir; //which way are we jumping?
int jumpspeed; // how fast we are moving upwards
int teleporting;// are we inside a teleporter? >0 is entering, <0 is exitting
int dead; // is this sprite dead? if so, what dying state?
int bounces; // how many time have we bounced after dying
int doomcount; // sprites dies when this reaches zero
int moved; // did we move this loop cycle?
int timer1; //
int timer2; //
int timer3; //
// GAME MECHANICS
double x,y; // current position
int dir; // which way we are facing (1=right,-1=left)
SDL_Surface *img; // current graphic image
SDL_Surface *netbg; // temp storage for area behind net
// LINKED LIST STUFF
struct sprite_s *next;
struct sprite_s *prev;
} sprite_t;
typedef struct imageset_s {
SDL_Surface *img[MAXFRAMES*4];
int numimages;
} imageset_t;
imageset_t imageset[MAXPTYPES];
/* external globals */
extern SDL_Color black;
extern SDL_Surface *screen, *temps, *levelbg, *head, *headsmall, *icecube;
extern SDL_Surface *healthbar[];
extern SDL_Surface *greenbox;
extern sprite_t *sprite, *lastsprite, *player, *boss;
extern level_t *curlevel;
extern tiletype_t fakeblock;
extern int gtime;
extern int timer;
extern SDL_Color red;
extern SDL_Color black;
extern SDL_Color blue;
extern SDL_Color white;
extern SDL_Color green;
extern SDL_Color yellow;
extern int vidargs;
extern int toggletimer;
extern TTF_Font *font[];
extern int musicplaying;
extern Mix_Music *music, *normalmusic, *fastmusic;
extern Mix_Chunk *sfx[];
extern int oldexitdir;
extern int levelcomplete;
extern text_t *text, *lasttext;
extern int cheat;
extern int nexthurryup;
extern levelentry_t levelentry[];
extern int numlevels;
extern int maxlevid;
extern char *deathtext[];
extern char *bifftext[];
#endif