Fixed bug with player2 and scuba mask

Added armour images for player 2
This commit is contained in:
Rob Pearce 2008-11-12 05:06:32 +00:00
parent 9805d3c503
commit aa2ddf538e
21 changed files with 57 additions and 24 deletions

BIN
data/sprites/armor2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

BIN
data/sprites/armor2fall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

BIN
data/sprites/armor2jump.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 991 B

After

Width:  |  Height:  |  Size: 969 B

BIN
data/sprites/dwarf2head.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

4
defs.h
View File

@ -325,7 +325,7 @@
#define S_SLOPE 2 #define S_SLOPE 2
// Sprite types // Sprite types
#define MAXPTYPES 135 #define MAXPTYPES 136
#define P_PLAYER 0 #define P_PLAYER 0
#define P_RAT 1 #define P_RAT 1
#define P_CHEESE 2 #define P_CHEESE 2
@ -466,6 +466,7 @@
#define P_PLATFORM 132 #define P_PLATFORM 132
#define P_FLY 133 #define P_FLY 133
#define P_PLAYER2 134 #define P_PLAYER2 134
#define P_ARMOUR2 135 // player 2 wearing armour
#define FLY_FLYTIME 150 #define FLY_FLYTIME 150
@ -882,6 +883,7 @@ imageset_t imageset[MAXPTYPES];
extern char progname[]; extern char progname[];
extern SDL_Color black; extern SDL_Color black;
extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube; extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube;
extern SDL_Surface *head2,*head52;
extern SDL_Surface *healthbar[]; extern SDL_Surface *healthbar[];
extern SDL_Surface *greenbox, *redbox; extern SDL_Surface *greenbox, *redbox;
extern sprite_t *sprite, *lastsprite, *player, *player2, *boss; extern sprite_t *sprite, *lastsprite, *player, *player2, *boss;

View File

@ -31,6 +31,7 @@ SDL_Surface *levelbg; // level background image
SDL_Surface *temps; // temporary surface SDL_Surface *temps; // temporary surface
SDL_Surface *screen; // the actual video screen SDL_Surface *screen; // the actual video screen
SDL_Surface *head,*head5; // imgs in corner showing number of lives SDL_Surface *head,*head5; // imgs in corner showing number of lives
SDL_Surface *head2,*head52; // imgs in corner showing number of lives
SDL_Surface *icecube; // overlaid on frozen monsters SDL_Surface *icecube; // overlaid on frozen monsters
SDL_Surface *greenbox; // for fly spray effect SDL_Surface *greenbox; // for fly spray effect
SDL_Surface *redbox; // for gunner SDL_Surface *redbox; // for gunner

46
rc.c
View File

