From d9963652c8ba49dfd03cf57b03dd8eaf3d9e0d9b Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Wed, 14 Aug 2013 10:46:53 +0000 Subject: [PATCH] - [+] plants now shoot upwards if you are above and near (similar to spider drop code) - [+] projectile is vertical fireball - [+] use code similar to snake - [+] only allowed to shoot if s->bullet = null - [+] always use open mouth frame if s->bullet - [+] bullet has initial negative y velocity and is affected by gravity - [+] once it is lower than its initial y point, it dies.... - [+] ...and update owner->bullet = null --- rc.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ scripts/makesnaps.sh | 5 +++++ shared.c | 18 ++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100755 scripts/makesnaps.sh diff --git a/rc.c b/rc.c index 2dc4fed..94e5a7a 100644 --- a/rc.c +++ b/rc.c @@ -3448,6 +3448,14 @@ int movesprite(sprite_t *s) { // die s->dead = D_FINAL; } + } else if (s->id == P_FIREUP) { // vertical fireball + s->y = s->y + s->ys; + s->ys += 0.1; + // if lower than starting y position & moving down + if ((s->y >= s->timer1) && (s->ys > 0)) { + // die + s->dead = D_FINAL; + } } else if ((s->id == P_METEOR) || (s->id == P_FALLINGBRICK)) { // meteor double oldy; @@ -4265,8 +4273,49 @@ int movesprite(sprite_t *s) { rv = movex(s, s->dir*getspeed(s), B_TRUE); } } else if (s->id == P_PLANT) { + /* timer1 loopsfrom 0 - 19 + + if timer1 is 0, we can shoot. if it is 1, we can't. + + */ + // don't move! s->moved = MV_WALK; + + + if (!s->falling) { + int xdiff, absxdiff; + sprite_t *pp; + + /* distance to player */ + xdiff = getxdisttoplayer(s, &pp); + if (pp) { + absxdiff = abs(xdiff); + + if (!s->bullet) { + if (s->timer1 == 0) { + if ((pp->y < s->y) && (absxdiff <= (TILEW*3)) ) { + sprite_t *ss; + ss = addsprite(P_FIREUP,s->x,s->y - TILEH,"fireup" ); + ss->ys = -4; + ss->xs = 0; + ss->dir = s->dir; + + ss->owner = s; + s->bullet = ss; + + // remember our starting y pos. + ss->timer1 = ss->y; + + // reset out shoot timer + s->timer1 = 75; + } + } else { + s->timer1--; + } + } + } + } } else if (s->id == P_KINGRAT) { /* timer1 is state diff --git a/scripts/makesnaps.sh b/scripts/makesnaps.sh new file mode 100755 index 0000000..1b1c2e1 --- /dev/null +++ b/scripts/makesnaps.sh @@ -0,0 +1,5 @@ +for f in /tmp/level*.bmp ; do + newname=/tmp/`basename $f .bmp`.png + convert $f -geometry 160x120 ${newname} + echo "done $newname." +done diff --git a/shared.c b/shared.c index 3ed70f0..44b6ec3 100644 --- a/shared.c +++ b/shared.c @@ -2193,6 +2193,22 @@ void drawsprite(sprite_t *s) { } else if (s->id == P_FALLINGBRICK) { // only 1 frame frame = F_WALK1; + } else if (s->id == P_FIREUP) { + if (s->ys < 0) { + // going up + if ((timer/6) % 2 == 0) { + frame = F_WALK1; + } else { + frame = F_JUMP; + } + } else { + // going down + if ((timer/6) % 2 == 0) { + frame = F_FALL; + } else { + frame = F_CAUGHT; + } + } } else { if ((timer/6) % 2 == 0) { frame = F_WALK1; @@ -2386,6 +2402,8 @@ void drawsprite(sprite_t *s) { } else { frame = F_SLAM5; } + } else if ((s->id == P_PLANT) && s->bullet) { //shooting plant + frame = F_JUMP; // ie. mouth open } else if (!s->teleporting) { if ((s->id == P_SPIDER) && (s->ys != -99)) { frame = F_FALL;