player dead animation

origin
stpohle 23 years ago
parent 0cde601cd7
commit c1ef50c8dd

@ -278,8 +278,8 @@ gfx_quater_image (SDL_Surface * org1, SDL_Surface * org2, SDL_Surface * org3, SD
x; x;
dest = SDL_CreateRGBSurface (SDL_HWSURFACE, org1->w, org1->h, org1->format->BitsPerPixel, dest = SDL_CreateRGBSurface (SDL_HWSURFACE, org1->w, org1->h, org1->format->BitsPerPixel,
org1->format->Rmask, org1->format->Gmask, org1->format->Rmask, org1->format->Gmask,
org1->format->Bmask, org1->format->Amask); org1->format->Bmask, org1->format->Amask);
if (dest == NULL) { if (dest == NULL) {
fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ()); fprintf (stderr, "CreateRGBSurface failed: %s\n", SDL_GetError ());
return NULL; return NULL;
@ -419,9 +419,30 @@ gfx_load_players (int sx, int sy)
gfx.players[i].smal_image = SDL_DisplayFormat (tmpimage1); gfx.players[i].smal_image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
} }
} }
/* load the death image */
sprintf (filename, "%s/player/dead0.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
/* no image found - set field clear */
printf ("Player Animation Could not be loaded (%s)\n", filename);
exit (1);
}
gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE);
tmpimage1 =
scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)),
gfx.dead.frames * (2 * sy));
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
gfx.dead.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage1);
SDL_FreeSurface (tmpimage);
/* load the illnessthing */ /* load the illnessthing */
sprintf (filename, "%s/player/playersick.bmp", bman.datapath); sprintf (filename, "%s/player/playersick.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
@ -431,7 +452,7 @@ gfx_load_players (int sx, int sy)
} }
gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE); gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE);
tmpimage1 = tmpimage1 =
scale_image (tmpimage, (tmpimage->w / (2 * GFX_IMGSIZE)) * (2 * sx), scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
gfx.ill.frames * (2 * sy)); gfx.ill.frames * (2 * sy));
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
@ -446,6 +467,7 @@ void
gfx_free_players () gfx_free_players ()
{ {
int i; int i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
if (gfx.players[i].ani.image != NULL) if (gfx.players[i].ani.image != NULL)
SDL_FreeSurface (gfx.players[i].ani.image); SDL_FreeSurface (gfx.players[i].ani.image);
@ -454,7 +476,11 @@ gfx_free_players ()
SDL_FreeSurface (gfx.players[i].smal_image); SDL_FreeSurface (gfx.players[i].smal_image);
gfx.players[i].smal_image = NULL; gfx.players[i].smal_image = NULL;
} }
SDL_FreeSurface (gfx.ill.image);
if (gfx.dead.image != NULL)
SDL_FreeSurface (gfx.dead.image);
if (gfx.ill.image != NULL)
SDL_FreeSurface (gfx.ill.image);
} }
@ -465,7 +491,7 @@ gfx_game_init ()
menu_displaytext ("Loading..", "Please Wait", 32, 128, 32); menu_displaytext ("Loading..", "Please Wait", 32, 128, 32);
gfx_load_tileset (gfx.tileset); gfx_load_tileset (gfx.tileset);
gfx_load_players (gfx.block.x, gfx.block.y); gfx_load_players (gfx.block.x, gfx.block.y);
snd_load (gfx.tileset); snd_load (gfx.tileset);
}; };
void void
@ -514,13 +540,13 @@ gfx_loaddata ()
sprintf (filename, "%s/gfx/font.bmp", bman.datapath); sprintf (filename, "%s/gfx/font.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
sprintf (bman.datapath, "data"); sprintf (bman.datapath, "data");
sprintf (filename, "%s/gfx/font.bmp", bman.datapath); sprintf (filename, "%s/gfx/font.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (filename); tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
exit (1); exit (1);
} }
} }
SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage->format, 0, 0, 0)); SDL_SetColorKey (tmpimage, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage->format, 0, 0, 0));
gfx.font.image = SDL_DisplayFormat (tmpimage); gfx.font.image = SDL_DisplayFormat (tmpimage);
@ -784,13 +810,13 @@ gfx_load_tileset (char *tilesetname)
r, r,
g, g,
b; b;
char fullname[LEN_PATHFILENAME]; char fullname[LEN_PATHFILENAME];
char filename[LEN_FILENAME]; char filename[LEN_FILENAME];
char tileset[LEN_TILESETNAME]; char tileset[LEN_TILESETNAME];
SDL_Surface *tmpimage, SDL_Surface *tmpimage,
*tmpimage1; *tmpimage1;
float sfkt; float sfkt;
d_printf ("Loading Tileset: %s\n", tilesetname); d_printf ("Loading Tileset: %s\n", tilesetname);
strncpy (tileset, tilesetname, LEN_TILESETNAME); strncpy (tileset, tilesetname, LEN_TILESETNAME);
@ -818,7 +844,7 @@ gfx_load_tileset (char *tilesetname)
sprintf (fullname, "%s/tileset/default/fire.bmp", bman.datapath); sprintf (fullname, "%s/tileset/default/fire.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("default tileset could not be loaded.\n"); printf ("default tileset could not be loaded.\n");
exit (1); exit (1);
} }
} }
@ -840,7 +866,7 @@ gfx_load_tileset (char *tilesetname)
sprintf (fullname, "%s/tileset/default/bomb.bmp", bman.datapath); sprintf (fullname, "%s/tileset/default/bomb.bmp", bman.datapath);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("default tileset could not be loaded.\n"); printf ("default tileset could not be loaded.\n");
exit (1); exit (1);
} }
} }
@ -855,39 +881,39 @@ gfx_load_tileset (char *tilesetname)
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
/* load the powerup's image */ /* load the powerup's image */
for (i = 0; i < PWUP_max; i++) { for (i = 0; i < PWUP_max; i++) {
switch (i) { switch (i) {
case (PWUP_good): case (PWUP_good):
sprintf (filename,"powerup.bmp"); sprintf (filename, "powerup.bmp");
break; break;
case (PWUP_bad): case (PWUP_bad):
sprintf (filename,"powerbad.bmp"); sprintf (filename, "powerbad.bmp");
break; break;
default: default:
sprintf (filename,"powersp.bmp"); sprintf (filename, "powersp.bmp");
break; break;
} }
sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename); sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
/* file could not be load, so load teh default tileset */ /* file could not be load, so load teh default tileset */
sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename); sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("default tileset could not be loaded.\n"); printf ("default tileset could not be loaded.\n");
exit (1); exit (1);
} }
} }
gfx.powerup[i].frames = tmpimage->h / GFX_IMGSIZE; gfx.powerup[i].frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 = tmpimage1 =
scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
gfx.powerup[i].frames * gfx.block.y); gfx.powerup[i].frames * gfx.block.y);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 0, 255)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 0, 255));
gfx.powerup[i].image = SDL_DisplayFormat (tmpimage1); gfx.powerup[i].image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
} }
/* loading the field images */ /* loading the field images */
for (i = 0; i < FT_max; i++) { for (i = 0; i < FT_max; i++) {
switch (i) { switch (i) {
@ -922,29 +948,29 @@ gfx_load_tileset (char *tilesetname)
sprintf (filename, "sppush.bmp"); sprintf (filename, "sppush.bmp");
break; break;
case (FT_sp_kick): case (FT_sp_kick):
sprintf (filename, "spkick.bmp"); sprintf (filename, "spkick.bmp");
continue; // remove this if you find a kick image continue; // remove this if you find a kick image
break; break;
} }
if (i != FT_mixed) { if (i != FT_mixed) {
sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename); sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename); sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename);
tmpimage = SDL_LoadBMP (fullname); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
exit (1); exit (1);
} }
} }
gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
gfx.field[i].frames * gfx.block.y); gfx.field[i].frames * gfx.block.y);
if (i == FT_nothing || i == FT_block || i == FT_stone) if (i == FT_nothing || i == FT_block || i == FT_stone)
r = g = b = 255; r = g = b = 255;
else else
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
gfx.field[i].image = SDL_DisplayFormat (tmpimage1); gfx.field[i].image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
@ -967,9 +993,9 @@ gfx_free_tileset ()
SDL_FreeSurface (gfx.bomb.image); SDL_FreeSurface (gfx.bomb.image);
if (gfx.fire.image != NULL) if (gfx.fire.image != NULL)
SDL_FreeSurface (gfx.fire.image); SDL_FreeSurface (gfx.fire.image);
for (i = 0; i < PWUP_max; i++) for (i = 0; i < PWUP_max; i++)
if (gfx.powerup[i].image != NULL) if (gfx.powerup[i].image != NULL)
SDL_FreeSurface (gfx.powerup[i].image); SDL_FreeSurface (gfx.powerup[i].image);
gfx.bomb.image = NULL; gfx.bomb.image = NULL;
gfx.fire.image = NULL; gfx.fire.image = NULL;
}; };

