#include #define TEXTSPEED 2 #define TEXTDELAY 40 #define NETSPEED 9 #define MAXMONSTERSPERLEVEL 20 #define MAXLETTERHEIGHT 100 #define MAXPTYPES 3 #define MAXFRAMES 8 #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 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; 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]; } level_t; level_t *level; typedef struct sprite_s { int id; double speed; int falling; int fallspeed; int jumping; int jumpdir; int dead; int bounces; struct sprite_s *caughtby; int caughtstate; int jumpspeed; int slamming; double slamangle; int netting; int netcaught; int netmax; int netspeed; int netdir; int netlen; int nety; int netxstart; int netystart; int moved; 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); void drawtext(void); void movetext(void); void killtext(text_t *t); 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(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 ismonster(int id); void killsprite(sprite_t *s); void checkcollide(sprite_t *s); double getspeed(int id); void adjustheight(sprite_t *s); #define S_NOTSOLID 0 #define S_SOLID 1 #define S_SLOPE 2 #define P_PLAYER 0 #define P_RAT 1 #define P_CHEESE 2 #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 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 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);