Specials and Death have now diffrent background powerups images - FT_mixed ist now scrolling through all the images

origin
stpohle 23 years ago
parent d1ec7c70d8
commit f5cbc3cf32

@ -124,6 +124,15 @@ enum _fieldtype {
FT_max // just to know how many types there are FT_max // just to know how many types there are
}; };
enum _poweruptypes {
PWUP_good = 0,
PWUP_bad,
PWUP_special,
PWUP_max
};
enum _special { enum _special {
SP_nothing=0, // player has no special SP_nothing=0, // player has no special
SP_trigger, // triggered bomb SP_trigger, // triggered bomb

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.24 2003/06/01 23:08:34 stpohle Exp $ */ /* $Id: field.c,v 1.25 2003/06/02 21:21:17 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */ /* field.c - procedures which are needed to control the field */
#include <stdlib.h> #include <stdlib.h>
@ -39,6 +39,14 @@ draw_stone (int x, int y)
SDL_BlitSurface (gfx.field[FT_nothing].image, &srcbg, gfx.screen, &dest); SDL_BlitSurface (gfx.field[FT_nothing].image, &srcbg, gfx.screen, &dest);
} }
if (stone->type == FT_mixed) {
i = 0;
while (i < FT_death || i == FT_mixed || i >= FT_max)
i = s_random (FT_max - FT_death) + FT_death;
}
else
i = stone->type;
/* animate the stone if needed only for exploding stone */ /* animate the stone if needed only for exploding stone */
if (stone->type == FT_stone && stone->frame > 0) { if (stone->type == FT_stone && stone->frame > 0) {
field_animation_add (x, y); field_animation_add (x, y);
@ -57,20 +65,29 @@ draw_stone (int x, int y)
src.y = 0; src.y = 0;
srcimg = gfx.field[stone->type].image; srcimg = gfx.field[stone->type].image;
} }
/* some powerup so we need to animate this too */ /* some powerup so we need to animate this too */
else if (stone->type >= FT_death) { if (i == FT_death)
d = PWUP_bad;
else if (i > FT_death && i < FT_sp_trigger)
d = PWUP_good;
else
d = PWUP_special;
if (i >= FT_death) {
field_animation_add (x, y); field_animation_add (x, y);
srcimg = gfx.powerup[d].image;
srcimg = gfx.powerup.image; if (stone->frame >= gfx.powerup[d].frames)
stone->frame = 0;
src.y = stone->frame * gfx.block.y; src.y = stone->frame * gfx.block.y;
} }
if (srcimg != NULL) if (srcimg != NULL)
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest); SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
if (stone->type >= FT_death) { /* draw now the powerup itself */ if (i >= FT_death) { /* draw now the powerup itself */
srcimg = gfx.field[stone->type].image; srcimg = gfx.field[i].image;
src.y = 0; src.y = 0;
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest); SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
} }
@ -428,7 +445,7 @@ field_new (char *filename)
void void
field_animation () field_animation ()
{ {
int i; int i,j;
for (i = 0; i < MAX_FILEDANIMATION; i++) for (i = 0; i < MAX_FILEDANIMATION; i++)
if (fieldani[i].x >= 0 && fieldani[i].x < bman.fieldsize.x && fieldani[i].y >= 0 if (fieldani[i].x >= 0 && fieldani[i].x < bman.fieldsize.x && fieldani[i].y >= 0
@ -449,13 +466,20 @@ field_animation ()
if (bman.field[fieldani[i].x][fieldani[i].y].frameto > 0) if (bman.field[fieldani[i].x][fieldani[i].y].frameto > 0)
bman.field[fieldani[i].x][fieldani[i].y].frameto--; bman.field[fieldani[i].x][fieldani[i].y].frameto--;
} }
else { else { /* animation is a powerup */
/* select right powerup animation */
if (bman.field[fieldani[i].x][fieldani[i].y].type == FT_death)
j = PWUP_bad;
else if (bman.field[fieldani[i].x][fieldani[i].y].type > FT_sp_trigger)
j = PWUP_special;
else
j = PWUP_good;
if (bman.field[fieldani[i].x][fieldani[i].y].frameto-- <= 0 || bman.field[fieldani[i].x][fieldani[i].y].frameto > ANI_STONETIMEOUT) { if (bman.field[fieldani[i].x][fieldani[i].y].frameto-- <= 0 || bman.field[fieldani[i].x][fieldani[i].y].frameto > ANI_STONETIMEOUT) {
bman.field[fieldani[i].x][fieldani[i].y].frameto = ANI_STONETIMEOUT; bman.field[fieldani[i].x][fieldani[i].y].frameto = ANI_STONETIMEOUT;
bman.field[fieldani[i].x][fieldani[i].y].frame++; bman.field[fieldani[i].x][fieldani[i].y].frame++;
} }
if (bman.field[fieldani[i].x][fieldani[i].y].frame >= gfx.powerup.frames) if (bman.field[fieldani[i].x][fieldani[i].y].frame >= gfx.powerup[j].frames)
bman.field[fieldani[i].x][fieldani[i].y].frame = 0; bman.field[fieldani[i].x][fieldani[i].y].frame = 0;
} }
draw_stone (fieldani[i].x, fieldani[i].y); draw_stone (fieldani[i].x, fieldani[i].y);

@ -775,6 +775,7 @@ gfx_copyscreen (SDL_Rect * wnd)
return res; return res;
}; };
/* load the tileset or if not present the files from the default folder */ /* load the tileset or if not present the files from the default folder */
void void
gfx_load_tileset (char *tilesetname) gfx_load_tileset (char *tilesetname)
@ -853,27 +854,40 @@ gfx_load_tileset (char *tilesetname)
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
/* load the powerup image */ /* load the powerup's image */
sprintf (fullname, "%s/tileset/%s/powerup.bmp", bman.datapath, tileset); for (i = 0; i < PWUP_max; i++) {
tmpimage = SDL_LoadBMP (fullname); switch (i) {
if (tmpimage == NULL) { case (PWUP_good):
/* file could not be load, so load teh default tileset */ sprintf (filename,"powerup.bmp");
sprintf (fullname, "%s/tileset/default/powerup.bmp", bman.datapath); break;
tmpimage = SDL_LoadBMP (fullname); case (PWUP_bad):
if (tmpimage == NULL) { sprintf (filename,"powerbad.bmp");
printf ("default tileset could not be loaded.\n"); break;
exit (1); default:
} sprintf (filename,"powersp.bmp");
} break;
gfx.powerup.frames = tmpimage->h / GFX_IMGSIZE; }
tmpimage1 =
scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename);
gfx.powerup.frames * gfx.block.y); tmpimage = SDL_LoadBMP (fullname);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 0, 255)); if (tmpimage == NULL) {
gfx.powerup.image = SDL_DisplayFormat (tmpimage1); /* file could not be load, so load teh default tileset */
SDL_FreeSurface (tmpimage); sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename);
SDL_FreeSurface (tmpimage1); tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) {
printf ("default tileset could not be loaded.\n");
exit (1);
}
}
gfx.powerup[i].frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 =
scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
gfx.powerup[i].frames * gfx.block.y);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, 255, 0, 255));
gfx.powerup[i].image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage);
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) {
@ -912,13 +926,7 @@ gfx_load_tileset (char *tilesetname)
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) {
tmpimage =
gfx_quater_image (gfx.field[FT_bomb].image, gfx.field[FT_fire].image,
gfx.field[FT_death].image, gfx.field[FT_shoe].image);
gfx.field[i].image = SDL_DisplayFormat (tmpimage);
}
else {
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) {
@ -959,8 +967,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);
if (gfx.powerup.image != NULL) for (i = 0; i < PWUP_max; i++)
SDL_FreeSurface (gfx.powerup.image); if (gfx.powerup[i].image != NULL)
SDL_FreeSurface (gfx.powerup[i].image);
gfx.bomb.image = NULL; gfx.bomb.image = NULL;
gfx.fire.image = NULL; gfx.fire.image = NULL;
}; };

@ -46,7 +46,7 @@ struct __gfx {
short int postab[256]; // table of points where we need to go to. short int postab[256]; // table of points where we need to go to.
_gfxani field[FT_max]; // the field animations _gfxani field[FT_max]; // the field animations
_gfxani powerup; // powerup field animation _gfxani powerup[3]; // powerup field animation
_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

Loading…
Cancel
Save