Fixed spider movement with 2 players
This commit is contained in:
parent
33e18504e0
commit
a5d477197c
1
defs.h
1
defs.h
|
@ -164,6 +164,7 @@
|
||||||
#define BIGNETSPEED 12 // how fast the player's net moves with bignet
|
#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 ACCNETSPEED 28 // how fast the player's net moves with accordion
|
||||||
#define POWERUPTIME 15 // # secs before a powerup appears
|
#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
|
#define PLAYERFAST 2 // how fast player goes with speed powerup
|
||||||
|
|
||||||
|
|
26
rc.c
26
rc.c
|
@ -2888,7 +2888,7 @@ int movesprite(sprite_t *s) {
|
||||||
|
|
||||||
|
|
||||||
/* distance to closest player */
|
/* distance to closest player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
// tile in front and below
|
// tile in front and below
|
||||||
|
@ -2986,7 +2986,7 @@ int movesprite(sprite_t *s) {
|
||||||
int xdiff, absxdiff;
|
int xdiff, absxdiff;
|
||||||
|
|
||||||
/* distance to closest player */
|
/* distance to closest player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
tt = gettileat(s->x + s->dir+getspeed(s) + (s->dir * (s->img->w/2)),s->y,NULL,NULL);
|
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 */
|
/* distance to closest player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
||||||
|
@ -3528,7 +3528,7 @@ int movesprite(sprite_t *s) {
|
||||||
|
|
||||||
|
|
||||||
/* distance to player */
|
/* distance to player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
||||||
|
@ -3613,7 +3613,7 @@ int movesprite(sprite_t *s) {
|
||||||
|
|
||||||
|
|
||||||
/* distance to player */
|
/* distance to player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
tt = gettileat(s->x + s->dir+getspeed(s),s->y,NULL,NULL);
|
||||||
|
@ -3848,7 +3848,7 @@ int movesprite(sprite_t *s) {
|
||||||
tiletype_t *tunder;
|
tiletype_t *tunder;
|
||||||
|
|
||||||
/* distance to player */
|
/* distance to player */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, NULL);
|
||||||
absxdiff = abs(xdiff);
|
absxdiff = abs(xdiff);
|
||||||
|
|
||||||
// tile in front and below
|
// tile in front and below
|
||||||
|
@ -4010,13 +4010,14 @@ int movesprite(sprite_t *s) {
|
||||||
} else {
|
} else {
|
||||||
int move = B_FALSE;
|
int move = B_FALSE;
|
||||||
int xdiff;
|
int xdiff;
|
||||||
|
sprite_t *pp ;
|
||||||
/* walk back and forwards */
|
/* walk back and forwards */
|
||||||
|
|
||||||
/* drop if player is close */
|
/* drop if player is close */
|
||||||
xdiff = getxdisttoplayer(s);
|
xdiff = getxdisttoplayer(s, &pp);
|
||||||
xdiff = abs(xdiff);
|
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->timer1 = 200;
|
||||||
s->flies = B_FALSE;
|
s->flies = B_FALSE;
|
||||||
s->falling = B_TRUE;
|
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;
|
double xdiff1,xdiff2,xdiff;
|
||||||
/* distance to closest player */
|
/* distance to closest player */
|
||||||
if (player) {
|
if (player) {
|
||||||
xdiff1 = player->x - s->x;
|
xdiff1 = abs(player->x - s->x);
|
||||||
} else {
|
} else {
|
||||||
xdiff1 = 9999;
|
xdiff1 = 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player2) {
|
if (player2) {
|
||||||
xdiff2 = player2->x - s->x;
|
xdiff2 = abs(player2->x - s->x);
|
||||||
} else {
|
} else {
|
||||||
xdiff2 = 9999;
|
xdiff2 = 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xdiff1 < xdiff2) {
|
if (xdiff1 < xdiff2) {
|
||||||
xdiff = xdiff1;
|
xdiff = xdiff1;
|
||||||
|
if (pl != NULL) *pl = player;
|
||||||
} else {
|
} else {
|
||||||
xdiff = xdiff2;
|
xdiff = xdiff2;
|
||||||
|
if (pl != NULL) *pl = player2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return xdiff;
|
return xdiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
rc.h
2
rc.h
|
@ -112,7 +112,7 @@ void swimup(sprite_t *pl);
|
||||||
void swimdown(sprite_t *pl);
|
void swimdown(sprite_t *pl);
|
||||||
double getdistance(double x1, double y1, double x2, double y2);
|
double getdistance(double x1, double y1, double x2, double y2);
|
||||||
void doplayermovement(sprite_t *pl);
|
void doplayermovement(sprite_t *pl);
|
||||||
double getxdisttoplayer(sprite_t *s);
|
double getxdisttoplayer(sprite_t *s, sprite_t **pl);
|
||||||
double getydisttoplayer(sprite_t *s);
|
double getydisttoplayer(sprite_t *s);
|
||||||
int playersalive(void);
|
int playersalive(void);
|
||||||
int inintro(void);
|
int inintro(void);
|
||||||
|
|
14
shared.c
14
shared.c
|
@ -96,7 +96,11 @@ int loadlevel(int lnum, int wantmonsters) {
|
||||||
level->hurryuptime = 30;
|
level->hurryuptime = 30;
|
||||||
if (cheat) {
|
if (cheat) {
|
||||||
level->poweruptime = 5;
|
level->poweruptime = 5;
|
||||||
} else level->poweruptime = POWERUPTIME;
|
} else if (getnumplayers() >= 2) {
|
||||||
|
level->poweruptime = POWERUPTIME2;
|
||||||
|
} else {
|
||||||
|
level->poweruptime = POWERUPTIME;
|
||||||
|
}
|
||||||
level->p1x = 0;
|
level->p1x = 0;
|
||||||
level->p1y = 0;
|
level->p1y = 0;
|
||||||
level->powerupx = -1;
|
level->powerupx = -1;
|
||||||
|
@ -4026,3 +4030,11 @@ int playersalive(void) {
|
||||||
if (player2 && player2->dead && player2->lives > 0) return B_FALSE;
|
if (player2 && player2->dead && player2->lives > 0) return B_FALSE;
|
||||||
return B_TRUE;
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getnumplayers(void) {
|
||||||
|
int num = 0;
|
||||||
|
if (player) num++;
|
||||||
|
if (player2) num++;
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
3
shared.h
3
shared.h
|
@ -65,7 +65,8 @@ void drawplayer(sprite_t *s, SDL_Rect *where);
|
||||||
void resethurryup(level_t *lev);
|
void resethurryup(level_t *lev);
|
||||||
int isplayer(sprite_t *s);
|
int isplayer(sprite_t *s);
|
||||||
int isplayer(sprite_t *s);
|
int isplayer(sprite_t *s);
|
||||||
int playersalive();
|
int playersalive(void);
|
||||||
|
int getnumplayers(void);
|
||||||
// for doco
|
// for doco
|
||||||
void setfruitinfo(void);
|
void setfruitinfo(void);
|
||||||
void setinfo(int id, char *name, char *desc, char *file);
|
void setinfo(int id, char *name, char *desc, char *file);
|
||||||
|
|
Loading…
Reference in New Issue