WaitForPlayers SDL_BlitSourface changed to gfx_blit

origin
stpohle 23 years ago
parent 4ecdb03594
commit 0af4e72130

@ -1,4 +1,4 @@
/* $Id: gfx.c,v 1.24 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: gfx.c,v 1.25 2003/07/22 23:15:03 stpohle Exp $ */
/* gfx.c */ /* gfx.c */
#include "bomberclone.h" #include "bomberclone.h"
@ -39,19 +39,19 @@ gfx_load_players (int sx, int sy)
else { else {
/* load the game player image */ /* load the game player image */
gfx.players[i].size.y = sy * 2; gfx.players[i].ani.h = sy * 2;
gfx.players[i].size.x = (tmpimage->w / 4) * sfkt; gfx.players[i].ani.w = (tmpimage->w / 4) * sfkt;
gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y; gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y;
tmpimage1 = tmpimage1 =
scale_image (tmpimage, gfx.players[i].size.x * 4, scale_image (tmpimage, gfx.players[i].ani.w * 4,
gfx.players[i].ani.frames * gfx.players[i].size.y); gfx.players[i].ani.frames * gfx.players[i].ani.h);
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.players[i].ani.image = SDL_DisplayFormat (tmpimage1); gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
/* calculate the numbers of images for the animation */ /* calculate the numbers of images for the animation */
gfx.players[i].offset.x = (sx - gfx.players[i].size.x) / 2; gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
gfx.players[i].offset.y = -sy; gfx.players[i].offset.y = -sy;
/* load the smal image */ /* load the smal image */
@ -261,6 +261,7 @@ redraw_logo (int x, int y, int w, int h)
src.x = x; src.x = x;
src.y = y; src.y = y;
SDL_BlitSurface (gfx.logo, &src, gfx.screen, &dest); SDL_BlitSurface (gfx.logo, &src, gfx.screen, &dest);
gfx_blitupdaterectadd (&dest);
}; };

@ -1,10 +1,11 @@
/* $Id: gfx.h,v 1.14 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: gfx.h,v 1.15 2003/07/22 23:15:31 stpohle Exp $ */
#ifndef _GFX_H_ #ifndef _GFX_H_
#define _GFX_H_ #define _GFX_H_
#define SCALE_MAXRES 10000 #define SCALE_MAXRES 10000
#define GFX_IMGSIZE 64 #define GFX_IMGSIZE 64
#define GFX_IMGBIGSIZE 96
#define GFX_PLAYERIMGSIZE_Y 128 #define GFX_PLAYERIMGSIZE_Y 128
#include "basic.h" #include "basic.h"
@ -22,13 +23,15 @@ struct __gfxblit {
struct __gfxani { struct __gfxani {
SDL_Surface *image; SDL_Surface *image;
int frames; // how many single frames (image -> heigh / (1.5 * gamestyle.height)) int frames; // how many single frames (image -> heigh / (1.5 * gamestyle.height))
int w; // size of a single frame
int h;
} typedef _gfxani; } typedef _gfxani;
struct __gfxplayer { struct __gfxplayer {
_gfxani ani; _gfxani ani;
_point offset; _point offset;
_point size; // height of the image.. needed for faster access. // _point size; // height of the image.. needed for faster access.
_point smal_size; _point smal_size;
SDL_Surface *smal_image; // smal size of the animation SDL_Surface *smal_image; // smal size of the animation
} typedef _gfxplayer; } typedef _gfxplayer;

@ -105,7 +105,7 @@ mw_draw_status ()
dest.x = x1 * 320; dest.x = x1 * 320;
dest.y = y - 4; dest.y = y - 4;
SDL_BlitSurface (bman.players[pnr].gfx->smal_image, &src, gfx.screen, &dest); gfx_blit (bman.players[pnr].gfx->smal_image, &src, gfx.screen, &dest, 0xFFFF);
} }
sprintf (text, " %10s %2d %2d", bman.players[pnr].name, bman.players[pnr].wins, sprintf (text, " %10s %2d %2d", bman.players[pnr].name, bman.players[pnr].wins,
@ -151,17 +151,17 @@ mw_draw_gfxselect (int selgfx)
if (bman.players[bman.p_nr].gfx_nr == -1) { if (bman.players[bman.p_nr].gfx_nr == -1) {
/* draw selection */ /* draw selection */
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
dest.w = src.w = gfx.players[i].size.x; dest.w = src.w = gfx.players[i].ani.w;
dest.h = src.h = gfx.players[i].size.y; dest.h = src.h = gfx.players[i].ani.h;
dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].ani.w >> 1);
dest.y = mw_player + 8; dest.y = mw_player + 8;
redraw_logo (dest.x, dest.y, dest.w, dest.h); redraw_logo (dest.x, dest.y, dest.w, dest.h);
src.x = 3 * gfx.players[i].size.x; src.x = 3 * gfx.players[i].ani.w;
if (i == selgfx) if (i == selgfx)
src.y = mw_frame * gfx.players[i].size.y; src.y = mw_frame * gfx.players[i].ani.h;
else else
src.y = 0; src.y = 0;
@ -182,27 +182,27 @@ mw_draw_gfxselect (int selgfx)
mw_frame = 0; mw_frame = 0;
} }
SDL_BlitSurface (gfx.players[i].ani.image, &src, gfx.screen, &dest); gfx_blit (gfx.players[i].ani.image, &src, gfx.screen, &dest, 0);
} }
else else
SDL_BlitSurface (mw_plgfx[i], &src, gfx.screen, &dest); gfx_blit (mw_plgfx[i], &src, gfx.screen, &dest, 0);
} }
} }
} }
else { else {
/* draw selected players */ /* draw selected players */
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
dest.w = src.w = gfx.players[i].size.x; dest.w = src.w = gfx.players[i].ani.w;
dest.h = src.h = gfx.players[i].size.y; dest.h = src.h = gfx.players[i].ani.h;
dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].ani.w >> 1);
dest.y = mw_player + 8; dest.y = mw_player + 8;
redraw_logo (dest.x, dest.y, dest.w, dest.h); redraw_logo (dest.x, dest.y, dest.w, dest.h);
src.x = 3 * gfx.players[i].size.x; src.x = 3 * gfx.players[i].ani.w;
if (i == selgfx) if (i == selgfx)
src.y = mw_frame * gfx.players[i].size.y; src.y = mw_frame * gfx.players[i].ani.h;
else else
src.y = 0; src.y = 0;
@ -211,9 +211,9 @@ mw_draw_gfxselect (int selgfx)
if (select < MAX_PLAYERS && select >= 0) { if (select < MAX_PLAYERS && select >= 0) {
/* this player have been selected */ /* this player have been selected */
if (bman.players[bman.p_nr].gfx_nr == i) if (bman.players[bman.p_nr].gfx_nr == i)
SDL_BlitSurface (gfx.players[i].ani.image, &src, gfx.screen, &dest); gfx_blit (gfx.players[i].ani.image, &src, gfx.screen, &dest, 0);
else else
SDL_BlitSurface (mw_plgfx[i], &src, gfx.screen, &dest); gfx_blit (mw_plgfx[i], &src, gfx.screen, &dest, 0);
} }
} }
} }
@ -221,10 +221,10 @@ mw_draw_gfxselect (int selgfx)
dest.x = 0; dest.x = 0;
dest.y = mw_player; dest.y = mw_player;
dest.w = gfx.res.x; dest.w = gfx.res.x;
dest.h = 8 + gfx.players[0].size.y; dest.h = 8 + gfx.players[0].ani.h;
gfx_blitupdaterectdraw (&dest); gfx_blitupdaterectdraw (&dest);
mw_chat = mw_player + 8 + gfx.players[0].size.y; mw_chat = mw_player + 8 + gfx.players[0].ani.h;
} }
@ -294,6 +294,7 @@ wait_for_players ()
mw_draw_chat (); mw_draw_chat ();
} }
gfx_blitdraw ();
gfx_blitupdaterectdraw (); gfx_blitupdaterectdraw ();
/* do the keyboard handling */ /* do the keyboard handling */

@ -21,16 +21,16 @@ draw_player (_player * player)
if (PS_IS_alife (player->state)) { if (PS_IS_alife (player->state)) {
/* player is alife */ /* player is alife */
dest.w = src.w = player->gfx->size.x; dest.w = src.w = player->gfx->ani.w;
dest.h = src.h = player->gfx->size.y; dest.h = src.h = player->gfx->ani.h;
dest.x = dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x +
gfx.postab[player->pos.x & 255]; gfx.postab[player->pos.x & 255];
dest.y = dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y +
gfx.postab[player->pos.y & 255]; gfx.postab[player->pos.y & 255];
src.x = player->d * player->gfx->size.x; src.x = player->d * player->gfx->ani.w;
src.y = player->frame * player->gfx->size.y; src.y = player->frame * player->gfx->ani.h;
gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, player->pos.y + 128); gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, player->pos.y + 128);
@ -56,7 +56,7 @@ draw_player (_player * player)
else { else {
/* player is dead */ /* player is dead */
dest.w = src.w = gfx.dead.image->w; dest.w = src.w = gfx.dead.image->w;
dest.h = src.h = player->gfx->size.y; dest.h = src.h = player->gfx->ani.h;
dest.x = dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x +

@ -1,4 +1,4 @@
/* $Id: tileset.c,v 1.3 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: tileset.c,v 1.4 2003/07/22 23:15:31 stpohle Exp $ */
/* load and select tilesets */ /* load and select tilesets */
#include "bomberclone.h" #include "bomberclone.h"
@ -151,54 +151,64 @@ tileset_load (char *tilesetname)
for (i = 0; i < FT_max; i++) { for (i = 0; i < FT_max; i++) {
switch (i) { switch (i) {
case (FT_nothing): case (FT_nothing):
sprintf (filename, "background.bmp"); sprintf (filename, "background");
break; break;
case (FT_stone): case (FT_stone):
sprintf (filename, "stone.bmp"); sprintf (filename, "stone");
break; break;
case (FT_block): case (FT_block):
sprintf (filename, "block.bmp"); sprintf (filename, "block");
break; break;
case (FT_death): case (FT_death):
sprintf (filename, "pwdeath.bmp"); sprintf (filename, "pwdeath");
break; break;
case (FT_bomb): case (FT_bomb):
sprintf (filename, "pwbomb.bmp"); sprintf (filename, "pwbomb");
break; break;
case (FT_fire): case (FT_fire):
sprintf (filename, "pwfire.bmp"); sprintf (filename, "pwfire");
break; break;
case (FT_shoe): case (FT_shoe):
sprintf (filename, "pwshoe.bmp"); sprintf (filename, "pwshoe");
break; break;
case (FT_sp_trigger): case (FT_sp_trigger):
sprintf (filename, "sptrigger.bmp"); sprintf (filename, "sptrigger");
break; break;
case (FT_sp_row): case (FT_sp_row):
sprintf (filename, "sprow.bmp"); sprintf (filename, "sprow");
break; break;
case (FT_sp_push): case (FT_sp_push):
sprintf (filename, "sppush.bmp"); sprintf (filename, "sppush");
break; break;
case (FT_sp_kick): case (FT_sp_kick):
sprintf (filename, "spkick.bmp"); sprintf (filename, "spkick");
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.bmp", bman.datapath, tileset, filename);
gfx.field[i].w = GFX_IMGSIZE;
gfx.field[i].h = GFX_IMGSIZE;
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/%s/%s96.bmp", bman.datapath, tileset, filename);
tmpimage = SDL_LoadBMP (fullname); gfx.field[i].h = GFX_IMGBIGSIZE;
if (tmpimage == NULL) { tmpimage = SDL_LoadBMP (fullname);
printf ("Can't load image: %s\n", SDL_GetError ()); if (tmpimage == NULL) {
exit (1); sprintf (fullname, "%s/tileset/default/%s.bmp", bman.datapath, filename);
} gfx.field[i].h = GFX_IMGSIZE;
tmpimage = SDL_LoadBMP (fullname);
if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ());
exit (1);
}
}
} }
gfx.field[i].frames = tmpimage->h / GFX_IMGSIZE; gfx.field[i].frames = tmpimage->h / gfx.field[i].h;
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, gfx.field[i].h = ((float) ((float)gfx.field[i].h / (float)GFX_IMGSIZE) * (float)gfx.block.y);
gfx.field[i].frames * gfx.block.y); gfx.field[i].w = (gfx.field[i].w / GFX_IMGSIZE) * gfx.block.x;
tmpimage1 = scale_image (tmpimage, (tmpimage->w / gfx.field[i].w) * gfx.block.x,
gfx.field[i].frames * gfx.field[i].h);
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

Loading…
Cancel
Save