From fe76098363b5572add3359efec54ce56f1531a39 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Wed, 22 Oct 2008 21:38:56 +0000 Subject: [PATCH] - added code for testing of net collision bug --- defs.h | 3 ++- rc.c | 15 ++++++++++++--- shared.c | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/defs.h b/defs.h index a76469a..ab010c6 100644 --- a/defs.h +++ b/defs.h @@ -684,7 +684,8 @@ typedef struct sprite_s { int netlen; // how far our is our net? int nety; // y position of end of net (used when shooting >1 net) int netxstart; // x position of start of net - int netystart; // y position of start of net + int netystart; // y position of start of net when netting/slamming + int netymid; // y position of start of net when netting int netsticky; // can net pick up powerups? int powerup; // what temp powerup does the player have? diff --git a/rc.c b/rc.c index 719b060..e7e3db3 100644 --- a/rc.c +++ b/rc.c @@ -1372,9 +1372,9 @@ void checkcollide(sprite_t *s) { netsleft = s->netmax - s->netcaught; if (netsleft > 1) { ythresh += ((int)s->img->h / (int)(netsleft+1) ); - if (ythresh > TILEH*2) { + if (ythresh > TILEH*3) { printf("*DEBUG2* ythresh too high: %0.0f\n",ythresh); - ythresh = TILEH*2; + ythresh = TILEH*3; } } @@ -1382,6 +1382,9 @@ void checkcollide(sprite_t *s) { if ((xdiff <= s2->img->w/2) && (ydiff <= ythresh)) { // we hit something! + printf("caught: s='%s',%0.0f,%0.0f s2='%s',%0.0f,%0.0f\n", + s->name, s->x, s->y, s2->name,s2->x,s2->y); + if (s->netsticky && isfruit(s2->id)) { getfruit(s, s2, 1); } else { @@ -3796,10 +3799,12 @@ void drawnetting(sprite_t *s) { sx = s->x; s->nety = s->y - (s->img->h/2) + 2; + s->netymid = s->nety - 3; s->netxstart = s->x; s->netystart = s->nety - 3; + if (s->netdir == 1) { area.x = s->netxstart + TILEW/2; } else { @@ -7116,7 +7121,7 @@ void trytoshoot(sprite_t *pl) { } } - } else { + } else { // not holding down - try to shoot net if ((pl->netcaught < pl->netmax) && (pl->climbing == B_FALSE)) { // handle cannon if (pl->powerup == PW_CANNON) { @@ -7139,6 +7144,10 @@ void trytoshoot(sprite_t *pl) { } pl->netlen = 0; pl->netdir = pl->dir; + + // set up initial... + pl->nety = pl->y - (pl->img->h/2) + 2; + pl->netymid = pl->nety - 3; } diff --git a/shared.c b/shared.c index 579173d..311e330 100644 --- a/shared.c +++ b/shared.c @@ -1809,6 +1809,12 @@ void killsprite(sprite_t *s) { mask = NULL; } + if (s->caughtby) { + s->caughtby = NULL; + s->caughtstate = B_FALSE; + player->netcaught--; + } + /* remove references to this sprite before removing it */ for (s2 = sprite ; s2 ; s2 = s2->next) { if (s2->owner == s) {