@ -50,6 +50,7 @@ struct __gfx {
_gfxani fire; // fire (explostion) _gfxani fire; // fire (explostion)
_gfxani bomb; // bomb animation _gfxani bomb; // bomb animation
_gfxani ill; // sick animation above the player _gfxani ill; // sick animation above the player
_gfxani dead; // load the dead player animation
_gfxani menuselect; // The Menu Select GFX (the bomb ?) _gfxani menuselect; // The Menu Select GFX (the bomb ?)

@ -12,42 +12,56 @@ draw_player (_player * player)
dest; dest;
int i; int i;
dest.w = src.w = player->gfx->size.x;
dest.h = src.h = player->gfx->size.y;
dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x +
gfx.postab[player->pos.x & 255];
dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y +
gfx.postab[player->pos.y & 255];
src.x = player->d * player->gfx->size.x;
src.y = player->frame * player->gfx->size.y;
SDL_BlitSurface (player->gfx->ani.image, &src, gfx.screen, &dest);
/* if the player is ill, draw this image above him */
if (PS_IS_alife (player->state)) { if (PS_IS_alife (player->state)) {
for (i = PI_max - 1; (i >= 0) && (player->ill[i].to == 0); i--); /* player is alife */
if (i >= 0) { dest.w = src.w = player->gfx->size.x;
dest.w = src.w = gfx.block.x * 2; dest.h = src.h = player->gfx->size.y;
dest.h = src.h = gfx.block.y * 2; dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x +
src.x = 0; gfx.postab[player->pos.x & 255];
src.y = (2 * gfx.block.y) * player->illframe; dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y +
dest.x = gfx.postab[player->pos.y & 255];
(-(gfx.block.x >> 1)) + gfx.offset.x + (player->pos.x >> 8) * gfx.block.x + src.x = player->d * player->gfx->size.x;
gfx.postab[player->pos.x & 255]; src.y = player->frame * player->gfx->size.y;
dest.y = SDL_BlitSurface (player->gfx->ani.image, &src, gfx.screen, &dest);
gfx.offset.y + ((player->pos.y >> 8) - 1) * gfx.block.y +
gfx.postab[player->pos.y & 255]; /* if the player is ill, draw this image above him */
if (PS_IS_alife (player->state)) {
SDL_BlitSurface (gfx.ill.image, &src, gfx.screen, &dest); for (i = PI_max - 1; (i >= 0) && (player->ill[i].to == 0); i--);
if (i >= 0) {
dest.w = src.w = gfx.block.x * 2;
dest.h = src.h = gfx.block.y * 2;
src.x = 0;
src.y = (2 * gfx.block.y) * player->illframe;
dest.x =
(-(gfx.block.x >> 1)) + gfx.offset.x + (player->pos.x >> 8) * gfx.block.x +
gfx.postab[player->pos.x & 255];
dest.y =
gfx.offset.y + ((player->pos.y >> 8) - 1) * gfx.block.y +
gfx.postab[player->pos.y & 255];
SDL_BlitSurface (gfx.ill.image, &src, gfx.screen, &dest);
}
} }
} }
else {
/* player is dead */
dest.w = src.w = gfx.dead.image->w;
dest.h = src.h = player->gfx->size.y;
dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x +
gfx.postab[player->pos.x & 255];
dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y +
gfx.postab[player->pos.y & 255];
src.x = 0;
src.y = (2 * gfx.block.y) * player->frame;
SDL_BlitSurface (gfx.dead.image, &src, gfx.screen, &dest);
}
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
player->old = player->pos; // save this position player->old = player->pos; // save this position
}; };
@ -56,6 +70,7 @@ draw_player (_player * player)
void void
restore_players_screen () restore_players_screen ()
{ {
int i, int i,
x, x,
xs, xs,
@ -63,7 +78,6 @@ restore_players_screen ()
y, y,
ys, ys,
ye; ye;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) { if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) {
if ((bman.players[i].old.x & 0xFF) > 128) { if ((bman.players[i].old.x & 0xFF) > 128) {
@ -78,7 +92,6 @@ restore_players_screen ()
x = 0; x = 0;
if (xe >= bman.fieldsize.x) if (xe >= bman.fieldsize.x)
xe = bman.fieldsize.x - 1; xe = bman.fieldsize.x - 1;
ys = (bman.players[i].old.y >> 8) - 1; ys = (bman.players[i].old.y >> 8) - 1;
ye = (bman.players[i].old.y >> 8) + 1; ye = (bman.players[i].old.y >> 8) + 1;
if (ys < 0) if (ys < 0)
@ -89,10 +102,8 @@ restore_players_screen ()
for (; x <= xe; x++) for (; x <= xe; x++)
for (y = ys; y <= ye; y++) for (y = ys; y <= ye; y++)
draw_stone (x, y); draw_stone (x, y);
gfx_AddUpdateRect (xs * gfx.block.x + gfx.offset.x, ys * gfx.block.y + gfx.offset.y, gfx_AddUpdateRect (xs * gfx.block.x + gfx.offset.x, ys * gfx.block.y + gfx.offset.y,
gfx.block.x * 3, gfx.block.y * 3); gfx.block.x * 3, gfx.block.y * 3);
} }
}; };
@ -100,8 +111,7 @@ restore_players_screen ()
void void
player_check_powerup (int p_nr) player_check_powerup (int p_nr)
{ {
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
int fx = p->pos.x >> 8; int fx = p->pos.x >> 8;
int fy = p->pos.y >> 8; int fy = p->pos.y >> 8;
int _x = p->pos.x & 255; int _x = p->pos.x & 255;
@ -109,16 +119,14 @@ player_check_powerup (int p_nr)
int ft, int ft,
i; i;
if (PS_IS_netplayer (p->state)) if (PS_IS_netplayer (p->state))
return; return;
/* Get the right field position */ /* Get the right field position */
if (_x > 128) if (_x > 128)
fx = fx + 1; fx = fx + 1;
if (_y > 128) if (_y > 128)
fy = fy + 1; fy = fy + 1;
ft = bman.field[fx][fy].type; ft = bman.field[fx][fy].type;
/* we found a mixed powerup */ /* we found a mixed powerup */
if (ft == FT_mixed) { if (ft == FT_mixed) {
@ -150,7 +158,6 @@ player_check_powerup (int p_nr)
} }
field_clear (fx, fy); field_clear (fx, fy);
break; break;
/* we found a fire powerup */ /* we found a fire powerup */
case FT_fire: case FT_fire:
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) { if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) {
@ -159,7 +166,6 @@ player_check_powerup (int p_nr)
} }
field_clear (fx, fy); field_clear (fx, fy);
break; break;
/* we found a shoe powerup */ /* we found a shoe powerup */
case FT_shoe: case FT_shoe:
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) { if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) {
@ -168,7 +174,6 @@ player_check_powerup (int p_nr)
} }
field_clear (fx, fy); field_clear (fx, fy);
break; break;
/* we found a death ?powerup? */ /* we found a death ?powerup? */
case FT_death: case FT_death:
player_set_ilness (p, -1); player_set_ilness (p, -1);
@ -177,14 +182,13 @@ player_check_powerup (int p_nr)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
field_clear (fx, fy); field_clear (fx, fy);
break; break;
/* we found a special */ /* we found a special */
case FT_sp_trigger: case FT_sp_trigger:
case FT_sp_row: case FT_sp_row:
case FT_sp_push: case FT_sp_push:
case FT_sp_kick: case FT_sp_kick:
special_pickup(p_nr,ft-FT_sp_trigger+1); special_pickup (p_nr, ft - FT_sp_trigger + 1);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
field_clear (fx, fy); field_clear (fx, fy);
break; break;
} }
@ -200,14 +204,12 @@ check_field (short int fx, short int fy, _player * p)
{ {
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int res = 0; int res = 0;
if (bman.field[fx][fy].type != FT_stone && bman.field[fx][fy].type != FT_block) if (bman.field[fx][fy].type != FT_stone && bman.field[fx][fy].type != FT_block)
res = 1; res = 1;
get_bomb_on (fx, fy, bombs); get_bomb_on (fx, fy, bombs);
if (bombs[0].x != -1) if (bombs[0].x != -1)
res = 0; res = 0;
return res; return res;
} }
@ -228,22 +230,18 @@ stepmove_player (int pl_nr)
fx = p->pos.x >> 8; fx = p->pos.x >> 8;
fy = p->pos.y >> 8; fy = p->pos.y >> 8;
_x = p->pos.x & 255; _x = p->pos.x & 255;
_y = p->pos.y & 255; _y = p->pos.y & 255;
// do direction correction for going up/down // do direction correction for going up/down
if (_x > 0 && _x <= 128 && (p->d == up || p->d == down)) if (_x > 0 && _x <= 128 && (p->d == up || p->d == down))
p->d = left; p->d = left;
if (_x > 128 && _x < 256 && (p->d == up || p->d == down)) if (_x > 128 && _x < 256 && (p->d == up || p->d == down))
p->d = right; p->d = right;
// do direction correction for left/right // do direction correction for left/right
if (_y > 0 && _y <= 128 && (p->d == left || p->d == right)) if (_y > 0 && _y <= 128 && (p->d == left || p->d == right))
p->d = up; p->d = up;
if (_y > 128 && _y < 256 && (p->d == left || p->d == right)) if (_y > 128 && _y < 256 && (p->d == left || p->d == right))
p->d = down; p->d = down;
/* get the pos to the next field */ /* get the pos to the next field */
if (p->d == left) if (p->d == left)
speed = _x; speed = _x;
@ -253,29 +251,22 @@ stepmove_player (int pl_nr)
speed = _y; speed = _y;
else else
speed = 256 - _y; speed = 256 - _y;
if (speed > p->speed || speed == 0) if (speed > p->speed || speed == 0)
speed = p->speed; speed = p->speed;
// go left // go left
if (p->d == left && _y == 0 && ((_x == 0 && check_field (fx - 1, fy, p)) || (_x > 0))) if (p->d == left && _y == 0 && ((_x == 0 && check_field (fx - 1, fy, p)) || (_x > 0)))
dx = -speed; dx = -speed;
// go right // go right
if (p->d == right && _y == 0 && ((_x == 0 && check_field (fx + 1, fy, p)) || (_x > 0))) if (p->d == right && _y == 0 && ((_x == 0 && check_field (fx + 1, fy, p)) || (_x > 0)))
dx = speed; dx = speed;
// go up // go up
if (p->d == up && _x == 0 && ((_y == 0 && check_field (fx, fy - 1, p)) || (_y > 0))) if (p->d == up && _x == 0 && ((_y == 0 && check_field (fx, fy - 1, p)) || (_y > 0)))
dy = -speed; dy = -speed;
// go down // go down
if (p->d == down && _x == 0 && ((_y == 0 && check_field (fx, fy + 1, p)) || (_y > 0))) if (p->d == down && _x == 0 && ((_y == 0 && check_field (fx, fy + 1, p)) || (_y > 0)))
dy = speed; dy = speed;
p->pos.x = p->pos.x + dx; p->pos.x = p->pos.x + dx;
p->pos.y = p->pos.y + dy; p->pos.y = p->pos.y + dy;
player_check_powerup (pl_nr); player_check_powerup (pl_nr);
} }
@ -288,6 +279,7 @@ stepmove_player (int pl_nr)
void void
move_player (int pl_nr) move_player (int pl_nr)
{ {
int oldd, int oldd,
stepsleft, stepsleft,
speed; speed;
@ -296,7 +288,6 @@ move_player (int pl_nr)
oldd = p->d; oldd = p->d;
if (p->m) { if (p->m) {
player_animation (p); player_animation (p);
if ((stepsleft = stepmove_player (pl_nr)) > 0) { if ((stepsleft = stepmove_player (pl_nr)) > 0) {
/* save the speed and go the rest of the step */ /* save the speed and go the rest of the step */
p->d = oldd; p->d = oldd;
@ -314,7 +305,6 @@ move_player (int pl_nr)
/* the player just stopt moving so send data */ /* the player just stopt moving so send data */
if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0) if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0)
net_game_send_playermove (pl_nr, 1); net_game_send_playermove (pl_nr, 1);
p->old_m = p->m; // save the old state p->old_m = p->m; // save the old state
p->m = 0; p->m = 0;
}; };
@ -323,24 +313,21 @@ move_player (int pl_nr)
void void
player_drop_bomb (int pl_nr) player_drop_bomb (int pl_nr)
{ {
_player *player = &bman.players[pl_nr]; _player *player = &bman.players[pl_nr];
_bomb *bomb = NULL; _bomb *bomb = NULL;
int i, int i,
_x, _x,
_y; _y;
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++); for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++);
if (i < player->bombs_n && PS_IS_alife (player->state)) { // free bomb found
if (i < player->bombs_n && PS_IS_alife(player->state)) { // free bomb found
// get the best position for the bomb. // get the best position for the bomb.
bomb = &player->bombs[i]; bomb = &player->bombs[i];
bomb->pos.x = player->pos.x >> 8; bomb->pos.x = player->pos.x >> 8;
bomb->pos.y = player->pos.y >> 8; bomb->pos.y = player->pos.y >> 8;
_x = player->pos.x & 255; _x = player->pos.x & 255;
_y = player->pos.y & 255; _y = player->pos.y & 255;
if (_x > 0 && _x <= 128) if (_x > 0 && _x <= 128)
_x = 0; _x = 0;
else if (_x > 128) { else if (_x > 128) {
@ -354,34 +341,32 @@ player_drop_bomb (int pl_nr)
bomb->pos.y += 1; bomb->pos.y += 1;
_y = 0; _y = 0;
} }
get_bomb_on (bomb->pos.x, bomb->pos.y, bombs); get_bomb_on (bomb->pos.x, bomb->pos.y, bombs);
if (bombs[0].x != -1) // is there already a bomb if (bombs[0].x != -1) // is there already a bomb
return; return;
d_printf ("Player %d Dropped Bomb %d\n", pl_nr, i); d_printf ("Player %d Dropped Bomb %d\n", pl_nr, i);
bomb->r = player->range; bomb->r = player->range;
if (player->special.type == SP_trigger) { if (player->special.type == SP_trigger) {
bomb->state = BS_trigger; bomb->state = BS_trigger;
bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
} }
else { else {
bomb->state = BS_ticking; bomb->state = BS_ticking;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
} }
bomb->ex_nr = -1; bomb->ex_nr = -1;
bman.bfield[bomb->pos.x][bomb->pos.y] = 1; bman.bfield[bomb->pos.x][bomb->pos.y] = 1;
bomb->pos.x=bomb->pos.x << 8; bomb->pos.x = bomb->pos.x << 8;
bomb->pos.y=bomb->pos.y << 8; bomb->pos.y = bomb->pos.y << 8;
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {
net_game_send_bomb (pl_nr, i); net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS) if (GT_MP_PTPS)
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR);
} }
snd_play (SND_bombdrop); snd_play (SND_bombdrop);
} }
}; };
@ -415,27 +400,25 @@ player_died (_player * player, signed char dead_by)
// player die ! // player die !
d_printf ("player_died (%10s)\n", player->name); d_printf ("player_died (%10s)\n", player->name);
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS) if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS)
if (bman.p_nr != dead_by) if (bman.p_nr != dead_by)
bman.players[dead_by].points++; bman.players[dead_by].points++;
player->frame = 0;
player->state &= (0xFF - PSF_alife); player->state &= (0xFF - PSF_alife);
player->dead_by = dead_by; player->dead_by = dead_by;
if (GT_MP_PTP) if (GT_MP_PTP)
net_game_send_player (bman.p_nr); net_game_send_player (bman.p_nr);
snd_play (SND_dead);
snd_play (SND_dead);
}; };
void void
draw_players () draw_players ()
{ {
int p;
int p;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_playing (bman.players[p].state)) if (PS_IS_playing (bman.players[p].state))
draw_player (&bman.players[p]); draw_player (&bman.players[p]);
@ -448,16 +431,25 @@ player_animation (_player * player)
{ {
if (player->gfx == NULL) if (player->gfx == NULL)
return; return;
if (player->frame < player->gfx->ani.frames if (PS_IS_alife (player->state)) {
&& (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT)) { if (player->frame < player->gfx->ani.frames
player->frameto = ANI_PLAYERTIMEOUT; && (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT)) {
player->frame++; player->frameto = ANI_PLAYERTIMEOUT;
} player->frame++;
}
if (player->frame >= player->gfx->ani.frames && PS_IS_alife (player->state)) if (player->frame >= player->gfx->ani.frames)
player->frame = 0; player->frame = 0;
}
if (PS_IS_dead (player->state)) {
if (player->frame < gfx.dead.frames
&& (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT * 2)) {
player->frameto = ANI_PLAYERTIMEOUT * 2;
player->frame++;
}
}
if (player->frameto > 0) if (player->frameto > 0)
player->frameto--; player->frameto--;
}; };
@ -466,14 +458,15 @@ player_animation (_player * player)
int int
dead_playerani () dead_playerani ()
{ {
int i, int i,
b = 0; b = 0;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_dead (bman.players[i].state)) { if (PS_IS_dead (bman.players[i].state)) {
player_animation (&bman.players[i]); player_animation (&bman.players[i]);
b++; b++;
} }
return b; return b;
}; };
@ -481,15 +474,13 @@ dead_playerani ()
void void
player_calcstep (_player * pl) player_calcstep (_player * pl)
{ {
_point d; _point d;
int fx, int fx,
fy; fy;
player_animation (pl); player_animation (pl);
fx = pl->pos.x >> 8; fx = pl->pos.x >> 8;
fy = pl->pos.y >> 8; fy = pl->pos.y >> 8;
if (bman.field[fx][fy].type != FT_block && bman.field[fx][fy].type != FT_stone) { if (bman.field[fx][fy].type != FT_block && bman.field[fx][fy].type != FT_stone) {
d.x = 0; d.x = 0;
d.y = 0; d.y = 0;
@ -501,7 +492,6 @@ player_calcstep (_player * pl)
d.y = -16; d.y = -16;
else if (pl->d == down) else if (pl->d == down)
d.y = 16; d.y = 16;
pl->pos.x += d.x; pl->pos.x += d.x;
pl->pos.y += d.y; pl->pos.y += d.y;
} }
@ -527,13 +517,10 @@ player_calcpos ()
pl->speeddat = 1; pl->speeddat = 1;
else else
pl->speeddat = 0; pl->speeddat = 0;
oldm = pl->m; oldm = pl->m;
oldd = pl->d; oldd = pl->d;
if (pl->speed > 1) if (pl->speed > 1)
stepmove_player (p); stepmove_player (p);
if (pl->speeddat) { if (pl->speeddat) {
pl->m = oldm; pl->m = oldm;
pl->d = oldd; pl->d = oldd;
@ -555,7 +542,7 @@ player_ilness_loop (int pl_nr)
tmp, tmp,
send; send;
int pl[MAX_PLAYERS + 1]; int pl[MAX_PLAYERS + 1];
/* do the illness for the network players */ /* do the illness for the network players */
if (GT_MP_PTP) { if (GT_MP_PTP) {
for (pnr = 0; pnr < MAX_PLAYERS; pnr++) for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
@ -574,9 +561,9 @@ player_ilness_loop (int pl_nr)
} }
} }
} }
/* check if we have contact with an other ill player */ /* check if we have contact with an other ill player */
p = &bman.players[pl_nr]; p = &bman.players[pl_nr];
get_player_on (p->pos.x, p->pos.y, pl); get_player_on (p->pos.x, p->pos.y, pl);
for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++) for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++)
if (pl[i] != pl_nr) { if (pl[i] != pl_nr) {
@ -641,12 +628,10 @@ void
player_set_ilness (_player * p, int t) player_set_ilness (_player * p, int t)
{ {
int type; int type;
if (t == -1) if (t == -1)
type = s_random (PI_max); type = s_random (PI_max);
else else
type = t; type = t;
d_printf ("Ilness : %d\n", type); d_printf ("Ilness : %d\n", type);
switch (type) { switch (type) {
case PI_slow: case PI_slow:
@ -657,7 +642,6 @@ player_set_ilness (_player * p, int t)
} }
else else
p->ill[type].data = p->speed; p->ill[type].data = p->speed;
} }
p->speed = 6; p->speed = 6;
break; break;
@ -669,7 +653,6 @@ player_set_ilness (_player * p, int t)
} }
else else
p->ill[type].data = p->speed; p->ill[type].data = p->speed;
} }
p->speed = 150; p->speed = 150;
@ -684,7 +667,6 @@ player_set_ilness (_player * p, int t)
p->ill[type].data = p->bombs_n; p->ill[type].data = p->bombs_n;
p->bombs_n = s_random (2); p->bombs_n = s_random (2);
break; break;
} }
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
p->ill[type].to += TIME_FACTOR * IL_TIMEOUT; p->ill[type].to += TIME_FACTOR * IL_TIMEOUT;
@ -710,7 +692,6 @@ player_clear_ilness (_player * p, int type)
break; break;
} }
p->ill[type].to = 0; p->ill[type].to = 0;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
@ -721,10 +702,8 @@ void
player_set_gfx (_player * p, signed char gfx_nr) player_set_gfx (_player * p, signed char gfx_nr)
{ {
p->gfx_nr = gfx_nr; p->gfx_nr = gfx_nr;
if (p->gfx_nr < 0 || p->gfx_nr >= MAX_PLAYERS) if (p->gfx_nr < 0 || p->gfx_nr >= MAX_PLAYERS)
p->gfx_nr = -1; p->gfx_nr = -1;
if (p->gfx_nr == -1) { if (p->gfx_nr == -1) {
p->gfx = NULL; p->gfx = NULL;
p->state &= (0xFF - (PSF_alife + PSF_playing)); p->state &= (0xFF - (PSF_alife + PSF_playing));

Loading…
Cancel
Save