Changed 'sticky net' to pull fruits towards you, rather than instantly collecting them.

This commit is contained in:
Rob Pearce 2016-07-29 12:25:09 +12:00
parent f14d276c3a
commit ecf521771a
5 changed files with 45 additions and 8 deletions

2
defs.h
View File

@ -1160,6 +1160,8 @@ typedef struct sprite_s {
SDL_Surface *img; // current graphic image
SDL_Surface *netbg; // temp storage for area behind net
int allocimg; // have we allocated a special image?
int caughtdelay;
// LINKED LIST STUFF
struct sprite_s *next;

44
rc.c
View File

@ -2329,6 +2329,17 @@ void checklevelend(void) {
}
}
int countcaughtfruits(sprite_t *who) {
sprite_t *s;
int count = 0;
for (s = sprite ; s ; s = s->next) {
if ((s != who) && isfruit(s->id) && (s->caughtby == who)) {
count++;
}
}
return count;
}
int countfruits(void) {
sprite_t *s2;
int mcount;
@ -2547,8 +2558,8 @@ void checkcollide(sprite_t *s) {
if (s2 == s) continue;
else if (s->dead) continue;
else if (s2->dead) continue;
else if (s->caughtby) continue;
else if (s2->caughtby) continue;
else if (s->caughtby && !isfruit(s->id)) continue;
else if (s2->caughtby && !isfruit(s2->id)) continue;
else if (s2->teleporting) continue;
else if (iseffect(s2->id)) continue;
@ -2596,10 +2607,17 @@ void checkcollide(sprite_t *s) {
//if ((xdiff <= s2->img->w/2) && (ydiff <= s2->img->h)) {
if ((xdiff <= xthresh) && (ydiff <= ythresh)) {
// we hit something!
if (s->netsticky && isfruit(s2->id) && !s2->caughtby) {
//ooooooooo
//getfruit(s, s2, 1);
// delay movement back with net a little.
s2->caughtdelay = (countcaughtfruits(s) * (TILEW/2));
printf("%s caughtdelay = %d\n",s2->name, s2->caughtdelay);
if (s->netsticky && isfruit(s2->id)) {
getfruit(s, s2, 1);
// grab it, but don't use up one of our nets.
s2->caughtby = s;
s2->caughtstate = C_NETTING;
} else {
// Otherwise, it must be a monster
@ -2991,8 +3009,13 @@ int movesprite(sprite_t *s) {
/* stay at position of net */
s->y = s->caughtby->y;
if (s->caughtstate == C_NETTING) {
// at the end of the player's net
s->x = s->caughtby->x + (s->caughtby->netlen*s->caughtby->netdir);
if (isfruit(s->id)) {
s->x += (s->caughtdelay * s->caughtby->netdir);
}
} else {
// behind the player's back
s->x = s->caughtby->x + (s->caughtby->img->w/2) * -(s->caughtby->dir);
}
}
@ -11220,7 +11243,6 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) {
/* kill the fruit */
fruit->dead = D_FINAL;
// 100x points at endgame
if (endgame) {
gotscore *= 100;
@ -11240,21 +11262,29 @@ void getfruit(sprite_t *giveto, sprite_t *fruit, int multiplier) {
/* handle fruit effects */
if (!dofruiteffect(giveto, fruit)) {
int pointsx,pointsy;
playfx(FX_FRUIT);
col = getcolour(fruit->id);
bgcol = getbgcolour(fruit->id);
pointsx = fruit->x;
pointsy = fruit->y - fruit->img->h/2;
if (fruit->caughtby) {
// offset a little.
pointsx += (fruit->caughtdelay * fruit->caughtby->netdir);
pointsy -= (fruit->caughtdelay/4);
}
if (multiplier <= 1) {
addcommas(tempm, modscore);
//sprintf(tempm, "%d", modscore);
if (modscore > 0) {
addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS, tempm, col,bgcol,POINTSDELAY,TT_NORM);
addoutlinetext(pointsx,pointsy, TEXTSIZE_POINTS, tempm, col,bgcol,POINTSDELAY,TT_NORM);
}
} else {
addcommas(tempm, modscore);
sprintf(tempm2, "%s x %d" , tempm,multiplier);
if (modscore > 0) {
addoutlinetext(fruit->x,fruit->y - fruit->img->h/2, TEXTSIZE_POINTS + 2*multiplier, tempm2, col,bgcol,POINTSDELAY,TT_NORM);
addoutlinetext(pointsx,pointsy, TEXTSIZE_POINTS + 2*multiplier, tempm2, col,bgcol,POINTSDELAY,TT_NORM);
}
}

1
rc.h
View File

@ -51,6 +51,7 @@ void channeldone(int channel);
int moveto(sprite_t *p, int dstx, int dsty, double xspeed,double yspeed);
SDL_Surface *grabbehind(sprite_t *s, SDL_Surface *surf);
void dumpsprites(void);
int countcaughtfruits(sprite_t *who);
int countfruits(void);
int countmonsters(int montype);
int countsprites(int montype);

View File

@ -1026,6 +1026,7 @@ void setdefaults(sprite_t *s) {
s->caughtby = NULL;
s->caughtstate = B_FALSE;
s->caughtdelay = 0;
s->zapping = NULL;
@ -1113,7 +1114,6 @@ sprite_t *addsprite(int id, int x, int y, char *name ) {
s->usedcard[c] = 0;
}
setdefaults(s);
// initial fruits don't time out

4
todo
View File

@ -1,5 +1,8 @@
- animate players hanging from umbrellas ?
- if drawing a score text on the same location as another score text,
delay it by a little ?
- make points worth chasing for something more than a high schore
- bonus level teleport appears on next level once you
reach a certain amount of points ?
@ -14,6 +17,7 @@
..triple walk speed?
..spike boots to jump on monsters
..50% chance to skip two levels each time?
.. shortcut to skip directly to start of next world?
- Make level editor work again in opengl
- add help to level editor!