- added code for testing of net collision bug

This commit is contained in:
Rob Pearce 2008-10-22 21:38:56 +00:00
parent 420eaeb6ee
commit fe76098363
3 changed files with 20 additions and 4 deletions

3
defs.h
View File

@ -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?

15
rc.c
View File

@ -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;
}

View File

@ -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) {