diff --git a/defs.h b/defs.h index 3a58f2f..53d8292 100644 --- a/defs.h +++ b/defs.h @@ -164,6 +164,7 @@ #define BIGNETSPEED 12 // how fast the player's net moves with bignet #define ACCNETSPEED 28 // how fast the player's net moves with accordion #define POWERUPTIME 15 // # secs before a powerup appears +#define POWERUPTIME2 10 // # secs before a powerup appears #define PLAYERFAST 2 // how fast player goes with speed powerup diff --git a/rc.c b/rc.c index 93e0fd1..09bc3b6 100644 --- a/rc.c +++ b/rc.c @@ -2888,7 +2888,7 @@ int movesprite(sprite_t *s) { /* distance to closest player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); // tile in front and below @@ -2986,7 +2986,7 @@ int movesprite(sprite_t *s) { int xdiff, absxdiff; /* distance to closest player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); tt = gettileat(s->x + s->dir+getspeed(s) + (s->dir * (s->img->w/2)),s->y,NULL,NULL); @@ -3067,7 +3067,7 @@ int movesprite(sprite_t *s) { /* distance to closest player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL); @@ -3528,7 +3528,7 @@ int movesprite(sprite_t *s) { /* distance to player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL); @@ -3613,7 +3613,7 @@ int movesprite(sprite_t *s) { /* distance to player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL); @@ -3848,7 +3848,7 @@ int movesprite(sprite_t *s) { tiletype_t *tunder; /* distance to player */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, NULL); absxdiff = abs(xdiff); // tile in front and below @@ -4010,13 +4010,14 @@ int movesprite(sprite_t *s) { } else { int move = B_FALSE; int xdiff; + sprite_t *pp ; /* walk back and forwards */ /* drop if player is close */ - xdiff = getxdisttoplayer(s); + xdiff = getxdisttoplayer(s, &pp); xdiff = abs(xdiff); - if (isplayerbelow(s) && (xdiff <= (TILEW*2)) && (s->timer1 == 0)) { + if ((pp->y > s->y) && (xdiff <= (TILEW*2)) && (s->timer1 == 0)) { s->timer1 = 200; s->flies = B_FALSE; s->falling = B_TRUE; @@ -11365,27 +11366,30 @@ void doplayermovement(sprite_t *pl) { } } -double getxdisttoplayer(sprite_t *s) { +double getxdisttoplayer(sprite_t *s, sprite_t **pl) { double xdiff1,xdiff2,xdiff; /* distance to closest player */ if (player) { - xdiff1 = player->x - s->x; + xdiff1 = abs(player->x - s->x); } else { xdiff1 = 9999; } if (player2) { - xdiff2 = player2->x - s->x; + xdiff2 = abs(player2->x - s->x); } else { xdiff2 = 9999; } if (xdiff1 < xdiff2) { xdiff = xdiff1; + if (pl != NULL) *pl = player; } else { xdiff = xdiff2; + if (pl != NULL) *pl = player2; } + return xdiff; } diff --git a/rc.h b/rc.h index 3664cee..3476374 100644 --- a/rc.h +++ b/rc.h @@ -112,7 +112,7 @@ void swimup(sprite_t *pl); void swimdown(sprite_t *pl); double getdistance(double x1, double y1, double x2, double y2); void doplayermovement(sprite_t *pl); -double getxdisttoplayer(sprite_t *s); +double getxdisttoplayer(sprite_t *s, sprite_t **pl); double getydisttoplayer(sprite_t *s); int playersalive(void); int inintro(void); diff --git a/shared.c b/shared.c index 774b169..cb98381 100644 --- a/shared.c +++ b/shared.c @@ -96,7 +96,11 @@ int loadlevel(int lnum, int wantmonsters) { level->hurryuptime = 30; if (cheat) { level->poweruptime = 5; - } else level->poweruptime = POWERUPTIME; + } else if (getnumplayers() >= 2) { + level->poweruptime = POWERUPTIME2; + } else { + level->poweruptime = POWERUPTIME; + } level->p1x = 0; level->p1y = 0; level->powerupx = -1; @@ -4026,3 +4030,11 @@ int playersalive(void) { if (player2 && player2->dead && player2->lives > 0) return B_FALSE; return B_TRUE; } + +int getnumplayers(void) { + int num = 0; + if (player) num++; + if (player2) num++; + + return num; +} diff --git a/shared.h b/shared.h index 1dd96a1..1e7c4c5 100644 --- a/shared.h +++ b/shared.h @@ -65,7 +65,8 @@ void drawplayer(sprite_t *s, SDL_Rect *where); void resethurryup(level_t *lev); int isplayer(sprite_t *s); int isplayer(sprite_t *s); -int playersalive(); +int playersalive(void); +int getnumplayers(void); // for doco void setfruitinfo(void); void setinfo(int id, char *name, char *desc, char *file);