Added new powerup: random

This commit is contained in:
Rob Pearce 2008-11-06 02:15:49 +00:00
parent fe240dcdb4
commit 0aeb322c0e
4 changed files with 58 additions and 5 deletions

3
defs.h
View File

@ -320,7 +320,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 131 #define MAXPTYPES 132
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -457,6 +457,7 @@
#define P_KINGSNAIL 128 #define P_KINGSNAIL 128
#define P_KSSHELL 129 #define P_KSSHELL 129
#define P_BIGNUMNETS 130 #define P_BIGNUMNETS 130
#define P_RANDOM 131
// cards // cards
#define CARDFONTX 4 #define CARDFONTX 4

18
rc.c
View File

@ -1785,6 +1785,19 @@ int movesprite(sprite_t *s) {
return B_FALSE; return B_FALSE;
} }
// for random powerup, pick a random image
if ((timer % 5) == 0) {
if (s->id == P_RANDOM) {
s->timer1 = randompowerup();
while (s->timer1 == P_RANDOM) {
s->timer1 = randompowerup();
}
// set image
s->img = imageset[s->timer1].img[F_WALK1];
}
}
/* timer */ /* timer */
if (s->doomcount) { if (s->doomcount) {
if (player->powerup != PW_GUNNER) { if (player->powerup != PW_GUNNER) {
@ -6816,6 +6829,11 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) {
modscore = addscore(giveto, gotscore); modscore = addscore(giveto, gotscore);
} }
if (fruit->id == P_RANDOM) {
// change id to whatever it currently looks like
fruit->id = fruit->timer1;
}
/* handle fruit effects */ /* handle fruit effects */
if (!dofruiteffect(fruit)) { if (!dofruiteffect(fruit)) {
playfx(FX_FRUIT); playfx(FX_FRUIT);

View File

@ -613,7 +613,10 @@ void setdefaults(sprite_t *s) {
s->jumpspeed = 0; s->jumpspeed = 0;
s->jumpdir = 1; s->jumpdir = 1;
s->useddoublejump = B_FALSE; s->useddoublejump = B_FALSE;
s->timer1 = 0; if (s->id != P_RANDOM) {
// random gets timer1 set during addsprite()
s->timer1 = 0;
}
s->timer2 = 0; s->timer2 = 0;
s->timer3 = 0; s->timer3 = 0;
s->timer4 = 0; s->timer4 = 0;
@ -721,13 +724,26 @@ sprite_t *addsprite(int id, int x, int y, char *name ) {
} }
s->id = id; s->id = id;
s->x = x; s->x = x;
s->y = y; s->y = y;
// special case for random powerup
if (s->id == P_RANDOM) {
s->timer1 = randompowerup();
while (s->timer1 == P_RANDOM) {
s->timer1 = randompowerup();
}
}
if (s->id == P_BLACKCLOUD) { if (s->id == P_BLACKCLOUD) {
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);
} else if (s->id == P_RANDOM) {
s->img = imageset[s->timer1].img[F_WALK1];
} else { } else {
s->img = imageset[id].img[F_WALK1]; s->img = imageset[id].img[F_WALK1];
} }
@ -781,6 +797,7 @@ sprite_t *addsprite(int id, int x, int y, char *name ) {
#endif #endif
s->next = NULL; s->next = NULL;
lastsprite = s; lastsprite = s;
@ -1187,6 +1204,9 @@ int loadimagesets(void) {
loadspriteimage(P_SPEED,F_WALK1, "sprites/speed.png"); loadspriteimage(P_SPEED,F_WALK1, "sprites/speed.png");
imageset[P_SPEED].numimages = 1; imageset[P_SPEED].numimages = 1;
// don't load image for P_RANDOM
imageset[P_RANDOM].numimages = 0;
loadspriteimage(P_NUMNETS,F_WALK1, "sprites/numnets.png"); loadspriteimage(P_NUMNETS,F_WALK1, "sprites/numnets.png");
imageset[P_NUMNETS].numimages = 1; imageset[P_NUMNETS].numimages = 1;
@ -1784,6 +1804,9 @@ void drawsprite(sprite_t *s) {
s->img = imageset[s->timer1].img[F_WALK1]; s->img = imageset[s->timer1].img[F_WALK1];
} else if (s->id == P_FIVECARDS) { } else if (s->id == P_FIVECARDS) {
// do nothing - img already there! // do nothing - img already there!
} else if (s->id == P_RANDOM) {
// image based on timer1
s->img = imageset[s->timer1].img[F_WALK1];
} else if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) { } else if ((s->id != P_BLACKCLOUD) && (s->id != P_PINKCLOUD) && (!s->teleporting)) {
// select image based on sprite id // select image based on sprite id
s->img = imageset[s->id].img[frame]; s->img = imageset[s->id].img[frame];
@ -2121,6 +2144,7 @@ int isfruit(int id) {
case P_GUN: case P_GUN:
case P_ZAPPOWERUP: case P_ZAPPOWERUP:
case P_SKULL: case P_SKULL:
case P_RANDOM:
return FT_TEMP; return FT_TEMP;
/* flowers */ /* flowers */
case P_FLOWERYELLOW: case P_FLOWERYELLOW:
@ -2738,7 +2762,7 @@ int loadlevellist(void) {
int randompowerup(void) { int randompowerup(void) {
int num; int num;
num = rand() % 33; num = rand() % 34;
switch (num) { switch (num) {
case 0: case 0:
@ -2813,6 +2837,8 @@ int randompowerup(void) {
return P_GUN; return P_GUN;
case 32: case 32:
return P_ZAPPOWERUP; return P_ZAPPOWERUP;
case 33:
return P_RANDOM;
} }
} }
@ -2954,6 +2980,8 @@ void setfruitinfo(void) {
setinfo(P_SKULL, "Skull", "Avoid these at all costs! The skull will cause you to lose all net powerups.", "skull.png"); setinfo(P_SKULL, "Skull", "Avoid these at all costs! The skull will cause you to lose all net powerups.", "skull.png");
setinfo(P_CLOVER, "4-Leaf Clover", "Increases your luck...", "clover.png"); setinfo(P_CLOVER, "4-Leaf Clover", "Increases your luck...", "clover.png");
setinfo(P_RANDOM, "Random", "Gives you a random effect...", "random.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_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");
@ -3017,8 +3045,13 @@ void dumpinfo(void) {
printf("<tr bgcolor=\"#ffff00\"><th colspan=2>Temporary Powerups</th></tr>\n"); printf("<tr bgcolor=\"#ffff00\"><th colspan=2>Temporary Powerups</th></tr>\n");
for (i = 0; i < MAXPTYPES; i++) { for (i = 0; i < MAXPTYPES; i++) {
if (isfruit(i) == FT_TEMP) { if (isfruit(i) == FT_TEMP) {
printf("<tr><td align=center><img src=\"img/%s\"><br>%s</td><td>%s</td></tr>\n", if (i == P_RANDOM) {
spriteinfo[i].file, spriteinfo[i].name,spriteinfo[i].desc); printf("<tr><td align=center><font color=\"ff00ff\"><b><big>?</big></b></font><br>%s</td><td>%s</td></tr>\n",
spriteinfo[i].name,spriteinfo[i].desc);
} else {
printf("<tr><td align=center><img src=\"img/%s\"><br>%s</td><td>%s</td></tr>\n",
spriteinfo[i].file, spriteinfo[i].name,spriteinfo[i].desc);
}
} }
} }
// super powerup // super powerup

View File

@ -48,6 +48,7 @@
<tr><td align=center><img src="img/skull.png"><br>Skull</td><td>Avoid these at all costs! The skull will cause you to lose all net powerups.</td></tr> <tr><td align=center><img src="img/skull.png"><br>Skull</td><td>Avoid these at all costs! The skull will cause you to lose all net powerups.</td></tr>
<tr><td align=center><img src="img/gunner.png"><br>Gunner</td><td>Temporarily equips you with a super powerful machine gun!</td></tr> <tr><td align=center><img src="img/gunner.png"><br>Gunner</td><td>Temporarily equips you with a super powerful machine gun!</td></tr>
<tr><td align=center><img src="img/zapper.png"><br>Bug Zapper</td><td>Zaps nearby enemies with miniature bolts of lightning</td></tr> <tr><td align=center><img src="img/zapper.png"><br>Bug Zapper</td><td>Zaps nearby enemies with miniature bolts of lightning</td></tr>
<tr><td align=center><font color="ff00ff"><b><big>?</big></b></font><br>Random</td><td>Gives you a random effect...</td></tr>
<tr bgcolor="#ffff00"><th colspan=2>Super Powerups</th></tr> <tr bgcolor="#ffff00"><th colspan=2>Super Powerups</th></tr>
<tr><td align=center><img src="img/bigspeed.png"><br>Big Speed Up</td><td>Makes you walk faster, permenantly!</td></tr> <tr><td align=center><img src="img/bigspeed.png"><br>Big Speed Up</td><td>Makes you walk faster, permenantly!</td></tr>
<tr><td align=center><img src="img/bignumnets.png"><br>Big More Nets</td><td>Permenantly gives you two nets, even after death</td></tr> <tr><td align=center><img src="img/bignumnets.png"><br>Big More Nets</td><td>Permenantly gives you two nets, even after death</td></tr>