|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: gfx.c,v 1.39 2005/04/06 21:17:48 stpohle Exp $ */
|
|
|
|
/* $Id: gfx.c,v 1.40 2005/04/09 18:22:40 stpohle Exp $ */
|
|
|
|
/* gfx.c */
|
|
|
|
/* gfx.c */
|
|
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "bomberclone.h"
|
|
|
@ -6,14 +6,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
_gfx gfx;
|
|
|
|
_gfx gfx;
|
|
|
|
|
|
|
|
|
|
|
|
static int gfx_get_nr_of_playergfx ();
|
|
|
|
int gfx_get_nr_of_playergfx ();
|
|
|
|
static void gfx_load_menusmall_players ();
|
|
|
|
static void gfx_load_menusmall_players ();
|
|
|
|
static void gfx_load_fieldtype_menu ();
|
|
|
|
static void gfx_load_fieldtype_menu ();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* count all playergfx
|
|
|
|
* count all playergfx
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int gfx_get_nr_of_playergfx () {
|
|
|
|
int gfx_get_nr_of_playergfx () {
|
|
|
|
int i = 0;
|
|
|
|
int i = 0;
|
|
|
|
FILE *f = NULL;
|
|
|
|
FILE *f = NULL;
|
|
|
|
char filename[255];
|
|
|
|
char filename[255];
|
|
|
@ -65,19 +65,24 @@ gfx_load_players (int sx, int sy)
|
|
|
|
gfx.players[i].ani.h = sy * 2;
|
|
|
|
gfx.players[i].ani.h = sy * 2;
|
|
|
|
gfx.players[i].ani.w = (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 =
|
|
|
|
|
|
|
|
scale_image (tmpimage, gfx.players[i].ani.w * 4,
|
|
|
|
if (!bman.dedicated) {
|
|
|
|
gfx.players[i].ani.frames * gfx.players[i].ani.h);
|
|
|
|
tmpimage1 =
|
|
|
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
|
|
|
scale_image (tmpimage, gfx.players[i].ani.w * 4,
|
|
|
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
|
|
|
gfx.players[i].ani.frames * gfx.players[i].ani.h);
|
|
|
|
gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
|
|
|
|
|
|
|
gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
/* calculate the numbers of images for the animation */
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
|
|
|
|
|
|
|
|
gfx.players[i].offset.y = -sy;
|
|
|
|
/* calculate the numbers of images for the animation */
|
|
|
|
|
|
|
|
gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
gfx.players[i].offset.y = -sy;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
gfx.players[i].ani.image = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -91,46 +96,48 @@ gfx_load_players (int sx, int sy)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE);
|
|
|
|
gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE);
|
|
|
|
tmpimage1 =
|
|
|
|
if (!bman.dedicated) {
|
|
|
|
scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)),
|
|
|
|
tmpimage1 =
|
|
|
|
gfx.dead.frames * (2 * sy));
|
|
|
|
scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)),
|
|
|
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
|
|
|
gfx.dead.frames * (2 * sy));
|
|
|
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
|
|
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
|
|
|
gfx.dead.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
gfx.dead.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
|
|
|
|
|
|
|
|
/* load the illnessthing */
|
|
|
|
/* load the illnessthing */
|
|
|
|
sprintf (filename, "%s/player/playersick.png", bman.datapath);
|
|
|
|
sprintf (filename, "%s/player/playersick.png", bman.datapath);
|
|
|
|
tmpimage = IMG_Load (filename);
|
|
|
|
tmpimage = IMG_Load (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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE);
|
|
|
|
gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE);
|
|
|
|
tmpimage1 =
|
|
|
|
tmpimage1 =
|
|
|
|
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
|
|
|
|
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));
|
|
|
|
gfx.ill.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
gfx.ill.image = SDL_DisplayFormat (tmpimage1);
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
SDL_FreeSurface (tmpimage1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* load the respawn gfx */
|
|
|
|
/* load the respawn gfx */
|
|
|
|
sprintf (filename, "%s/player/respawn.png", bman.datapath);
|
|
|
|
sprintf (filename, "%s/player/respawn.png", bman.datapath);
|
|
|
|
tmpimage = IMG_Load (filename);
|
|
|
|
tmpimage = IMG_Load (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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE);
|
|
|
|
gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE);
|
|
|
|
gfx.respawn.image =
|
|
|
|
gfx.respawn.image =
|
|
|
|
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
|
|
|
|
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
|
|
|
|
gfx.respawn.frames * (2 * sy));
|
|
|
|
gfx.respawn.frames * (2 * sy));
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
SDL_FreeSurface (tmpimage);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -162,20 +169,23 @@ void
|
|
|
|
gfx_init ()
|
|
|
|
gfx_init ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
if (gfx.fullscreen)
|
|
|
|
if (gfx.fullscreen && !bman.dedicated)
|
|
|
|
gfx.screen =
|
|
|
|
gfx.screen =
|
|
|
|
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
|
|
|
|
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
|
|
|
|
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN);
|
|
|
|
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN);
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else if (!bman.dedicated)
|
|
|
|
gfx.screen =
|
|
|
|
gfx.screen =
|
|
|
|
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
|
|
|
|
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
|
|
|
|
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
|
|
|
|
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
|
|
|
|
if (gfx.screen == NULL) {
|
|
|
|
if (!bman.dedicated && gfx.screen == NULL) {
|
|
|
|
d_printf ("Unable to set video mode: %s\n", SDL_GetError ());
|
|
|
|
d_printf ("Unable to set video mode: %s\n", SDL_GetError ());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (bman.dedicated) {
|
|
|
|
|
|
|
|
gfx.screen = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
SDL_ShowCursor (SDL_DISABLE);
|
|
|
|
SDL_ShowCursor (SDL_DISABLE);
|
|
|
|
|
|
|
|
|
|
|
|
/* delete small gfx und the menu player gfx */
|
|
|
|
/* delete small gfx und the menu player gfx */
|
|
|
@ -521,6 +531,9 @@ void
|
|
|
|
draw_logo ()
|
|
|
|
draw_logo ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SDL_Rect dest;
|
|
|
|
SDL_Rect dest;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bman.dedicated) return;
|
|
|
|
|
|
|
|
|
|
|
|
dest.x = dest.y = 0;
|
|
|
|
dest.x = dest.y = 0;
|
|
|
|
dest.w = gfx.res.x;
|
|
|
|
dest.w = gfx.res.x;
|
|
|
|
dest.h = gfx.res.y;
|
|
|
|
dest.h = gfx.res.y;
|
|
|
|