Recent additions...

This commit is contained in:
Rob Pearce 2008-10-14 19:36:51 +00:00
parent dd7bf8738c
commit b32043b53f
12 changed files with 435 additions and 17 deletions

View File

@ -3,7 +3,7 @@ LIBS = libs/libSDL-1.2.0.dylib libs/libSDL_image-1.2.0.dylib libs/libSDL_mixer-1
all: rc edit all: rc edit
rc: rc.c shared.c rc.h shared.h globals.h defs.h rc: rc.c shared.c rc.h shared.h globals.h defs.h
gcc -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer gcc -Wall -o rc -g rc.c shared.c -L/Users/rob/c/rc/libs `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer
edit: edit.c shared.c edit.h shared.h globals.h defs.h edit: edit.c shared.c edit.h shared.h globals.h defs.h
gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf

20
Makefile.leapord Normal file
View File

@ -0,0 +1,20 @@
LIBS = libs/libSDL-1.2.0.dylib libs/libSDL_image-1.2.0.dylib libs/libSDL_mixer-1.2.0.dylib libs/libSDL_ttf-2.0.0.dylib libs/libjpeg.62.dylib libs/libpng.3.dylib libs/libvorbisfile.3.dylib libs/libogg.0.dylib libs/libsmpeg-0.4.0.dylib libs/libmikmod.2.dylib libs/libvorbis.0.dylib libs/libSDL_gfx.dylib
all: rc edit
rc: rc.c shared.c rc.h shared.h globals.h defs.h
gcc -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_Mixer
edit: edit.c shared.c edit.h shared.h globals.h defs.h
gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf
app: rc
if [ `uname -s` != "Darwin" ]; then echo "Mac .app bundle generation is only available under OSX."; exit 1; fi;
if [ -d RatCatcher.app ]; then rm -fr RatCatcher.app ; fi
# create staging area without svn files
rsync -rC data/ staging/data
platypus -a rc -t shell -o TextWindow -R -u "Rob Pearce" -f staging/data -f rc scripts/run.sh RatCatcher.app
seticon -d icon.icns RatCatcher.app
dylibbundler -od -b -x ./RatCatcher.app/Contents/Resources/rc -d ./RatCatcher.app/Contents/libs/ -p @executable_path/../libs/
zip -r RatCatcher.zip RatCatcher.app

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1019 B

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1001 B

After

Width:  |  Height:  |  Size: 943 B

View File

@ -25,13 +25,13 @@ endmonsters
exitdir 1 exitdir 1
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,4,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4, 4,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,4,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4, 4,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,4,27,27,27,27,27,27,35,34,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4, 4,27,27,27,41,27,27,27,27,27,27,27,27,35,34,27,27,27,27,27,27,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,39,1,1,1,1,1,1,38,39,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,4, 4,27,27,27,39,1,1,1,1,1,1,1,1,38,39,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,34,0,0,4, 4,27,27,27,27,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,34,0,0,4,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29,0,4,
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,1,1,1,38, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,1,1,1,38,
4,0,0,0,0,0,0,0,0,5,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,5,41,6,0,0,39,1,1,1,4,4,4,4, 4,0,0,0,0,0,0,0,0,5,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,5,41,6,0,0,39,1,1,1,4,4,4,4,
39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,38,4,39,1,1,38,4,4,4,4,4,4,4, 39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,38,4,39,1,1,38,4,4,4,4,4,4,4,
@ -54,3 +54,5 @@ exitdir 1
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
layer2 layer2
4,3,30
4,6,42

67
defs.h
View File

@ -241,7 +241,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 64 #define MAXPTYPES 116
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -306,6 +306,68 @@
#define P_TAP 61 #define P_TAP 61
#define P_MASK 62 #define P_MASK 62
#define P_MASKPOWERUP 63 #define P_MASKPOWERUP 63
#define P_FIRSTCARD 64 // IMPORTANT!
#define P_FIRSTHEART 64 // IMPORTANT!
#define P_CARDH1 64
#define P_CARDH2 65
#define P_CARDH3 66
#define P_CARDH4 67
#define P_CARDH5 68
#define P_CARDH6 69
#define P_CARDH7 70
#define P_CARDH8 71
#define P_CARDH9 72
#define P_CARDH10 73
#define P_CARDHJ 74
#define P_CARDHQ 75
#define P_CARDHK 76
#define P_FIRSTDIAMOND 77 // IMPORTANT!
#define P_CARDD1 77
#define P_CARDD2 78
#define P_CARDD3 79
#define P_CARDD4 80
#define P_CARDD5 81
#define P_CARDD6 82
#define P_CARDD7 83
#define P_CARDD8 84
#define P_CARDD9 85
#define P_CARDD10 86
#define P_CARDDJ 87
#define P_CARDDQ 88
#define P_CARDDK 89
#define P_FIRSTSPADE 90 // IMPORTANT!
#define P_CARDS1 90
#define P_CARDS2 91
#define P_CARDS3 92
#define P_CARDS4 93
#define P_CARDS5 94
#define P_CARDS6 95
#define P_CARDS7 96
#define P_CARDS8 97
#define P_CARDS9 98
#define P_CARDS10 99
#define P_CARDSJ 100
#define P_CARDSQ 101
#define P_CARDSK 102
#define P_FIRSTCLUB 103 // IMPORTANT!
#define P_CARDC1 103
#define P_CARDC2 104
#define P_CARDC3 105
#define P_CARDC4 106
#define P_CARDC5 107
#define P_CARDC6 108
#define P_CARDC7 109
#define P_CARDC8 110
#define P_CARDC9 111
#define P_CARDC10 112
#define P_CARDCJ 113
#define P_CARDCQ 114
#define P_CARDCK 115
// cards
#define CARDFONTX 4
#define CARDFONTY 6
#define CARDFONTSIZE 10
// powerups // powerups
#define PW_NONE 0 #define PW_NONE 0
@ -590,6 +652,8 @@ typedef struct sprite_s {
int timer3; // int timer3; //
int watertimer; // int watertimer; //
int frame;
// GAME MECHANICS // GAME MECHANICS
double x,y; // current position double x,y; // current position
@ -627,6 +691,7 @@ extern SDL_Color yellow;
extern int vidargs; extern int vidargs;
extern int toggletimer; extern int toggletimer;
extern TTF_Font *font[]; extern TTF_Font *font[];
extern TTF_Font *cardfont;
extern int musicplaying; extern int musicplaying;
extern Mix_Music *music, *normalmusic, *fastmusic, *bossmusic; extern Mix_Music *music, *normalmusic, *fastmusic, *bossmusic;
extern Mix_Chunk *sfx[]; extern Mix_Chunk *sfx[];

4
edit.c
View File

@ -1046,6 +1046,10 @@ int isplacablesprite(int sid) {
case P_BIGSPEED: case P_BIGSPEED:
return B_FALSE; return B_FALSE;
} }
if (iscard(sid)) {
return B_FALSE;
}
return B_TRUE; return B_TRUE;
} }

View File

@ -47,6 +47,7 @@ int oldexitdir; // exit direction of previous level
int vidargs; // arguments for SetVideo call int vidargs; // arguments for SetVideo call
TTF_Font *font[MAXLETTERHEIGHT]; TTF_Font *font[MAXLETTERHEIGHT];
TTF_Font *cardfont;
/* timers */ /* timers */
int gtime; // game time - time elapsed on current level int gtime; // game time - time elapsed on current level

103
rc.c
View File

@ -153,6 +153,9 @@ int main (int argc, char **argv) {
} }
initsdl(); initsdl();
if (TTF_Init()) {
printf("TTF_Init: %s\n", TTF_GetError());
}
atexit(cleanup); atexit(cleanup);
srand(time(NULL)); srand(time(NULL));
@ -191,9 +194,6 @@ int main (int argc, char **argv) {
/* load fonts */ /* load fonts */
if (TTF_Init()) {
printf("TTF_Init: %s\n", TTF_GetError());
}
sprintf(filename, "%s/gamefont.ttf",datadir); sprintf(filename, "%s/gamefont.ttf",datadir);
for (i = 1; i < MAXLETTERHEIGHT; i++) { for (i = 1; i < MAXLETTERHEIGHT; i++) {
SDL_Surface *surf; SDL_Surface *surf;
@ -505,6 +505,9 @@ int main (int argc, char **argv) {
player->slamming = B_TRUE; player->slamming = B_TRUE;
player->slamangle = 0; player->slamangle = 0;
player->netxstart = player->x - (player->img->w/2)*player->dir; player->netxstart = player->x - (player->img->w/2)*player->dir;
adjustx(player, F_SLAM1);
player->netystart = player->y; player->netystart = player->y;
/* handle mace */ /* handle mace */
@ -539,7 +542,10 @@ int main (int argc, char **argv) {
} else { } else {
/* shoot net */ /* shoot net */
playfx(FX_SHOOT); playfx(FX_SHOOT);
player->netting = 1; player->netting = 1;
adjustx(player, F_SHOOT);
if (player->netbig) { if (player->netbig) {
player->netspeed = NETSPEED+3; player->netspeed = NETSPEED+3;
} else { } else {
@ -1103,7 +1109,7 @@ void nextlevel(void) {
} }
void jump(sprite_t *s, int dir) { void jump(sprite_t *s, int dir) {
// if we've just been hit with armour, bypass all these checks) // if we've ust been hit with armour, bypass all these checks)
if (!s->recoiling) { if (!s->recoiling) {
// can't jump if already jumping // can't jump if already jumping
if (s->jumping) return; if (s->jumping) return;
@ -1711,6 +1717,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
SDL_Surface *ts; SDL_Surface *ts;
if (timer % 2 == 0) { if (timer % 2 == 0) {
/* shrink */ /* shrink */
// TODO: free old image first!!
if (s->teleporting == TP_SHRINKING) { if (s->teleporting == TP_SHRINKING) {
ts = rotozoomSurfaceXY(s->img,0, 0.9 , 0.9 ,0); ts = rotozoomSurfaceXY(s->img,0, 0.9 , 0.9 ,0);
s->img = ts; s->img = ts;
@ -1748,6 +1755,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
s->teleporting = 0; s->teleporting = 0;
s->img = imageset[s->id].img[F_WALK1]; s->img = imageset[s->id].img[F_WALK1];
} else { } else {
// TODO: free old image first!!
s->img = rotozoomSurfaceXY(imageset[s->id].img[F_WALK1],0,size,size,0); s->img = rotozoomSurfaceXY(imageset[s->id].img[F_WALK1],0,size,size,0);
s->teleporting--; s->teleporting--;
} }
@ -2714,7 +2722,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
player->x = s->x; player->x = s->x;
player->y = s->y - (imageset[P_PINKCLOUD].img[F_WALK1]->h / 2); player->y = s->y - (imageset[P_PINKCLOUD].img[F_WALK1]->h / 2);
// turn off payer attributes // turn off player attributes
player->climbing = B_FALSE; player->climbing = B_FALSE;
player->netting = B_FALSE; player->netting = B_FALSE;
player->slamming = B_FALSE; player->slamming = B_FALSE;
@ -2801,6 +2809,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
cloudim = imageset[P_BLACKCLOUD].img[0]; cloudim = imageset[P_BLACKCLOUD].img[0];
/* get smaller */ /* get smaller */
s->size -= 0.1; s->size -= 0.1;
// TODO: free old image first ?? depends ...
ts = rotozoomSurfaceXY(cloudim,0,s->size, s->size, 0); ts = rotozoomSurfaceXY(cloudim,0,s->size, s->size, 0);
//ts = rotozoomSurfaceXY(s->img,0, 0.9 , 0.9 ,0); //ts = rotozoomSurfaceXY(s->img,0, 0.9 , 0.9 ,0);
SDL_FreeSurface(s->img); SDL_FreeSurface(s->img);
@ -2845,6 +2854,7 @@ if (s->id == P_PUFF) printf("PUFF WITH DOOMCOUNT!\n");
//ts = rotozoomSurfaceXY(s->img,0, 1.1 , 1.1 ,0); //ts = rotozoomSurfaceXY(s->img,0, 1.1 , 1.1 ,0);
s->size += CLOUDGROWAMT; s->size += CLOUDGROWAMT;
//printf("grow, now %0.2f\n",s->size); //printf("grow, now %0.2f\n",s->size);
// TODO: free old first? depends if we ever use a preset one
ts = rotozoomSurfaceXY(cloudim,0,s->size, s->size, 0); ts = rotozoomSurfaceXY(cloudim,0,s->size, s->size, 0);
SDL_FreeSurface(s->img); SDL_FreeSurface(s->img);
s->img = ts; s->img = ts;
@ -3394,6 +3404,11 @@ int addtext(int x, int y, int size, char *string, SDL_Color *c, int delay) {
t->img = TTF_RenderText_Solid(font[t->size], t->txt, *t->c); t->img = TTF_RenderText_Solid(font[t->size], t->txt, *t->c);
if (t->img == NULL) {
printf("rendertext failed for '%s'\n", t->txt);
fflush(stdout);
}
t->next = NULL; t->next = NULL;
lasttext = t; lasttext = t;
@ -4132,6 +4147,7 @@ void dogravity(sprite_t *s) {
else { else {
if (s->netlen <= 0) { if (s->netlen <= 0) {
s->netting = 0; s->netting = 0;
adjustx(s, F_WALK1);
for (s2 = sprite ; s2 ; s2 = s2->next) { for (s2 = sprite ; s2 ; s2 = s2->next) {
if ((s2->caughtby == s) && (s2->caughtstate == C_NETTING)) { if ((s2->caughtby == s) && (s2->caughtstate == C_NETTING)) {
s2->caughtstate = C_NETTED; s2->caughtstate = C_NETTED;
@ -4362,6 +4378,11 @@ void dogravity(sprite_t *s) {
curpoweruptype = 0; curpoweruptype = 0;
} }
} }
// if player already has this, we get a card instead
if (haspowerup(player, s2->willbecome)) {
s2->willbecome = getrandomcard();
}
} }
} else if (player->powerup == PW_MACE) { } else if (player->powerup == PW_MACE) {
s2->willbecome = P_DIAMOND; s2->willbecome = P_DIAMOND;
@ -4909,6 +4930,12 @@ int dofruiteffect(sprite_t *s) {
// TODO: move other HELP text around if need be! // TODO: move other HELP text around if need be!
addoutlinetext(320,240,TEXTSIZE_HELP, s->name, &white,&black,HELPDELAY); addoutlinetext(320,240,TEXTSIZE_HELP, s->name, &white,&black,HELPDELAY);
return B_TRUE; return B_TRUE;
} else if (iscard(s->id)) {
// TODO: handle cards
sprintf(tempm, getcardname(s->id));
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY);
// TODO: add a "card" effect, move it slowly towards the corner.
return B_TRUE;
} else if (isflower(s->id)) { } else if (isflower(s->id)) {
int xx; int xx;
sprite_t *ss; sprite_t *ss;
@ -5338,8 +5365,17 @@ void adjustx(sprite_t *s,int framenum) {
int newx,newy,diff; int newx,newy,diff;
tiletype_t *tt; tiletype_t *tt;
diff = (imageset[s->id].img[framenum]->w - s->img->w) +1 ; if (imageset[s->id].img[framenum] == NULL) {
return;
}
if (imageset[s->id].img[framenum]->w > s->img->w) {
diff = (imageset[s->id].img[framenum]->w - s->img->w) +1 ;
} else {
diff = (s->img->w - imageset[s->id].img[framenum]->w) +1 ;
}
newy = s->y-TILEH; newy = s->y-TILEH;
// check RIGHT // check RIGHT
newx = s->x + (s->img->w/2); newx = s->x + (s->img->w/2);
tt = gettileat(newx,newy,NULL,NULL); tt = gettileat(newx,newy,NULL,NULL);
@ -5420,9 +5456,16 @@ void checkcollideall(void) {
void drawallsprites(void) { void drawallsprites(void) {
sprite_t *s; sprite_t *s;
int lastframe;
/* draw non-puff sprites */ /* draw non-puff sprites */
for (s = sprite ; s ; s = s->next) { for (s = sprite ; s ; s = s->next) {
if (s->id != P_PUFF) drawsprite(s); if (s->id != P_PUFF) {
lastframe = s->frame;
drawsprite(s);
if (s->frame != lastframe) {
adjustx(s, s->frame);
}
}
} }
/* draw puff sprites */ /* draw puff sprites */
for (s = sprite ; s ; s = s->next) { for (s = sprite ; s ; s = s->next) {
@ -5634,3 +5677,49 @@ void doflood(void) {
} }
} }
int haspowerup(sprite_t *s, int pid) {
switch (pid) {
case P_SPEED:
if (s->speed != 1) {
return B_TRUE;
}
break;
case P_NUMNETS:
if (s->netmax >= 4 ) {
return B_TRUE;
}
break;
case P_BIGNET:
if (s->netbig) {
return B_TRUE;
}
break;
case P_MASKPOWERUP:
if (s->hasmask) {
return B_TRUE;
}
break;
case P_TROPHY:
if ((s->netmax >= 4) && (s->netbig) && (s->speed != 1)) {
return B_TRUE;
}
break;
case P_HELMET:
if (s->armour) {
return B_TRUE;
}
break;
case P_BELL:
if (s->hasbell) {
return B_TRUE;
}
break;
case P_GEMBOOST:
if (s->gemboost >= 3) {
return B_TRUE;
}
break;
}
return B_FALSE;
}

1
rc.h
View File

@ -67,3 +67,4 @@ void togglepause(void);
void togglefullscreen(void); void togglefullscreen(void);
void initsdl(void); void initsdl(void);
void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier); void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier);
int haspowerup(sprite_t *s, int pid);

236
shared.c
View File

@ -568,6 +568,9 @@ void setdefaults(sprite_t *s) {
} else { } else {
s->speed = 1; s->speed = 1;
} }
s->frame = 0;
s->hasmask = B_FALSE; s->hasmask = B_FALSE;
s->hasbell = B_FALSE; s->hasbell = B_FALSE;
s->armour = B_FALSE; s->armour = B_FALSE;
@ -692,7 +695,6 @@ sprite_t *addsprite(int id, int x, int y, char *name ) {
s->x = x; s->x = x;
s->y = y; s->y = y;
if (s->id == P_BLACKCLOUD) { if (s->id == P_BLACKCLOUD) {
//s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,1,1,0);
s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,0.1,0.1,0); s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,0.1,0.1,0);
} else if (s->id == P_PINKCLOUD) { } else if (s->id == P_PINKCLOUD) {
s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,(double)PCGROWSPEED,(double)PCGROWSPEED,0); s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,(double)PCGROWSPEED,(double)PCGROWSPEED,0);
@ -1253,6 +1255,60 @@ int loadimagesets(void) {
imageset[P_PUFF].numimages = PUFFFRAMES; imageset[P_PUFF].numimages = PUFFFRAMES;
imageset[P_SMASH].numimages = PUFFFRAMES; imageset[P_SMASH].numimages = PUFFFRAMES;
// playing card bonuses
//loadspriteimage(P_CARDHK,F_WALK1, "sprites/cardhk.png");
// load card font
sprintf(tempfile, "%s/cardfont.ttf", datadir);
cardfont = TTF_OpenFont(tempfile, CARDFONTSIZE);
if (!cardfont) {
printf("Error opening font '%s': %s\n", tempfile, TTF_GetError());
exit(1);
}
for (i = 1; i <= 13; i++) {
SDL_Surface *letter;
SDL_Rect area;
char str[2];
// HEARTS
loadspriteimage(P_FIRSTHEART+i-1, F_WALK1, "sprites/cardh.png");
sprintf(str, "%s",getcardletter(i));
letter = TTF_RenderText_Blended(cardfont, str, red );
area.x = CARDFONTX; area.y = CARDFONTY; area.w = 0; area.h = 0;
if (i == 10) area.x -= 3;
SDL_BlitSurface(letter, NULL, imageset[P_FIRSTHEART + i-1].img[F_WALK1], &area);
imageset[P_FIRSTHEART + i-1].numimages = 1;
SDL_FreeSurface(letter);
// DIAMONDS
loadspriteimage(P_FIRSTDIAMOND+i-1, F_WALK1, "sprites/cardd.png");
sprintf(str, "%s",getcardletter(i));
letter = TTF_RenderText_Blended(cardfont, str, red );
area.x = CARDFONTX; area.y = CARDFONTY; area.w = 0; area.h = 0;
if (i == 10) area.x -= 3;
SDL_BlitSurface(letter, NULL, imageset[P_FIRSTDIAMOND + i-1].img[F_WALK1], &area);
imageset[P_FIRSTDIAMOND + i-1].numimages = 1;
SDL_FreeSurface(letter);
// SPADES
loadspriteimage(P_FIRSTSPADE+i-1, F_WALK1, "sprites/cards.png");
sprintf(str, "%s",getcardletter(i));
letter = TTF_RenderText_Blended(cardfont, str, black );
area.x = CARDFONTX; area.y = CARDFONTY; area.w = 0; area.h = 0;
if (i == 10) area.x -= 3;
SDL_BlitSurface(letter, NULL, imageset[P_FIRSTSPADE + i-1].img[F_WALK1], &area);
imageset[P_FIRSTSPADE + i-1].numimages = 1;
SDL_FreeSurface(letter);
// CLUBS
loadspriteimage(P_FIRSTCLUB+i-1, F_WALK1, "sprites/cardc.png");
sprintf(str, "%s",getcardletter(i));
letter = TTF_RenderText_Blended(cardfont, str, black );
area.x = CARDFONTX; area.y = CARDFONTY; area.w = 0; area.h = 0;
if (i == 10) area.x -= 3;
SDL_BlitSurface(letter, NULL, imageset[P_FIRSTCLUB + i-1].img[F_WALK1], &area);
imageset[P_FIRSTCLUB + i-1].numimages = 1;
SDL_FreeSurface(letter);
}
// sparkles // sparkles
for (i = 0; i < SPARKLEFRAMES; i++) { for (i = 0; i < SPARKLEFRAMES; i++) {
@ -1282,6 +1338,10 @@ int loadimagesets(void) {
for (fr = F_DEAD2; fr <= F_DEAD4; fr++) { for (fr = F_DEAD2; fr <= F_DEAD4; fr++) {
if (!imageset[p].img[fr]) { if (!imageset[p].img[fr]) {
tempimg = rotozoomSurface(imageset[p].img[F_DEAD],angle,1,0); tempimg = rotozoomSurface(imageset[p].img[F_DEAD],angle,1,0);
if (tempimg == NULL) {
printf("error rotozooming sprite %d, deadimage %d\n",p,fr);
exit(1);
}
imageset[p].img[fr] = SDL_DisplayFormat(tempimg); imageset[p].img[fr] = SDL_DisplayFormat(tempimg);
} }
angle += 90; angle += 90;
@ -1389,7 +1449,7 @@ int loadimagesets(void) {
void drawsprite(sprite_t *s) { void drawsprite(sprite_t *s) {
SDL_Rect area; SDL_Rect area;
int frame; int frame = 0;
if ((s == player) && (levelcomplete == LV_NEXTLEV)) { if ((s == player) && (levelcomplete == LV_NEXTLEV)) {
frame = F_SHOOT; frame = F_SHOOT;
@ -1561,6 +1621,8 @@ void drawsprite(sprite_t *s) {
} }
s->frame = frame;
area.x = s->x - (s->img->w/2); area.x = s->x - (s->img->w/2);
area.y = s->y - (s->img->h); area.y = s->y - (s->img->h);
area.w = 0; area.w = 0;
@ -1654,6 +1716,12 @@ void killsprite(sprite_t *s) {
SDL_FreeSurface(s->iceimg); SDL_FreeSurface(s->iceimg);
} }
// TODO: free image for certain types
// blackcloud
// pinkcloud
// cards?
// etc
nextone = s->next; nextone = s->next;
if (nextone != NULL) { if (nextone != NULL) {
nextone->prev = s->prev; nextone->prev = s->prev;
@ -1707,6 +1775,13 @@ int flowertogem(int id) {
return P_GEMRED; return P_GEMRED;
} }
int iscard(int id) {
if ((id >= P_FIRSTCARD) && (id <= P_FIRSTCARD+51)) {
return B_TRUE;
}
return B_FALSE;
}
int isflower(int id) { int isflower(int id) {
switch (id) { switch (id) {
case P_FLOWERRED: case P_FLOWERRED:
@ -1775,6 +1850,8 @@ int isfruit(int id) {
} }
if (iscard(id)) return FT_FRUIT;
return B_FALSE; return B_FALSE;
} }
@ -2547,6 +2624,8 @@ void setfruitinfo(void) {
setinfo(P_UFO, "UFO", "Calls in a powerful meteor strike!", "ufo.png"); setinfo(P_UFO, "UFO", "Calls in a powerful meteor strike!", "ufo.png");
setinfo(P_TAP, "Tap", "The leaky tap will flood the level with water, allowing you to acces hard to reach areas.", "tap.png"); setinfo(P_TAP, "Tap", "The leaky tap will flood the level with water, allowing you to acces hard to reach areas.", "tap.png");
// TODO: add cards here!
setinfo(P_RAT, "Rat", "The weakest of the monsters, the rat will simply walk back and forth waiting to be caught. Beward an angry rat though, as it will try to fall or jump in order to catch you!", "rat.png"); setinfo(P_RAT, "Rat", "The weakest of the monsters, the rat will simply walk back and forth waiting to be caught. Beward an angry rat though, as it will try to fall or jump in order to catch you!", "rat.png");
setinfo(P_BEE, "Bee", "Bees, while still relatively weak, gain an advantage over bats in that they are able to fly. They move in a simple diagonal pattern, changing direction when they get near a wall or spikes. Bees will speed up when angry.", "newbee.png"); setinfo(P_BEE, "Bee", "Bees, while still relatively weak, gain an advantage over bats in that they are able to fly. They move in a simple diagonal pattern, changing direction when they get near a wall or spikes. Bees will speed up when angry.", "newbee.png");
@ -2660,3 +2739,156 @@ void doblit(SDL_Surface *src, SDL_Surface *dst, SDL_Rect *dstarea) {
} }
} }
} }
char *getcardletter(int num) {
switch (num) {
case 0:
return "X";
case 1:
return "A";
case 2:
return "2";
case 3:
return "3";
case 4:
return "4";
case 5:
return "5";
case 6:
return "6";
case 7:
return "7";
case 8:
return "8";
case 9:
return "9";
case 10:
return "10";
case 11:
return "J";
case 12:
return "Q";
case 13:
return "K";
}
return "?";
}
// returns a random card sprite id
int getrandomcard(void) {
int cardid;
// TODO: change to 52
cardid = P_FIRSTCARD + (rand() % 52);
return cardid;
}
char *getcardname(int id) {
switch (id) {
case P_CARDH1:
return "Ace of Hearts";
case P_CARDH2:
return "Two of Hearts";
case P_CARDH3:
return "Three of Hearts";
case P_CARDH4:
return "Four of Hearts";
case P_CARDH5:
return "Five of Hearts";
case P_CARDH6:
return "Six of Hearts";
case P_CARDH7:
return "Seven of Hearts";
case P_CARDH8:
return "Eight of Hearts";
case P_CARDH9:
return "Nine of Hearts";
case P_CARDH10:
return "Ten of Hearts";
case P_CARDHJ:
return "Jack of Hearts";
case P_CARDHQ:
return "Queen of Hearts";
case P_CARDHK:
return "King of Hearts";
case P_CARDD1:
return "Ace of Diamonds";
case P_CARDD2:
return "Two of Diamonds";
case P_CARDD3:
return "Three of Diamonds";
case P_CARDD4:
return "Four of Diamonds";
case P_CARDD5:
return "Five of Diamonds";
case P_CARDD6:
return "Six of Diamonds";
case P_CARDD7:
return "Seven of Diamonds";
case P_CARDD8:
return "Eight of Diamonds";
case P_CARDD9:
return "Nine of Diamonds";
case P_CARDD10:
return "Ten of Diamonds";
case P_CARDDJ:
return "Jack of Diamonds";
case P_CARDDQ:
return "Queen of Diamonds";
case P_CARDDK:
return "King of Diamonds";
case P_CARDS1:
return "Ace of Spades";
case P_CARDS2:
return "Two of Spades";
case P_CARDS3:
return "Three of Spades";
case P_CARDS4:
return "Four of Spades";
case P_CARDS5:
return "Five of Spades";
case P_CARDS6:
return "Six of Spades";
case P_CARDS7:
return "Seven of Spades";
case P_CARDS8:
return "Eight of Spades";
case P_CARDS9:
return "Nine of Spades";
case P_CARDS10:
return "Ten of Spades";
case P_CARDSJ:
return "Jack of Spades";
case P_CARDSQ:
return "Queen of Spades";
case P_CARDSK:
return "King of Spades";
case P_CARDC1:
return "Ace of Clubs";
case P_CARDC2:
return "Two of Clubs";
case P_CARDC3:
return "Three of Clubs";
case P_CARDC4:
return "Four of Clubs";
case P_CARDC5:
return "Five of Clubs";
case P_CARDC6:
return "Six of Clubs";
case P_CARDC7:
return "Seven of Clubs";
case P_CARDC8:
return "Eight of Clubs";
case P_CARDC9:
return "Nine of Clubs";
case P_CARDC10:
return "Ten of Clubs";
case P_CARDCJ:
return "Jack of Clubs";
case P_CARDCQ:
return "Queen of Clubs";
case P_CARDCK:
return "King of Clubs";
}
return "Unknown Card";
}

View File

@ -18,6 +18,7 @@ void drawsprite(sprite_t *s);
int gettileframecount(int tid); int gettileframecount(int tid);
int isfruit(int id); int isfruit(int id);
int isflower(int id); int isflower(int id);
int iscard(int id);
int iseffect(int id); int iseffect(int id);
int needscollisions(int id); int needscollisions(int id);
int candoslopes(int sid); int candoslopes(int sid);
@ -51,6 +52,9 @@ int isboss(int monid);
int getbosshealth(int mid); int getbosshealth(int mid);
void getpixelrgb(SDL_Surface *where, int x, int y, SDL_Color *clr); void getpixelrgb(SDL_Surface *where, int x, int y, SDL_Color *clr);
void doblit(SDL_Surface *src, SDL_Surface *dst, SDL_Rect *dstarea); void doblit(SDL_Surface *src, SDL_Surface *dst, SDL_Rect *dstarea);
char *getcardletter(int num);
int getrandomcard(void);
char *getcardname(int id);
// for doco // for doco
void setfruitinfo(void); void setfruitinfo(void);
void setinfo(int id, char *name, char *desc, char *file); void setinfo(int id, char *name, char *desc, char *file);