@ -354,7 +354,7 @@ int main (int argc, char **argv) {
srand(time(NULL)); srand(time(NULL));
} else { } else {
// cheat // cheat
want1up = B_TRUE; want1up = B_FALSE;
want2up = B_TRUE; want2up = B_TRUE;
} }
@ -2445,7 +2445,7 @@ int movesprite(sprite_t *s) {
} }
} else if (s->id == P_MASK) { // mask effect } else if (s->id == P_MASK) { // mask effect
// stay on top of player // stay on top of player
if (player->slamming) { if (s->owner->slamming) {
s->y = s->owner->y + MASKOFFSETSLAMY; s->y = s->owner->y + MASKOFFSETSLAMY;
s->x = s->owner->x + (MASKOFFSETSLAMX*s->owner->dir); s->x = s->owner->x + (MASKOFFSETSLAMX*s->owner->dir);
} else { } else {
@ -2551,7 +2551,7 @@ int movesprite(sprite_t *s) {
} else if (s->owner->powerup == PW_CANNON) { } else if (s->owner->powerup == PW_CANNON) {
int targx,targy; int targx,targy;
// try to stay behind player // try to stay behind player
targx = s->owner->x - (player->dir * 32); targx = s->owner->x - (s->owner->dir * 32);
targy = s->owner->y; targy = s->owner->y;
if (s->x < targx) { if (s->x < targx) {
s->x += 2; s->x += 2;
@ -3384,7 +3384,8 @@ int movesprite(sprite_t *s) {
} else if ((xdiff <= -(TILEW*2)) && (xdiff >= -(TILEW*3))) { } else if ((xdiff <= -(TILEW*2)) && (xdiff >= -(TILEW*3))) {
/* jump left */ /* jump left */
jump(s, -1); jump(s, -1);
} else if (s->y - player->y <= (TILEH*6)) { } else if ((player && (s->y - player->y <= (TILEH*6))) ||
(player2 && (s->y - player2->y <= (TILEH*6)))) {
if ((xdiff >= 0) && (xdiff < (TILEW*2))) { if ((xdiff >= 0) && (xdiff < (TILEW*2))) {
/* jump up */ /* jump up */
jump(s, 0); jump(s, 0);
@ -4992,25 +4993,25 @@ void drawscore(void) {
// go left correct amount // go left correct amount
numtoshow2 = numtoshow; numtoshow2 = numtoshow;
while (numtoshow2 >= 5) { while (numtoshow2 >= 5) {
area.x -= (head->w + 3); area.x -= (head2->w + 3);
numtoshow2 -= 5; numtoshow2 -= 5;
} }
for (i = 0; i < numtoshow2; i++) { for (i = 0; i < numtoshow2; i++) {
area.x -= (head->w + 3); area.x -= (head2->w + 3);
} }
// now start displaying // now start displaying
// show "x5" for lots of lives // show "x5" for lots of lives
while (numtoshow >= 5) { while (numtoshow >= 5) {
SDL_BlitSurface(head5, NULL, screen, &area); SDL_BlitSurface(head52, NULL, screen, &area);
area.x += (head->w + 3); area.x += (head2->w + 3);
numtoshow -= 5; numtoshow -= 5;
} }
for (i = 0; i < numtoshow; i++) { for (i = 0; i < numtoshow; i++) {
SDL_BlitSurface(head, NULL, screen, &area); SDL_BlitSurface(head2, NULL, screen, &area);
area.x += (head->w + 3); area.x += (head2->w + 3);
} }
@ -5610,7 +5611,6 @@ void dogravity(sprite_t *s) {
if (s->id == P_PINKCLOUD) return; if (s->id == P_PINKCLOUD) return;
if (s->id == P_TICK) printf("9 dogravity for tick\n");
// only player can move if you have a clock // only player can move if you have a clock
if (globpowerup == PW_CLOCK) { if (globpowerup == PW_CLOCK) {
if (!iseffect(s->id) && (!isplayer(s)) && !s->caughtby && !s->dead) { if (!iseffect(s->id) && (!isplayer(s)) && !s->caughtby && !s->dead) {
@ -5645,7 +5645,6 @@ if (s->id == P_TICK) printf("9 dogravity for tick\n");
} }
if (s->id == P_TICK) printf("0 dogravity for tick\n");
if (s->dead) return; if (s->dead) return;
if (s->flies && !s->iced) return; // no gravity if you fly, but ice cancels flying if (s->flies && !s->iced) return; // no gravity if you fly, but ice cancels flying
if (s->id != P_KSSHELL) { if (s->id != P_KSSHELL) {
@ -5733,7 +5732,7 @@ if (s->id == P_TICK) printf("0 dogravity for tick\n");
// get rid of the mask // get rid of the mask
for (ms = sprite; ms ; ms = ms->next) { for (ms = sprite; ms ; ms = ms->next) {
if ((ms->id == P_MASK) && (ms->owner == s)) { if ((ms->id == P_MASK) && (ms->owner == s)) {
s->dead = D_FINAL; ms->dead = D_FINAL;
break; break;
} }
} }
@ -5834,8 +5833,7 @@ if (s->id == P_TICK) printf("0 dogravity for tick\n");
} }
if ((s->id == P_KINGRAT) && (s->timer1 == KRS_FALL)) { // special case if ((s->id == P_KINGRAT) && (s->timer1 == KRS_FALL)) { // special case
// king rat drops until he is at player height // king rat drops until he is at player height
// TODO: 2player if (!playersalive() || isplayerbelow(s)) { // above player
if ((player->dead) || (s->y < player->y)) { // above player
ontheground = B_FALSE; ontheground = B_FALSE;
} else { // above player } else { // above player
s->dropping = B_FALSE; s->dropping = B_FALSE;
@ -6473,8 +6471,11 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) {
} else if (s->id == P_HELMET) { } else if (s->id == P_HELMET) {
int xx,yy; int xx,yy;
playfx(FX_ARMOR); playfx(FX_ARMOR);
// TODO: player2 if (pp == player) {
pp->id = P_ARMOUR; // change how the player looks pp->id = P_ARMOUR; // change how the player looks
} else {
pp->id = P_ARMOUR2; // change how the player looks
}
pp->armour = B_TRUE; pp->armour = B_TRUE;
sprintf(tempm, "Armour!"); sprintf(tempm, "Armour!");
addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM); addoutlinetext(s->x,s->y - s->img->h/2, TEXTSIZE_POINTS, tempm,&white,&black,POINTSDELAY, TT_NORM);
@ -6783,14 +6784,15 @@ int dofruiteffect(sprite_t *pp, sprite_t *s) {
gunorigy = pp->y; gunorigy = pp->y;
guntime = 10; guntime = 10;
gundelay = 0; // used to control shooting speed gundelay = 0; // used to control shooting speed
pp->powerup = PW_GUNNER;
// turn off netting etc // turn off netting etc
player->netting = B_FALSE; if (player) {
player->slamming = B_FALSE; player->netting = B_FALSE;
player->powerup = PW_GUNNER; player->slamming = B_FALSE;
}
if (player2) { if (player2) {
player2->netting = B_FALSE; player2->netting = B_FALSE;
player2->slamming = B_FALSE; player2->slamming = B_FALSE;
player2->powerup = PW_GUNNER;
} }
return B_TRUE; return B_TRUE;
@ -9466,7 +9468,7 @@ void startgame(void) {
if (gamemode == GM_EASY) { if (gamemode == GM_EASY) {
player2->permarmour = B_TRUE; player2->permarmour = B_TRUE;
player2->armour = B_TRUE; player2->armour = B_TRUE;
player2->id = P_ARMOUR; player2->id = P_ARMOUR2;
} else { } else {
player2->permarmour = B_FALSE; player2->permarmour = B_FALSE;
player2->armour = B_FALSE; player2->armour = B_FALSE;

View File

@ -644,7 +644,11 @@ void setdefaults(sprite_t *s) {
if (s->permarmour) { if (s->permarmour) {
s->armour = B_TRUE; s->armour = B_TRUE;
s->id = P_ARMOUR; if (s == player) {
s->id = P_ARMOUR;
} else {
s->id = P_ARMOUR2;
}
} else { } else {
s->armour = B_FALSE; s->armour = B_FALSE;
} }
@ -1106,6 +1110,10 @@ int loadimagesets(void) {
head = IMG_Load(tempfile); head = IMG_Load(tempfile);
sprintf(tempfile, "%s/sprites/dwarfhead5.png",datadir); sprintf(tempfile, "%s/sprites/dwarfhead5.png",datadir);
head5 = IMG_Load(tempfile); head5 = IMG_Load(tempfile);
sprintf(tempfile, "%s/sprites/dwarf2head.png",datadir);
head2 = IMG_Load(tempfile);
sprintf(tempfile, "%s/sprites/dwarf2head5.png",datadir);
head52 = IMG_Load(tempfile);
sprintf(tempfile, "%s/sprites/icecube.png",datadir); sprintf(tempfile, "%s/sprites/icecube.png",datadir);
icecube = IMG_Load(tempfile); icecube = IMG_Load(tempfile);
@ -1189,6 +1197,24 @@ int loadimagesets(void) {
loadspriteimage(P_ARMOUR,F_SWIM2, "sprites/armorswim2.png"); loadspriteimage(P_ARMOUR,F_SWIM2, "sprites/armorswim2.png");
imageset[P_ARMOUR].numimages = 18; imageset[P_ARMOUR].numimages = 18;
loadspriteimage(P_ARMOUR2,F_WALK1, "sprites/armor2.png");
loadspriteimage(P_ARMOUR2,F_JUMP, "sprites/armor2jump.png");
loadspriteimage(P_ARMOUR2,F_FALL, "sprites/armor2fall.png");
loadspriteimage(P_ARMOUR2,F_CAUGHT, "sprites/armor2.png");
loadspriteimage(P_ARMOUR2,F_DEAD, "sprites/dwarfdie.png"); // not used
/* next 3 are auto generated */
loadspriteimage(P_ARMOUR2,F_CLIMB1, "sprites/armor2climb1.png");
loadspriteimage(P_ARMOUR2,F_CLIMB2, "sprites/armor2climb2.png");
loadspriteimage(P_ARMOUR2,F_SHOOT, "sprites/armor2shoot.png");
loadspriteimage(P_ARMOUR2,F_SLAM1, "sprites/armor2slam1.png");
loadspriteimage(P_ARMOUR2,F_SLAM2, "sprites/armor2slam2.png");
loadspriteimage(P_ARMOUR2,F_SLAM3, "sprites/armor2slam3.png");
loadspriteimage(P_ARMOUR2,F_SLAM4, "sprites/armor2slam4.png");
loadspriteimage(P_ARMOUR2,F_SLAM5, "sprites/armor2slam5.png");
loadspriteimage(P_ARMOUR2,F_SWIM1, "sprites/armor2swim1.png");
loadspriteimage(P_ARMOUR2,F_SWIM2, "sprites/armor2swim2.png");
imageset[P_ARMOUR2].numimages = 18;
loadspriteimage(P_SNAKE,F_WALK1, "sprites/snake.png"); loadspriteimage(P_SNAKE,F_WALK1, "sprites/snake.png");
loadspriteimage(P_SNAKE,F_JUMP, "sprites/snakejump.png"); loadspriteimage(P_SNAKE,F_JUMP, "sprites/snakejump.png");
@ -2928,6 +2954,8 @@ int randompowerup(void) {
int num; int num;
num = rand() % 34; num = rand() % 34;
return P_MASKPOWERUP;
switch (num) { switch (num) {
case 0: case 0:
default: default: