parent
5b50dbe0c2
commit
94202c9983
@ -1,25 +1,28 @@
|
|||||||
$Id: TODO,v 1.9 2003/07/13 00:10:59 stpohle Exp $
|
$Id: TODO,v 1.10 2003/07/15 11:43:08 stpohle Exp $
|
||||||
|
|
||||||
this version (fix2):
|
next version (0.9.10):
|
||||||
====================
|
======================
|
||||||
|
|
||||||
always changes:
|
- more specials (Kicking Bomb, Pushing Bomb Ver.2)
|
||||||
===============
|
|
||||||
|
|
||||||
- animated fire
|
- maps will have more options to set and it will be displayed in the multiplayer menu
|
||||||
- more players
|
|
||||||
- we need some more sound for picking up items.
|
|
||||||
- find better way for menus
|
|
||||||
|
|
||||||
|
- network joining menu Add: i on a game for information about the playernames and
|
||||||
next version:
|
the point list.
|
||||||
=============
|
|
||||||
|
|
||||||
- gfx, source cleanup. player will now drawn in order they stay
|
- gfx, source cleanup. player will now drawn in order they stay
|
||||||
tileset will change we can support 64x64pixel size and 64x92pixel size tilesets
|
tileset will change we can support 64x64pixel size and 64x92pixel size tilesets
|
||||||
no sdl_blit* calls from game_loop for the game gfx.. working on a new engine with
|
no sdl_blit* calls from game_loop for the game gfx.. working on a new engine with
|
||||||
sorting the tiles and update rects.
|
sorting the tiles and update rects.
|
||||||
|
|
||||||
- keyboard/keybinput cleanup so all keyboard inputs will be read from there.
|
- keyboard/keybinput cleanup so all keyboard inputs will be read from there.
|
||||||
hopefully we will get so out of this menu problem that sometimes keys are ignored.
|
hopefully we will get so out of this menu problem that sometimes keys are ignored.
|
||||||
|
|
||||||
|
|
||||||
|
always change if possible:
|
||||||
|
==========================
|
||||||
|
|
||||||
|
- animated fire
|
||||||
|
- more players
|
||||||
|
- we need some more sound for picking up items.
|
||||||
|
- find better way for menus
|
||||||
|
@ -0,0 +1,357 @@
|
|||||||
|
/* $Id: map.c,v 1.1 2003/07/15 11:43:09 stpohle Exp $ */
|
||||||
|
/* map handling, like generate and load maps. */
|
||||||
|
|
||||||
|
#include "bomberclone.h"
|
||||||
|
|
||||||
|
// put items into the field
|
||||||
|
void
|
||||||
|
map_fillitems (int fieldtype, int num)
|
||||||
|
{
|
||||||
|
int nb_try = 100,
|
||||||
|
d,
|
||||||
|
x,
|
||||||
|
y;
|
||||||
|
/* this is the item factor we multiply it with this so we know
|
||||||
|
how much items we want in the game */
|
||||||
|
float fkt = ((float) (bman.fieldsize.x * bman.fieldsize.y)) / (25.0 * 17.0);
|
||||||
|
/* put the row special in the field */
|
||||||
|
|
||||||
|
for (d = 0; d < num * fkt; d++) {
|
||||||
|
x = y = 0;
|
||||||
|
while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) {
|
||||||
|
x = ((float) rand () / (float) RAND_MAX) * (bman.fieldsize.x - 1);
|
||||||
|
y = ((float) rand () / (float) RAND_MAX) * (bman.fieldsize.y - 1);
|
||||||
|
nb_try--;
|
||||||
|
if (nb_try < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bman.field[x][y].special = fieldtype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// loads or generate an map
|
||||||
|
void
|
||||||
|
map_new (char *filename)
|
||||||
|
{
|
||||||
|
int x,
|
||||||
|
y;
|
||||||
|
FILE *fmap;
|
||||||
|
|
||||||
|
if (filename) {
|
||||||
|
fmap = fopen (filename, "r");
|
||||||
|
|
||||||
|
/* if we can't open the given filename for any reason, reverting
|
||||||
|
to default value else, load the file */
|
||||||
|
if (fmap)
|
||||||
|
map_load (fmap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fmap = NULL;
|
||||||
|
|
||||||
|
// Clean and create the field //
|
||||||
|
if (fmap == NULL)
|
||||||
|
map_genrandom ();
|
||||||
|
|
||||||
|
/* delete the bfield data */
|
||||||
|
for (x = 0; x < MAX_FIELDSIZE_X; x++)
|
||||||
|
for (y = 0; y < MAX_FIELDSIZE_Y; y++)
|
||||||
|
bman.bfield[x][y] = 0;
|
||||||
|
|
||||||
|
/* Set the Playerinformation */
|
||||||
|
map_set_playerposition (fmap != NULL);
|
||||||
|
|
||||||
|
/* put the fire powerups in the field */
|
||||||
|
map_fillitems (FT_fire, GAME_SPECIAL_ITEMFIRE);
|
||||||
|
/* put the bomb powerups in the field */
|
||||||
|
map_fillitems (FT_bomb, GAME_SPECIAL_ITEMBOMB);
|
||||||
|
/* put the shoe powerup in the field */
|
||||||
|
map_fillitems (FT_shoe, GAME_SPECIAL_ITEMSHOE);
|
||||||
|
/* put the death ?powerups? in the field */
|
||||||
|
map_fillitems (FT_death, GAME_SPECIAL_ITEMDEATH);
|
||||||
|
/* put the mixed powerrup in the field */
|
||||||
|
map_fillitems (FT_mixed, GAME_SPECIAL_ITEMMIXED);
|
||||||
|
/* put the trigger special in the field */
|
||||||
|
map_fillitems (FT_sp_trigger, GAME_SPECIAL_ITEMSTRIGGER);
|
||||||
|
/* put the row special in the field */
|
||||||
|
map_fillitems (FT_sp_row, GAME_SPECIAL_ITEMSROW);
|
||||||
|
/* put the push special in the field */
|
||||||
|
map_fillitems (FT_sp_push, GAME_SPECIAL_ITEMSPUSH);
|
||||||
|
/* put the kick special in the field */
|
||||||
|
map_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void map_genrandom () {
|
||||||
|
int x, y, d;
|
||||||
|
|
||||||
|
/* if we can't load the map check first the fieldsize settings */
|
||||||
|
if (bman.fieldsize.x < MIN_FIELDSIZE_X)
|
||||||
|
bman.fieldsize.x = MIN_FIELDSIZE_X;
|
||||||
|
if (bman.fieldsize.x > MAX_FIELDSIZE_X)
|
||||||
|
bman.fieldsize.x = MAX_FIELDSIZE_X;
|
||||||
|
|
||||||
|
for (x = 0; x < bman.fieldsize.x; x++)
|
||||||
|
for (y = 0; y < bman.fieldsize.y; y++) {
|
||||||
|
if ((y == 0) || (y == bman.fieldsize.y - 1))
|
||||||
|
bman.field[x][y].type = FT_block;
|
||||||
|
else if ((x == 0) || (x == bman.fieldsize.x - 1))
|
||||||
|
bman.field[x][y].type = FT_block;
|
||||||
|
else if (((x & 1) == 0) && ((y & 1) == 0))
|
||||||
|
bman.field[x][y].type = FT_block;
|
||||||
|
else {
|
||||||
|
// create random field
|
||||||
|
if ((s_random (256) & 3) == 0)
|
||||||
|
bman.field[x][y].type = FT_nothing;
|
||||||
|
else
|
||||||
|
bman.field[x][y].type = FT_stone;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (d = 0; d < 4; d++)
|
||||||
|
bman.field[x][y].ex[d].frame = bman.field[x][y].ex[d].count = 0;
|
||||||
|
bman.field[x][y].ex_nr = -1;
|
||||||
|
bman.field[x][y].frame = 0;
|
||||||
|
bman.field[x][y].frameto = 0;
|
||||||
|
bman.field[x][y].special = FT_nothing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* will set the playerposition but in a way that we won't start on a block */
|
||||||
|
/* i am just too lazy to write this all again and again */
|
||||||
|
#define PLX bman.players[i].pos.x
|
||||||
|
#define PLY bman.players[i].pos.y
|
||||||
|
void
|
||||||
|
map_set_playerposition (int usermap)
|
||||||
|
{
|
||||||
|
int p,
|
||||||
|
dist,
|
||||||
|
i,
|
||||||
|
j,
|
||||||
|
mx,
|
||||||
|
my,
|
||||||
|
dx = 0,
|
||||||
|
dy = 0;
|
||||||
|
char txt[255];
|
||||||
|
|
||||||
|
p = 50;
|
||||||
|
dist = 8;
|
||||||
|
while (p == 50) {
|
||||||
|
p = 0;
|
||||||
|
dist--;
|
||||||
|
for (i = 0; (p < 50 && i < MAX_PLAYERS);) {
|
||||||
|
if (usermap) {
|
||||||
|
int maxloop = 0;
|
||||||
|
while (maxloop < 200 && (PLX == -1 || PLY == -1)) {
|
||||||
|
maxloop++;
|
||||||
|
PLX = s_random (bman.fieldsize.x - 2) + 1;
|
||||||
|
PLY = s_random (bman.fieldsize.y - 2) + 1;
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (dx < 0)
|
||||||
|
dx = -dx;
|
||||||
|
dy = PLY - bman.players[j].pos.y;
|
||||||
|
if (dy < 0)
|
||||||
|
dy = -dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if there is no block */
|
||||||
|
if ((dx > 1 || dy > 1)
|
||||||
|
&& ((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 */
|
||||||
|
dx = s_random (2);
|
||||||
|
if (dx == 0)
|
||||||
|
dx = -1;
|
||||||
|
dy = s_random (2);
|
||||||
|
if (dy == 0)
|
||||||
|
dy = -1;
|
||||||
|
|
||||||
|
/* first check if there is and free place for us */
|
||||||
|
if (!((bman.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
|
||||||
|
bman.field[PLX + dx][PLY].type == FT_nothing))
|
||||||
|
dx = -dx;
|
||||||
|
if (!((bman.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
|
||||||
|
bman.field[PLX + dx][PLY].type == FT_nothing))
|
||||||
|
PLX = -1;
|
||||||
|
|
||||||
|
if (!((bman.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
|
||||||
|
bman.field[PLX][PLY + dy].type == FT_nothing))
|
||||||
|
dy = -dy;
|
||||||
|
if (!((bman.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
|
||||||
|
bman.field[PLX][PLY + dy].type == FT_nothing))
|
||||||
|
PLY = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PLX = -1;
|
||||||
|
PLY = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make some space */
|
||||||
|
if (PLX != -1 && PLY != -1) {
|
||||||
|
bman.field[PLX][PLY].type = FT_nothing;
|
||||||
|
bman.field[PLX + dx][PLY].type = FT_nothing;
|
||||||
|
bman.field[PLX][PLY + dy].type = FT_nothing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PLX == -1 || PLY == -1) {
|
||||||
|
/* we could not set all fields or we don't run on a usermap */
|
||||||
|
if (usermap) {
|
||||||
|
sprintf (txt, "Not all players could be set (Pl:%d)", i);
|
||||||
|
menu_displaymessage ("MAP - ERROR", txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now there will be some fields deleted */
|
||||||
|
PLX = 2 * (s_random ((bman.fieldsize.x - 1) / 2)) + 1;
|
||||||
|
PLY = 2 * (s_random ((bman.fieldsize.y - 1) / 2)) + 1;
|
||||||
|
|
||||||
|
bman.field[PLX][PLY].type = FT_nothing;
|
||||||
|
|
||||||
|
dx = s_random (4); // bit 1 = up/down bit 2 = left/right
|
||||||
|
/* up and down */
|
||||||
|
if (((dx & 1) == 0 && PLX > 1) || PLX >= bman.fieldsize.x - 2)
|
||||||
|
bman.field[PLX - 1][PLY].type = FT_nothing;
|
||||||
|
else
|
||||||
|
bman.field[PLX + 1][PLY].type = FT_nothing;
|
||||||
|
/* left and right */
|
||||||
|
if (((dx & 2) == 0 && PLY > 1) || PLY >= bman.fieldsize.y - 2)
|
||||||
|
bman.field[PLX][PLY - 1].type = FT_nothing;
|
||||||
|
else
|
||||||
|
bman.field[PLX][PLY + 1].type = FT_nothing;
|
||||||
|
}
|
||||||
|
mx = my = 100;
|
||||||
|
for (j = 0; j <= i; j++) { /* search smalest distance */
|
||||||
|
dy = PLY - bman.players[j].pos.y;
|
||||||
|
dx = PLX - bman.players[j].pos.x;
|
||||||
|
if (dy < 0)
|
||||||
|
dy = -dy;
|
||||||
|
if (dx < 0)
|
||||||
|
dx = -dx;
|
||||||
|
|
||||||
|
if (mx > dx && i != j)
|
||||||
|
mx = dx;
|
||||||
|
if (my > dy && i != j)
|
||||||
|
my = dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mx > dist || my > dist)
|
||||||
|
i++;
|
||||||
|
else
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
||||||
|
PLX = PLX << 8;
|
||||||
|
PLY = PLY << 8;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef PLX
|
||||||
|
#undef PLY
|
||||||
|
|
||||||
|
/* load a random map */
|
||||||
|
void map_random () {
|
||||||
|
_direntry *destart, *de, *desel;
|
||||||
|
char path[LEN_PATHFILENAME];
|
||||||
|
int max, sel;
|
||||||
|
|
||||||
|
sprintf (path, "%s/maps", bman.datapath);
|
||||||
|
desel = destart = s_getdir (path);
|
||||||
|
|
||||||
|
for (max = 0, de = destart; de != NULL; de = de->next)
|
||||||
|
if ((de->flags & DF_file) == DF_file)
|
||||||
|
max++;
|
||||||
|
|
||||||
|
sel = s_random (max);
|
||||||
|
for (max = 0, de = destart; max <= sel && de != NULL; de = de->next)
|
||||||
|
if ((de->flags & DF_file) == DF_file) {
|
||||||
|
desel = de;
|
||||||
|
max++;
|
||||||
|
}
|
||||||
|
|
||||||
|
d_printf ("Random Map %s (%d on %d)\n", desel->name, sel, max);
|
||||||
|
|
||||||
|
if (desel != NULL)
|
||||||
|
sprintf (bman.fieldpath, "%s/maps/%s", bman.datapath, desel->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Init the game according to options
|
||||||
|
void init_map_tileset()
|
||||||
|
{
|
||||||
|
switch (bman.random_map) {
|
||||||
|
case (0):
|
||||||
|
map_new (bman.fieldpath);
|
||||||
|
break;
|
||||||
|
case (1):
|
||||||
|
map_random ();
|
||||||
|
map_new (bman.fieldpath);
|
||||||
|
break;
|
||||||
|
case (2):
|
||||||
|
map_new (NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gfx.random_tileset)
|
||||||
|
tileset_random ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* read from an open file map, determine field.x and field.y
|
||||||
|
and fill the field.
|
||||||
|
(# correspond to a bloc and @ correspond to a stone,
|
||||||
|
an espace is nothing ' '
|
||||||
|
% are commentary at the beginning of the map */
|
||||||
|
void
|
||||||
|
map_load (FILE * map)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
char *currentline;
|
||||||
|
char tmp[MAX_FIELDSIZE_X];
|
||||||
|
int sizex = 0;
|
||||||
|
int sizey = 0;
|
||||||
|
int i;
|
||||||
|
int d;
|
||||||
|
|
||||||
|
while ((currentline = fgets (tmp, MAX_FIELDSIZE_X, map))) {
|
||||||
|
length = strlen (currentline);
|
||||||
|
if (currentline[0] == '%')
|
||||||
|
continue;
|
||||||
|
/* now each line correspond to the field */
|
||||||
|
else {
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
switch (currentline[i]) {
|
||||||
|
case '#':
|
||||||
|
bman.field[i][sizey].type = FT_block;
|
||||||
|
break;
|
||||||
|
case '@':
|
||||||
|
bman.field[i][sizey].type = FT_stone;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
bman.field[i][sizey].type = FT_nothing;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (d = 0; d < 4; d++)
|
||||||
|
bman.field[i][sizey].ex[d].frame = bman.field[i][sizey].ex[d].count = 0;
|
||||||
|
bman.field[i][sizey].ex_nr = -1;
|
||||||
|
bman.field[i][sizey].frame = 0;
|
||||||
|
bman.field[i][sizey].frameto = 0;
|
||||||
|
bman.field[i][sizey].special = FT_nothing;
|
||||||
|
}
|
||||||
|
sizey++;
|
||||||
|
if (sizex < length)
|
||||||
|
sizex = length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bman.fieldsize.x = sizex - 1;
|
||||||
|
bman.fieldsize.y = sizey;
|
||||||
|
|
||||||
|
/* darw the border so we know everything is right */
|
||||||
|
for (i = 0; i < bman.fieldsize.x; i++)
|
||||||
|
bman.field[i][0].type = bman.field[i][bman.fieldsize.y - 1].type = FT_block;
|
||||||
|
for (i = 0; i < bman.fieldsize.y; i++)
|
||||||
|
bman.field[0][i].type = bman.field[bman.fieldsize.x - 1][i].type = FT_block;
|
||||||
|
}
|
@ -0,0 +1,245 @@
|
|||||||
|
/* $Id: tileset.c,v 1.1 2003/07/15 11:43:09 stpohle Exp $ */
|
||||||
|
/* load and select tilesets */
|
||||||
|
|
||||||
|
#include "bomberclone.h"
|
||||||
|
|
||||||
|
extern int UpdateRects_nr;
|
||||||
|
|
||||||
|
/* load a random tileset */
|
||||||
|
void tileset_random () {
|
||||||
|
_direntry *destart, *de, *desel;
|
||||||
|
char path[LEN_PATHFILENAME];
|
||||||
|
int max, sel;
|
||||||
|
|
||||||
|
sprintf (path, "%s/tileset", bman.datapath);
|
||||||
|
desel = destart = s_getdir (path);
|
||||||
|
|
||||||
|
for (max = 0, de = destart; de != NULL; de = de->next)
|
||||||
|
if (de->name[0] != '.' && (de->flags & DF_dir) == DF_dir)
|
||||||
|
max++;
|
||||||
|
|
||||||
|
sel = s_random (max);
|
||||||
|
for (max = 0, de = destart; max <= sel && de != NULL; de = de->next)
|
||||||
|
if (de->name[0] != '.' && (de->flags & DF_dir) == DF_dir) {
|
||||||
|
desel = de;
|
||||||
|
max++;
|
||||||
|
}
|
||||||
|
|
||||||
|
d_printf ("Random Tileset %s (%d on %d)\n", desel->name, sel, max);
|
||||||
|
|
||||||
|
if (desel != NULL)
|
||||||
|
strncpy (gfx.tileset, desel->name, LEN_TILESETNAME);
|
||||||
|
gfx.tileset[LEN_TILESETNAME-1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* load the tileset or if not present the files from the default folder */
|
||||||
|
void
|
||||||
|
tileset_load (char *tilesetname)
|
||||||
|
{
|
||||||
|
int i,
|
||||||
|
r,
|
||||||
|
g,
|
||||||
|
b;
|
||||||
|
char fullname[LEN_PATHFILENAME];
|
||||||
|
char filename[LEN_FILENAME];
|
||||||
|
char tileset[LEN_TILESETNAME];
|
||||||
|
SDL_Surface *tmpimage,
|
||||||
|
*tmpimage1;
|
||||||
|
float sfkt;
|
||||||
|
|
||||||
|
d_printf ("Loading Tileset: %s\n", tilesetname);
|
||||||
|
strncpy (tileset, tilesetname, LEN_TILESETNAME);
|
||||||
|
|
||||||
|
/* Calculate the Best Size of the Images */
|
||||||
|
gfx.block.x = gfx.res.x / (bman.fieldsize.x + 1);
|
||||||
|
gfx.block.y = (gfx.res.y - 80) / (bman.fieldsize.y + 1);
|
||||||
|
if (gfx.block.x < gfx.block.y)
|
||||||
|
gfx.block.y = gfx.block.x;
|
||||||
|
else
|
||||||
|
gfx.block.x = gfx.block.y;
|
||||||
|
|
||||||
|
/* create Table of points */
|
||||||
|
scale (gfx.postab, gfx.block.x, 256);
|
||||||
|
sfkt = ((float) gfx.block.x) / ((float) GFX_IMGSIZE);
|
||||||
|
|
||||||
|
/* calculating the best offset for the field on the screen */
|
||||||
|
gfx.offset.x = (gfx.res.x - (gfx.block.x * bman.fieldsize.x)) / 2;
|
||||||
|
gfx.offset.y = gfx.res.y - (gfx.block.y * bman.fieldsize.y);
|
||||||
|
|
||||||
|
/* load the fire */
|
||||||
|
sprintf (fullname, "%s/tileset/%s/fire.bmp", bman.datapath, tileset);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
/* file could not be load, so load teh default tileset */
|
||||||
|
sprintf (fullname, "%s/tileset/default/fire.bmp", bman.datapath);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
printf ("default tileset could not be loaded.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gfx.fire.frames = tmpimage->h / GFX_IMGSIZE;
|
||||||
|
tmpimage1 =
|
||||||
|
scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
|
||||||
|
gfx.fire.frames * gfx.block.y);
|
||||||
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
||||||
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
||||||
|
gfx.fire.image = SDL_DisplayFormat (tmpimage1);
|
||||||
|
SDL_FreeSurface (tmpimage);
|
||||||
|
SDL_FreeSurface (tmpimage1);
|
||||||
|
|
||||||
|
/* load the bomb */
|
||||||
|
sprintf (fullname, "%s/tileset/%s/bomb.bmp", bman.datapath, tileset);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
/* file could not be load, so load teh default tileset */
|
||||||
|
sprintf (fullname, "%s/tileset/default/bomb.bmp", bman.datapath);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
printf ("default tileset could not be loaded.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gfx.bomb.frames = tmpimage->h / GFX_IMGSIZE;
|
||||||
|
tmpimage1 =
|
||||||
|
scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
|
||||||
|
gfx.bomb.frames * gfx.block.y);
|
||||||
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
||||||
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
||||||
|
gfx.bomb.image = SDL_DisplayFormat (tmpimage1);
|
||||||
|
SDL_FreeSurface (tmpimage);
|
||||||
|
SDL_FreeSurface (tmpimage1);
|
||||||
|
|
||||||
|
/* load the powerup's image */
|
||||||
|
for (i = 0; i < PWUP_max; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case (PWUP_good):
|
||||||
|
sprintf (filename, "powerup.bmp");
|
||||||
|
break;
|
||||||
|
case (PWUP_bad):
|
||||||
|
sprintf (filename, "powerbad.bmp");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sprintf (filename, "powersp.bmp");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
/* file could not be load, so load teh default tileset */
|
||||||
|
sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename);
|
||||||
|
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 */
|
||||||
|
for (i = 0; i < FT_max; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case (FT_nothing):
|
||||||
|
sprintf (filename, "background.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_stone):
|
||||||
|
sprintf (filename, "stone.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_block):
|
||||||
|
sprintf (filename, "block.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_death):
|
||||||
|
sprintf (filename, "pwdeath.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_bomb):
|
||||||
|
sprintf (filename, "pwbomb.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_fire):
|
||||||
|
sprintf (filename, "pwfire.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_shoe):
|
||||||
|
sprintf (filename, "pwshoe.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_sp_trigger):
|
||||||
|
sprintf (filename, "sptrigger.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_sp_row):
|
||||||
|
sprintf (filename, "sprow.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_sp_push):
|
||||||
|
sprintf (filename, "sppush.bmp");
|
||||||
|
break;
|
||||||
|
case (FT_sp_kick):
|
||||||
|
sprintf (filename, "spkick.bmp");
|
||||||
|
continue; // remove this if you find a kick image
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i != FT_mixed) {
|
||||||
|
sprintf (fullname, "%s/tileset/%s/%s", bman.datapath, tileset, filename);
|
||||||
|
tmpimage = SDL_LoadBMP (fullname);
|
||||||
|
if (tmpimage == NULL) {
|
||||||
|
sprintf (fullname, "%s/tileset/default/%s", bman.datapath, filename);
|
||||||
|
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;
|
||||||
|
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x,
|
||||||
|
gfx.field[i].frames * gfx.block.y);
|
||||||
|
if (i == FT_nothing || i == FT_block || i == FT_stone)
|
||||||
|
r = g = b = 255;
|
||||||
|
else
|
||||||
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
||||||
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
||||||
|
gfx.field[i].image = SDL_DisplayFormat (tmpimage1);
|
||||||
|
SDL_FreeSurface (tmpimage1);
|
||||||
|
if (i >= FT_sp_trigger && i < FT_max) {
|
||||||
|
// create the smal special thing
|
||||||
|
tmpimage1 = scale_image (tmpimage, 32, 32);
|
||||||
|
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
|
||||||
|
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
|
||||||
|
gfx.smal_special[i - FT_sp_trigger] = SDL_DisplayFormat (tmpimage1);
|
||||||
|
};
|
||||||
|
SDL_FreeSurface (tmpimage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdateRects_nr = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
tileset_free () {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < FT_max; i++) {
|
||||||
|
if (gfx.field[i].image != NULL)
|
||||||
|
SDL_FreeSurface (gfx.field[i].image);
|
||||||
|
gfx.field[i].image = NULL;
|
||||||
|
if (i >= FT_sp_trigger && i < FT_max) {
|
||||||
|
if (gfx.smal_special[i - FT_sp_trigger] != NULL)
|
||||||
|
SDL_FreeSurface (gfx.smal_special[i - FT_sp_trigger]);
|
||||||
|
gfx.smal_special[i - FT_sp_trigger] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gfx.bomb.image != NULL)
|
||||||
|
SDL_FreeSurface (gfx.bomb.image);
|
||||||
|
if (gfx.fire.image != NULL)
|
||||||
|
SDL_FreeSurface (gfx.fire.image);
|
||||||
|
for (i = 0; i < PWUP_max; i++)
|
||||||
|
if (gfx.powerup[i].image != NULL)
|
||||||
|
SDL_FreeSurface (gfx.powerup[i].image);
|
||||||
|
gfx.bomb.image = NULL;
|
||||||
|
gfx.fire.image = NULL;
|
||||||
|
};
|
Loading…
Reference in new issue