ratcatcher/rc.h

228 lines
4.1 KiB
C

#include <SDL_image.h>
#define INVULNTIME 200
#define WANTFPS 75
#define TEXTSPEED 2
#define TEXTDELAY 40
#define NETSPEED 9
#define MAXMAPPINGS 50
#define MAXMONSTERSPERLEVEL 20
#define MAXLETTERHEIGHT 100
#define MAXFRAMES 10
#define TILEH 16
#define TILEW 16
#define LEVELW 40
#define LEVELH 30
#define BUFLEN 512
#define SMALLBUFLEN 32
#define FALLSPEED 4
#define B_TRUE -1
#define B_FALSE 0
#define S_NOTSOLID 0
#define S_SOLID 1
#define S_SLOPE 2
#define MAXPTYPES 9
#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_CLOUD 8
#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 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
typedef struct mapping_s {
char ch;
int tnum;
} mapping_t;
typedef struct tiletype_s {
int id;
char name[SMALLBUFLEN];
int lowness[TILEW];
int solid;
SDL_Surface *img;
struct tiletype_s *next;
struct tiletype_s *prev;
} tiletype_t;
tiletype_t *tiletype;
typedef struct initialmonster_s {
int startx;
int starty;
int id;
} initialmonster_t;
typedef struct text_s {
int x,y;
int size;
int maxsize;
int state;
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 name[SMALLBUFLEN];
int map[LEVELW*LEVELH];
struct level_s *next;
struct level_s *prev;
int p1x; /* player 1 start pos */
int p1y;
int nummonsters;
initialmonster_t initm[MAXMONSTERSPERLEVEL];
int hurryuptime;
} level_t;
level_t *level;
typedef struct sprite_s {
int id;
double speed;
int score;
int falling;
int fallspeed;
int jumping;
int jumpdir;
int angry;
int dead;
int invuln;
int bounces;
struct sprite_s *caughtby;
int caughtstate;
int jumpspeed;
int climbing;
int slamming;
double slamangle;
int netting;
int netcaught;
int netmax;
int netspeed;
int netdir;
int netlen;
int netbig;
int nety;
int netxstart;
int netystart;
int timer;
int moved;
int flies;
double xs,ys;
double x,y;
int dir;
SDL_Surface *img;
SDL_Surface *netbg;
struct sprite_s *next;
struct sprite_s *prev;
char name[SMALLBUFLEN];
} sprite_t;
typedef struct imageset_s {
SDL_Surface *img[MAXFRAMES*2];
int numimages;
} imageset_t;
imageset_t imageset[MAXPTYPES];
void cleanup(void);
int addtext(int x, int y, int size, char *string, SDL_Color *c);
void drawscore(void);
void drawtext(void);
void movetext(void);
void killtext(text_t *t);
void removeall(void);
void removetext(void);
int addsprite(int id,int x, int y, char *name);
int loadtiletypes(char *filename);
tiletype_t *gettileat(int pixx,int pixy, int *tilex, int *tiley);
int loadlevel(int lnum);
int loadsprites(void);
int loadimagesets(void);
void drawlevel(void);
void drawtile(SDL_Surface *s, int x, int y);
void removesprite(sprite_t *s);
void removenetting(sprite_t *s);
void drawsprite(sprite_t *s);
void drawnetting(sprite_t *s);
void dogravity(sprite_t *s);
void dotileeffects(sprite_t *s);
int movex(sprite_t *s,double amt);
void movesprite(sprite_t *s);
int isonground(sprite_t *s);
int isongroundpoint(sprite_t *s, int x, int y);
int isonladder(sprite_t *s);
int isladderabove(sprite_t *s);
int isfruit(int id);
int dofruiteffect(sprite_t *s);
int ismonster(int id);
void killsprite(sprite_t *s);
void checkcollide(sprite_t *s);
void die(sprite_t *s);
void nextlevel(void);
void jump(sprite_t *s, int dir);
double getspeed(sprite_t *s );
void adjustheight(sprite_t *s);
void setdefaults(sprite_t *s);
void tick(void);
inline void drawpixel16(SDL_Surface *screen, int x, int y, SDL_Color c);
inline void drawbox16(SDL_Surface *screen, int x1,int y1,int x2,int y2,SDL_Color *c,SDL_Color *fc);
void drawline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c);