New powerup: winged boots (allows you to double-jump)

This commit is contained in:
Rob Pearce 2008-10-18 04:49:08 +00:00
parent 53e373c1b4
commit 26e91e1da1
4 changed files with 55 additions and 10 deletions

BIN
data/sprites/wingboots.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

6
defs.h
View File

@ -285,7 +285,7 @@
#define S_SLOPE 2
// Sprite types
#define MAXPTYPES 120
#define MAXPTYPES 121
#define P_PLAYER 0
#define P_RAT 1
#define P_CHEESE 2
@ -411,6 +411,7 @@
#define P_FIVECARDS 117
#define P_CLOVER 118
#define P_ACCORDION 119
#define P_WINGBOOTS 120
// cards
#define CARDFONTX 4
@ -674,6 +675,9 @@ typedef struct sprite_s {
int netbig; // have we collected a BIG NET powerup?
int hasbell; // got a bell ?
int hasmask; // got scuba mask?
int doublejump; // have we collected a doublejump powerup?
int useddoublejump;
// player cards
int numcards;

42
rc.c
View File

@ -74,6 +74,7 @@ int poweruptypes[] = {
P_NUMNETS,
P_GEMBOOST,
P_HELMET,
P_WINGBOOTS,
-1
};
@ -921,10 +922,19 @@ void jump(sprite_t *s, int dir) {
// if we've ust been hit with armour, bypass all these checks)
if (!s->recoiling) {
// can't jump if already jumping
if (s->jumping) return;
if (s->jumping) {
// unless we have the doublejump powerup
if (!s->doublejump) {
return;
}
}
if (s->jumptimer) return;
// can only jump up when climbing
if (s->doublejump && s->falling && s->useddoublejump) {
return;
}
// can only jump sideways when climbing
if (s->climbing && (dir == 0)) {
return;
}
@ -932,7 +942,7 @@ void jump(sprite_t *s, int dir) {
// check for recoiling here, because we always need to be able to
// "jump" backwards, even if already jumping
if (s->recoiling || isonground(s) || isinwater(s) || isonladder(s)) {
if (s->recoiling || isonground(s) || isinwater(s) || isonladder(s) || s->doublejump) {
if (ismonster(s->id)) {
if (s->recoiling) { // recoiling monsters don't pause before jumping
s->jumpspeed = MONJUMPSPEED;
@ -962,6 +972,12 @@ void jump(sprite_t *s, int dir) {
s->dir = s->jumpdir;
}
// used up the doublejump
if ((s->doublejump) && (s->falling)) {
s->useddoublejump = B_TRUE;
puffin(-1, s->x, s->y, "nothing", 0);
}
// if on rollers, they add to your inertia
// if you are facing their direction
tt= gettileat(s->x, s->y, NULL, NULL);
@ -4126,6 +4142,13 @@ void dogravity(sprite_t *s) {
}
if (ontheground) {
// reset doublejump
if (s->doublejump) {
s->useddoublejump = B_FALSE;
}
if (s->falling && s->iced) {
// when an iced monster hits the ground, it smashes
s->willbecome = P_DIAMOND;
@ -5004,9 +5027,14 @@ int dofruiteffect(sprite_t *s) {
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM);
player->powerup = PW_ACCORDION;
return B_TRUE;
} else if (s->id == P_WINGBOOTS) {
playfx(FX_POWERUP);
sprintf(tempm, "Double jump!");
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM);
player->doublejump = B_TRUE;
return B_TRUE;
} else if (s->id == P_HELP) {
playfx(FX_POWERUP);
// TODO: move other HELP text around if need be!
addoutlinetext(320,240,TEXTSIZE_HELP, s->name, &white,&black,HELPDELAY,TT_HELP);
return B_TRUE;
} else if (iscard(s->id)) {
@ -6701,9 +6729,9 @@ void trytojump(sprite_t *pl) {
}
} else { // not in water
// jump
if (!pl->jumping) {
if (!pl->falling) {
if (isonground(pl) || isonladder(pl)) {
if (!pl->jumping) {
if (!pl->falling || (pl->doublejump && pl->falling && (pl->fallspeed == 0))) {
if (isonground(pl) || isonladder(pl) || pl->doublejump ) {
/* dropping through a bridge */
if (keydown(SDLK_DOWN)) {
if (isonbridge(pl) && !pl->falling) {

View File

@ -585,6 +585,12 @@ void setdefaults(sprite_t *s) {
s->netsticky = B_FALSE;
}
s->doublejump = B_FALSE;
s->frame = 0;
s->hasmask = B_FALSE;
@ -604,6 +610,7 @@ void setdefaults(sprite_t *s) {
s->jumping = 0;
s->jumpspeed = 0;
s->jumpdir = 1;
s->useddoublejump = B_FALSE;
s->timer1 = 0;
s->timer2 = 0;
s->timer3 = 0;
@ -1274,6 +1281,9 @@ int loadimagesets(void) {
loadspriteimage(P_ACCORDION,F_WALK1, "sprites/accordion.png");
imageset[P_ACCORDION].numimages = 1;
loadspriteimage(P_WINGBOOTS,F_WALK1, "sprites/wingboots.png");
imageset[P_WINGBOOTS].numimages = 1;
loadspriteimage(P_BIGSPEED,F_WALK1, "sprites/bigspeed.png");
imageset[P_BIGSPEED].numimages = 1;
@ -1866,6 +1876,7 @@ int isfruit(int id) {
case P_HELMET:
case P_BIGSPEED:
case P_MASKPOWERUP:
case P_WINGBOOTS:
return FT_PERM;
/* one-off level only powerups */
case P_BOXING:
@ -2496,7 +2507,7 @@ int loadlevellist(void) {
int randompowerup(void) {
int num;
num = rand() % 29;
num = rand() % 30;
switch (num) {
case 0:
@ -2558,6 +2569,8 @@ int randompowerup(void) {
return P_CLOVER;
case 28:
return P_ACCORDION;
case 29:
return P_WINGBOOTS;
}
}
@ -2666,7 +2679,7 @@ void setfruitinfo(void) {
setinfo(P_HELMET, "Helmet","Gives you a suit of armour which will protect you from death.", "helmet.png");
setinfo(P_BIGSPEED, "Big Speed Up", "Makes you walk faster, permenantly!", "bigspeed.png");
setinfo(P_MASKPOWERUP, "Scuba Mask", "Allows you to move fast underwater.", "maskpowerup.png");
setinfo(P_WINGBOOTS, "Winged Boots", "These magical boots allow to you jump again at the peak of your jump!", "wingboots.png");
setinfo(P_BOXING, "Boxing Glove", "Your net will punch monsters, killing them instantly.", "boxing.png");
setinfo(P_MACEPOWERUP, "Mace", "Slamming your net will cause a lethal explosion!", "macepowerup.png");