From 26e91e1da1bce2dd2eb7ec92693c3a43be3211f1 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Sat, 18 Oct 2008 04:49:08 +0000 Subject: [PATCH] New powerup: winged boots (allows you to double-jump) --- data/sprites/wingboots.png | Bin 0 -> 1042 bytes defs.h | 6 +++++- rc.c | 42 ++++++++++++++++++++++++++++++------- shared.c | 17 +++++++++++++-- 4 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 data/sprites/wingboots.png diff --git a/data/sprites/wingboots.png b/data/sprites/wingboots.png new file mode 100644 index 0000000000000000000000000000000000000000..83d9c8f04581dabfdf9dc64f5cc30af70fcfdf05 GIT binary patch literal 1042 zcmV+t1nv8YP)b!O$*z*g*+hz?t&EaizQJl1I%*? zHXZ`iat!l{A?wbRe|%e(O$Hwv6rGJ_^NlF&;-yYbO>JI7XlQ6`NE{v$2E}a@=%83yu&7x3`#U|?YT*qZCej}Qko@PToP}RpJs9+kD_&4J+kFk_kS1_& zaJ-;$=;-M5l`PQE(EHq;z`(%$@2=e3+~0x}dr~1!O*rxK@gN`|zPX6+nlw;QQ2P4% z^_)5Noj23d)2XScPC_sJ{r#F}DaeL3!^6YffD!heIpX5t``Vn2Ne2AnrS9(T*pN9s zH74<$H}#n@wzjtRp**m#u{ zTm0gqqg)5`ktg<@I=*WNkB^V`pFGyq*5BXX>XIq#moVk!<@?~Gl~e}wlPTHR+3nq- z?&zvpF9VK+V0CqMTQv~UZVGHZ6TV{!_M<@ZiyxO$4)l*K;(QgJm~X{#9bZ^XwPX+C zk~3j81?GSd>+9?O__p4B4E^n_<9-f%PaWxs9-fL;#2d9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliru*a{K{0x*-g z_xu0=0E1F#mtnFQsM>) zGx+|20)|cj5MW_|0recoiling) { // 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) { diff --git a/shared.c b/shared.c index ef8bb50..5e965fe 100644 --- a/shared.c +++ b/shared.c @@ -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");