diff --git a/defs.h b/defs.h index 6476cc8..d8afa09 100644 --- a/defs.h +++ b/defs.h @@ -320,7 +320,7 @@ #define S_SLOPE 2 // Sprite types -#define MAXPTYPES 131 +#define MAXPTYPES 132 #define P_PLAYER 0 #define P_RAT 1 #define P_CHEESE 2 @@ -457,6 +457,7 @@ #define P_KINGSNAIL 128 #define P_KSSHELL 129 #define P_BIGNUMNETS 130 +#define P_RANDOM 131 // cards #define CARDFONTX 4 diff --git a/rc.c b/rc.c index e2be9a4..480f129 100644 --- a/rc.c +++ b/rc.c @@ -1785,6 +1785,19 @@ int movesprite(sprite_t *s) { 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 */ if (s->doomcount) { if (player->powerup != PW_GUNNER) { @@ -6816,6 +6829,11 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) { modscore = addscore(giveto, gotscore); } + if (fruit->id == P_RANDOM) { + // change id to whatever it currently looks like + fruit->id = fruit->timer1; + } + /* handle fruit effects */ if (!dofruiteffect(fruit)) { playfx(FX_FRUIT); diff --git a/shared.c b/shared.c index 60bb496..2e9ee99 100644 --- a/shared.c +++ b/shared.c @@ -613,7 +613,10 @@ void setdefaults(sprite_t *s) { s->jumpspeed = 0; s->jumpdir = 1; 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->timer3 = 0; s->timer4 = 0; @@ -721,13 +724,26 @@ sprite_t *addsprite(int id, int x, int y, char *name ) { } + s->id = id; s->x = x; 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) { s->img = rotozoomSurfaceXY(imageset[id].img[F_WALK1],0,0.1,0.1,0); } else if (s->id == P_PINKCLOUD) { 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 { s->img = imageset[id].img[F_WALK1]; } @@ -781,6 +797,7 @@ sprite_t *addsprite(int id, int x, int y, char *name ) { #endif + s->next = NULL; lastsprite = s; @@ -1187,6 +1204,9 @@ int loadimagesets(void) { loadspriteimage(P_SPEED,F_WALK1, "sprites/speed.png"); 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"); imageset[P_NUMNETS].numimages = 1; @@ -1784,6 +1804,9 @@ void drawsprite(sprite_t *s) { s->img = imageset[s->timer1].img[F_WALK1]; } else if (s->id == P_FIVECARDS) { // 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)) { // select image based on sprite id s->img = imageset[s->id].img[frame]; @@ -2121,6 +2144,7 @@ int isfruit(int id) { case P_GUN: case P_ZAPPOWERUP: case P_SKULL: + case P_RANDOM: return FT_TEMP; /* flowers */ case P_FLOWERYELLOW: @@ -2738,7 +2762,7 @@ int loadlevellist(void) { int randompowerup(void) { int num; - num = rand() % 33; + num = rand() % 34; switch (num) { case 0: @@ -2813,6 +2837,8 @@ int randompowerup(void) { return P_GUN; case 32: 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_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_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("Temporary Powerups\n"); for (i = 0; i < MAXPTYPES; i++) { if (isfruit(i) == FT_TEMP) { - printf("
%s%s\n", - spriteinfo[i].file, spriteinfo[i].name,spriteinfo[i].desc); + if (i == P_RANDOM) { + printf("?
%s%s\n", + spriteinfo[i].name,spriteinfo[i].desc); + } else { + printf("
%s%s\n", + spriteinfo[i].file, spriteinfo[i].name,spriteinfo[i].desc); + } } } // super powerup diff --git a/website/info.html b/website/info.html index d6f766f..1befc2f 100644 --- a/website/info.html +++ b/website/info.html @@ -48,6 +48,7 @@
SkullAvoid these at all costs! The skull will cause you to lose all net powerups.
GunnerTemporarily equips you with a super powerful machine gun!
Bug ZapperZaps nearby enemies with miniature bolts of lightning +?
RandomGives you a random effect... Super Powerups
Big Speed UpMakes you walk faster, permenantly!
Big More NetsPermenantly gives you two nets, even after death