gfx for the powerups changed.. as soon someone makes a good powerup.bmp with animation we will see it.. :o)

origin
stpohle 23 years ago
parent 405867ec5e
commit c2563f2a0e

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.21 2003/05/18 14:06:29 patty21 Exp $ */ /* $Id: field.c,v 1.22 2003/06/01 22:06:30 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>
@ -13,7 +13,7 @@ draw_stone (int x, int y)
_field *stone = &bman.field[x][y]; _field *stone = &bman.field[x][y];
SDL_Rect dest, SDL_Rect dest,
src; src;
SDL_Surface *srcimg; SDL_Surface *srcimg = NULL;
int i, int i,
d; d;
@ -25,50 +25,74 @@ draw_stone (int x, int y)
src.x = 0; src.x = 0;
if (stone->frame == 0 || stone->type != FT_stone) { /* draw background if we have a stone, block or nothing */
srcimg = gfx.field[stone->type].image; if (stone->type <= FT_block) {
src.y = 0; SDL_Rect srcbg;
srcbg.w = dest.w;
srcbg.h = dest.h;
srcbg.x = (x % gfx.field[FT_nothing].frames) * gfx.block.x;
srcbg.y = (y % gfx.field[FT_nothing].frames) * gfx.block.y;
SDL_BlitSurface (gfx.field[FT_nothing].image, &srcbg, gfx.screen, &dest);
} }
else {
if (stone->frameto == 0) { /* animate the stone if needed only for exploding stone */
if (stone->type == FT_stone && stone->frame > 0) {
if (stone->frameto == 0)
if (stone->frame < gfx.field[stone->type].frames) { if (stone->frame < gfx.field[stone->type].frames) {
stone->frame++; stone->frame++;
stone->frameto = ANI_STONETIMEOUT; stone->frameto = ANI_STONETIMEOUT;
} }
}
if (stone->frameto > 0) if (stone->frameto > 0)
stone->frameto--; stone->frameto--;
if (stone->frame < gfx.field[stone->type].frames) {
if (stone->frame < gfx.field[FT_stone].frames) {
src.y = stone->frame * gfx.block.y; src.y = stone->frame * gfx.block.y;
srcimg = gfx.field[stone->type].image; srcimg = gfx.field[FT_stone].image;
} }
else { else {
src.y = 0; src.y = 0;
srcimg = gfx.field[FT_nothing].image; srcimg = gfx.field[FT_nothing].image;
} }
}
else if (stone->type == FT_stone || stone->type == FT_block) {
src.y = 0;
srcimg = gfx.field[stone->type].image;
} }
if (stone->frame > 0 || stone->type == FT_nothing) { /* some powerup so we need to animate this too */
SDL_Rect srcbg; else if (stone->type >= FT_death) {
if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) {
stone->frameto = ANI_STONETIMEOUT;
stone->frame++;
}
srcbg.w = dest.w; if (stone->frame >= gfx.powerup.frames)
srcbg.h = dest.h; stone->frame = 0;
srcbg.x = (x % gfx.field[FT_nothing].frames) * gfx.block.x;
srcbg.y = (y % gfx.field[FT_nothing].frames) * gfx.block.y;
SDL_BlitSurface (gfx.field[FT_nothing].image, &srcbg, gfx.screen, &dest); srcimg = gfx.powerup.image;
src.y = stone->frame * gfx.block.y;
} }
if (stone->type != FT_nothing) 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 */
srcimg = gfx.field[stone->type].image;
src.y = 0;
SDL_BlitSurface (srcimg, &src, gfx.screen, &dest);
}
// draw explosions if there is any // draw explosions if there is any
for (d = 0, i = 0; d < 4; d++) for (d = 0, i = 0; d < 4; d++)
if (stone->ex[d].count > 0) { if (stone->ex[d].count > 0) {
i = 1; // mark that there is already an explosion i = 1; // mark that there is already an explosion
draw_fire (x, y, d, -1); draw_fire (x, y, d, -1);
} }
return; return;
}; };
@ -146,8 +170,17 @@ field_load (FILE * map)
/* i am just too lazy to write this all again and again */ /* i am just too lazy to write this all again and again */
#define PLX bman.players[i].pos.x #define PLX bman.players[i].pos.x
#define PLY bman.players[i].pos.y #define PLY bman.players[i].pos.y
void field_set_playerposition (int usermap) { void
int p, dist, i,j , mx, my, dx = 0, dy = 0; field_set_playerposition (int usermap)
{
int p,
dist,
i,
j,
mx,
my,
dx = 0,
dy = 0;
char txt[255]; char txt[255];
p = 50; p = 50;
@ -165,14 +198,17 @@ void field_set_playerposition (int usermap) {
for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */ for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */
dx = PLX - bman.players[j].pos.x; dx = PLX - bman.players[j].pos.x;
if (dx < 0) dx = - dx; if (dx < 0)
dx = -dx;
dy = PLY - bman.players[j].pos.y; dy = PLY - bman.players[j].pos.y;
if (dy < 0) dy = - dy; if (dy < 0)
dy = -dy;
} }
/* check if there is no block */ /* check if there is no block */
if ((dx > 1 || dy > 1) && ((bman.field[PLX][PLY].type != FT_block && maxloop > 100) || if ((dx > 1 || dy > 1)
bman.field[PLX][PLY].type == FT_nothing)) { && ((bman.field[PLX][PLY].type != FT_block && maxloop > 100)
|| bman.field[PLX][PLY].type == FT_nothing)) {
/* get (up or down) dx and (left or right) dy */ /* get (up or down) dx and (left or right) dy */
dx = s_random (2); dx = s_random (2);
if (dx == 0) if (dx == 0)
@ -261,6 +297,7 @@ void field_set_playerposition (int usermap) {
PLY = PLY << 8; PLY = PLY << 8;
} }
}; };
#undef PLX #undef PLX
#undef PLY #undef PLY
@ -285,9 +322,11 @@ gfx_AddUpdateRect (x * gfx.block.x + gfx.offset.x, y * gfx.block.y + gfx.offset.
// put items into the field // put items into the field
void void
field_fillitems (int fieldtype, int num) field_fillitems (int fieldtype, int num)
{ {
int nb_try=100,d,x,y; int nb_try = 100,
d,
x,
y;
/* this is the item factor we multiply it with this so we know /* this is the item factor we multiply it with this so we know
how much items we want in the game */ how much items we want in the game */
float fkt = ((float) (bman.fieldsize.x * bman.fieldsize.y)) / (25.0 * 17.0); float fkt = ((float) (bman.fieldsize.x * bman.fieldsize.y)) / (25.0 * 17.0);
@ -319,8 +358,7 @@ field_new (char *filename)
d; d;
FILE *fmap; FILE *fmap;
if(filename) if (filename) {
{
fmap = fopen (filename, "r"); fmap = fopen (filename, "r");
/* if we can't open the given filename for any reason, reverting /* if we can't open the given filename for any reason, reverting
@ -328,8 +366,7 @@ field_new (char *filename)
if (fmap) if (fmap)
field_load (fmap); field_load (fmap);
} }
else else {
{
fmap = NULL; fmap = NULL;
} }
@ -397,5 +434,3 @@ field_new (char *filename)
/* put the kick special in the field */ /* put the kick special in the field */
field_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK); field_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK);
} }

@ -868,7 +868,7 @@ gfx_load_tileset (char *tilesetname)
gfx.powerup.frames = tmpimage->h / GFX_IMGSIZE; gfx.powerup.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.bomb.frames * gfx.block.y); gfx.powerup.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.image = SDL_DisplayFormat (tmpimage1); gfx.powerup.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);

Loading…
Cancel
Save