|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: field.c,v 1.18 2003/05/11 22:29:28 stpohle Exp $ */
|
|
|
|
|
/* $Id: field.c,v 1.19 2003/05/13 21:53:40 patty21 Exp $ */
|
|
|
|
|
/* field.c - procedures which are needed to control the field */
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -267,6 +267,44 @@ void field_set_playerposition (int usermap) {
|
|
|
|
|
#undef PLY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clear field and send this to all netplayers
|
|
|
|
|
void
|
|
|
|
|
field_clear(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
bman.field[x][y].type = FT_nothing;
|
|
|
|
|
if (bman.gametype != GT_single)
|
|
|
|
|
net_game_send_field (x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// put items into the field
|
|
|
|
|
void
|
|
|
|
|
field_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
field_new (char *filename)
|
|
|
|
|
{
|
|
|
|
@ -274,8 +312,6 @@ field_new (char *filename)
|
|
|
|
|
y,
|
|
|
|
|
d;
|
|
|
|
|
FILE *fmap;
|
|
|
|
|
float fkt;
|
|
|
|
|
int nb_try;
|
|
|
|
|
|
|
|
|
|
if(filename)
|
|
|
|
|
{
|
|
|
|
@ -293,7 +329,7 @@ field_new (char *filename)
|
|
|
|
|
|
|
|
|
|
/* this is the item factor we multiply it with this so we know
|
|
|
|
|
how much items we want in the game */
|
|
|
|
|
fkt = ((float)(bman.fieldsize.x * bman.fieldsize.y))/(25.0 * 17.0);
|
|
|
|
|
// fkt = ((float)(bman.fieldsize.x * bman.fieldsize.y))/(25.0 * 17.0);
|
|
|
|
|
|
|
|
|
|
// Clean and create the field //
|
|
|
|
|
if (fmap == NULL) {
|
|
|
|
@ -336,75 +372,24 @@ field_new (char *filename)
|
|
|
|
|
/* Set the Playerinformation */
|
|
|
|
|
field_set_playerposition (fmap != NULL);
|
|
|
|
|
|
|
|
|
|
nb_try = 100; // to prevent infinite loops (maybe there are no stones)
|
|
|
|
|
/* put the fire powerups in the field */
|
|
|
|
|
for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMFIRE * fkt; d++) {
|
|
|
|
|
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 = FT_fire;
|
|
|
|
|
x = y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nb_try = 100;
|
|
|
|
|
field_fillitems (FT_fire, GAME_SPECIAL_ITEMFIRE);
|
|
|
|
|
/* put the bomb powerups in the field */
|
|
|
|
|
for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMBOMB * fkt; d++) {
|
|
|
|
|
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 = FT_bomb;
|
|
|
|
|
x = y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nb_try = 100;
|
|
|
|
|
field_fillitems (FT_bomb, GAME_SPECIAL_ITEMBOMB);
|
|
|
|
|
/* put the shoe powerup in the field */
|
|
|
|
|
for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMSHOE * fkt; d++) {
|
|
|
|
|
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 = FT_shoe;
|
|
|
|
|
x = y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nb_try = 100;
|
|
|
|
|
field_fillitems (FT_shoe, GAME_SPECIAL_ITEMSHOE);
|
|
|
|
|
/* put the death ?powerups? in the field */
|
|
|
|
|
for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMDEATH * fkt; d++) {
|
|
|
|
|
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 = FT_death;
|
|
|
|
|
x = y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nb_try=100;
|
|
|
|
|
field_fillitems (FT_death, GAME_SPECIAL_ITEMDEATH);
|
|
|
|
|
/* put the mixed powerrup in the field */
|
|
|
|
|
for (d = 0, x = 0, y = 0; d < GAME_SPECIAL_ITEMDEATH * fkt; d++) {
|
|
|
|
|
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 = FT_mixed;
|
|
|
|
|
x = y = 0;
|
|
|
|
|
}
|
|
|
|
|
field_fillitems (FT_mixed, GAME_SPECIAL_ITEMMIXED);
|
|
|
|
|
/* put the trigger special in the field */
|
|
|
|
|
field_fillitems (FT_sp_trigger, GAME_SPECIAL_ITEMSTRIGGER);
|
|
|
|
|
/* put the row special in the field */
|
|
|
|
|
field_fillitems (FT_sp_row, GAME_SPECIAL_ITEMSROW);
|
|
|
|
|
/* put the push special in the field */
|
|
|
|
|
field_fillitems (FT_sp_push, GAME_SPECIAL_ITEMSPUSH);
|
|
|
|
|
/* put the kick special in the field */
|
|
|
|
|
field_fillitems (FT_sp_kick, GAME_SPECIAL_ITEMSKICK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|