Started to work on special items.

trigger already working
http://x.yz.to/bc/specials.tgz required.
origin
patty21 23 years ago
parent b11a7282e2
commit ed59822a82

@ -108,7 +108,8 @@ module.source.files=\
keybinput.h\
single.c\
sysfunc.h\
mapmenu.c
mapmenu.c\
special.c
module.pixmap.name=pixmaps
module.pixmap.type=

@ -31,7 +31,8 @@ bomberclone_SOURCES = \
chat.h \
keybinput.h \
keybinput.c \
single.c
single.c \
special.c
## bomberclone_LDADD =

@ -6,9 +6,13 @@
#define GAME_SPECIAL_ITEMBOMB 10
#define GAME_SPECIAL_ITEMFIRE 10
#define GAME_SPECIAL_ITEMSHOE 15
#define GAME_SPECIAL_ITEMSHOE 10
#define GAME_SPECIAL_ITEMDEATH 25
#define GAME_SPECIAL_ITEMMIXED 10
#define GAME_SPECIAL_ITEMSTRIGGER 10
#define GAME_SPECIAL_ITEMSROW 0
#define GAME_SPECIAL_ITEMSPUSH 0
#define GAME_SPECIAL_ITEMSKICK 0
#define START_BOMBS 1
#define START_RANGE 2
@ -94,10 +98,24 @@ enum _fieldtype {
FT_bomb, // The bomb Powerup
FT_shoe, // The shoe Powerup
FT_mixed, // The mixed Powerup
FT_sp_trigger, // The Triggered bomb Special
FT_sp_row, // The bomb-row special
FT_sp_push, // The push-boms special
FT_sp_kick, // The kick-boms special
FT_max // just to know how many types there are
};
enum _special {
SP_nothing=0, // player has no special
SP_trigger, // triggered bomb
SP_row, // bomb row
SP_push, // push bombs
SP_kick, // push kick
SP_max // just to know how many types there are
};
enum _playerillnestype {
PI_keys = 0, // switch keys
@ -115,7 +133,8 @@ enum _playerillnestype {
enum _bombstate {
BS_off = 0,
BS_ticking,
BS_exploding
BS_exploding,
BS_trigger
};

@ -12,17 +12,18 @@ draw_bomb (_bomb * bomb)
SDL_Rect src,
dest;
/* check the framenumber */
if (bomb->frameto-- == 0) {
bomb->frameto = ANI_BOMBTIMEOUT;
bomb->frame++;
};
if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames || bomb->frameto > ANI_BOMBTIMEOUT) {
bomb->frame = 0;
bomb->frameto = ANI_BOMBTIMEOUT;
if (bomb->state != BS_trigger) {
/* check the framenumber */
if (bomb->frameto-- == 0) {
bomb->frameto = ANI_BOMBTIMEOUT;
bomb->frame++;
};
if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames || bomb->frameto > ANI_BOMBTIMEOUT) {
bomb->frame = 0;
bomb->frameto = ANI_BOMBTIMEOUT;
}
}
src.w = src.w = gfx.bomb.image->w;
dest.w = src.w = gfx.bomb.image->w;
dest.h = src.h = gfx.block.y;
dest.x = gfx.offset.x + (bomb->pos.x * gfx.block.x);
@ -65,8 +66,8 @@ bomb_loop ()
{
int p,
i,
b=0;
_player *player;
b = 0;
_player *player;
_bomb *bomb;
for (p = 0; p < MAX_PLAYERS; p++) {
@ -74,9 +75,10 @@ bomb_loop ()
if ((bman.players[p].state & PSFM_used) != 0) {
for (i = 0; i < MAX_BOMBS; i++) {
bomb = &player->bombs[i];
if (bomb->state == BS_ticking) {
switch (bomb->state){
case BS_ticking:
if (GT_MP_PTPM || bman.gametype == GT_single) {
if (--bomb->to == 0) // bomb will have to explode in the next loop
if (--bomb->to == 0) // bomb will have to explode in the next loop
bomb_explode (p, i);
else
draw_bomb (bomb);
@ -89,9 +91,13 @@ bomb_loop ()
}
draw_bomb (bomb);
}
b++;
}
else if (bomb->state == BS_exploding) {
b++; // Count ticking Bombs for Return value
break;
case BS_trigger:
draw_bomb (bomb);
b++; // Count ticking Bombs for Return value
break;
case BS_exploding:
if (bomb->to > 0) {
do_explosion (p, i);
}
@ -101,12 +107,13 @@ bomb_loop ()
bomb->state = BS_off;
}
bomb->to--;
b++;
}
b++;
break;
}
}
}
}
return b;
return b;
};
void
@ -224,15 +231,15 @@ restore_explosion (_bomb * bomb)
net_game_send_field (_x, _y);
}
}
_x=bomb->pos.x;
_y=bomb->pos.y;
gfx_AddUpdateRect (gfx.offset.x + (_x-bomb->firer[left]) * gfx.block.x,
gfx.offset.y + (_y-bomb->firer[up]) * gfx.block.y,
gfx.block.x*(bomb->firer[left]+bomb->firer[right]+1),
gfx.block.x*(bomb->firer[up]+bomb->firer[down]+1));
/* delete field from the bfield map */
bman.bfield [bomb->pos.x][bomb->pos.y] = 0;
_x = bomb->pos.x;
_y = bomb->pos.y;
gfx_AddUpdateRect (gfx.offset.x + (_x - bomb->firer[left]) * gfx.block.x,
gfx.offset.y + (_y - bomb->firer[up]) * gfx.block.y,
gfx.block.x * (bomb->firer[left] + bomb->firer[right] + 1),
gfx.block.x * (bomb->firer[up] + bomb->firer[down] + 1));
/* delete field from the bfield map */
bman.bfield[bomb->pos.x][bomb->pos.y] = 0;
};
@ -298,9 +305,9 @@ draw_explosion (_bomb * bomb)
dy;
_point p;
bomb->frameto--;
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
bomb->frameto = ANI_FIRETIMEOUT;
bomb->frameto--;
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
bomb->frameto = ANI_FIRETIMEOUT;
for (d = 0; d < 4; d++) {
switch (d) {
@ -325,11 +332,11 @@ draw_explosion (_bomb * bomb)
p.y = bomb->pos.y;
for (r = 0; r < bomb->firer[d]; r++) {
if (bomb->frameto == 0) {
bman.field[p.x][p.y].ex[d].frame++;
if (bman.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
bman.field[p.x][p.y].ex[d].frame = 0;
}
if (bomb->frameto == 0) {
bman.field[p.x][p.y].ex[d].frame++;
if (bman.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
bman.field[p.x][p.y].ex[d].frame = 0;
}
draw_fire (p.x, p.y, d, -1);
p.x += dx;
p.y += dy;
@ -374,7 +381,7 @@ do_explosion (int p, int b)
BS_off && bomb->firerst[d] == -1) {
bomb->firer[d]++;
bman.field[bomb->pos.x + dx][bomb->pos.y + dy].ex[d].count++;
bman.field[bomb->pos.x + dx][bomb->pos.y + dy].ex[d].frame = bomb->firer[d];
bman.field[bomb->pos.x + dx][bomb->pos.y + dy].ex[d].frame = bomb->firer[d];
/* if we have a slow pc we can enable this and disable the drawing animation */
// draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1);
}

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.21 2003/05/11 22:28:14 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.22 2003/05/13 21:53:40 patty21 Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -82,6 +82,7 @@ struct __player {
int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest)
int speeddat; // some data i need to do the speed thing
_playerilness ill[PI_max]; // all possible types
int special; // special the player has
char name[LEN_PLAYERNAME]; // name oder name[0] == 0
unsigned char state; // status of the player
@ -173,6 +174,7 @@ extern void game_set_playerposition();
// everything is declared in field.c
extern void draw_field ();
extern void draw_stone (int x, int y);
extern void field_clear(int x, int y);
extern void field_new (char *filename);
extern void field_set_playerposition (int usermap);
extern void tileset_random ();
@ -243,5 +245,7 @@ extern void mapmenu ();
extern char* getfilename(char* path);
extern void init_map_tileset();
// special.c
extern void special_use (int p_nr);
#endif

@ -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);
}

@ -27,69 +27,70 @@ game_draw_info ()
redraw_logo (0, 0, gfx.res.x, 3 * 16);
if (bman.updatestatusbar) {
gfx_AddUpdateRect (0, 0, gfx.res.x, 3 * 16);
bman.updatestatusbar = 0;
}
bman.players_nr = 0;
if (GT_MP_PTP) {
/* In Multiplayer mode draw Player names and
count the players who are still alife. */
for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSFM_used) != 0) {
if (bman.players[i].gfx_nr != -1 && PS_IS_used (bman.players[i].state)) {
src.x = 3 * bman.players[i].gfx->smal_size.x;
src.y = 0;
src.w = dest.w = bman.players[i].gfx->smal_size.x;
src.h = dest.h = bman.players[i].gfx->smal_size.y;
dest.x = x;
dest.y = j - 4;
gfx_AddUpdateRect (0, 0, gfx.res.x, 3 * 16);
SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest);
}
bman.players_nr = 0;
sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points);
if ((bman.players[i].state & PSFM_alife) != PSFM_alife) { // Player is dead
draw_text (x, j, scrtext, 0);
if ((bman.players[i].state & PSF_used) != PSF_used)
draw_text (x, j, "-------------", 1);
if (GT_MP_PTP) {
/* In Multiplayer mode draw Player names and
count the players who are still alife. */
for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSFM_used) != 0) {
if (bman.players[i].gfx_nr != -1 && PS_IS_used (bman.players[i].state)) {
src.x = 3 * bman.players[i].gfx->smal_size.x;
src.y = 0;
src.w = dest.w = bman.players[i].gfx->smal_size.x;
src.h = dest.h = bman.players[i].gfx->smal_size.y;
dest.x = x;
dest.y = j - 4;
SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest);
}
sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points);
if ((bman.players[i].state & PSFM_alife) != PSFM_alife) { // Player is dead
draw_text (x, j, scrtext, 0);
if ((bman.players[i].state & PSF_used) != PSF_used)
draw_text (x, j, "-------------", 1);
}
else { // players is alife
draw_text (x, j, scrtext, 1);
bman.players_nr++;
}
x = x + 170;
if (x >= gfx.res.x - (120 + 170)) {
x = 0;
j = j + 14;
}
}
else { // players is alife
draw_text (x, j, scrtext, 1);
}
else
/* in single mode count the player's who are still alife */
for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_alife (bman.players[i].state))
bman.players_nr++;
}
x = x + 170;
if (x >= gfx.res.x - (120 + 170)) {
x = 0;
j = j + 14;
}
}
}
else
/* in single mode count the player's who are still alife */
for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_alife (bman.players[i].state))
bman.players_nr++;
x = gfx.res.x - 120;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n);
draw_text (x, 0, text, 1);
sprintf (text, "Range: %2d", bman.players[bman.p_nr].range);
draw_text (x, 16, text, 1);
sprintf (text, "Speed: %2d", bman.players[bman.p_nr].speed);
draw_text (x, 32, text, 1);
if (bman.state == GS_ready && GT_MP_PTPM)
draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready)
draw_text (100, 32, "Waiting for the Server to Start", 1);
x = gfx.res.x - 120;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n);
draw_text (x, 0, text, 1);
sprintf (text, "Range: %2d", bman.players[bman.p_nr].range);
draw_text (x, 16, text, 1);
sprintf (text, "SP: %d Speed: %2d", bman.players[bman.p_nr].special,
bman.players[bman.p_nr].speed);
draw_text (x - 90, 32, text, 1);
if (bman.state == GS_ready && GT_MP_PTPM)
draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready)
draw_text (100, 32, "Waiting for the Server to Start", 1);
}
if (debug) { /* do some debug informations on the screen */
redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y);
redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y);
for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y - 1);
if (GT_MP_PTP) {
@ -171,8 +172,8 @@ game_loop ()
}
else
key_bomb = 0;
if (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) {
d_printf ("not in use yet\n");
if ((keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) && bman.players[bman.p_nr].special) {
special_use (bman.p_nr);
}
}
else if (GT_MP_PTPM && keys[SDLK_F4] && event.type == SDL_KEYDOWN) {

@ -873,6 +873,19 @@ gfx_load_tileset (char *tilesetname)
case (FT_shoe):
sprintf (filename, "%s/tileset/%s/fieldshoe.bmp", bman.datapath, tileset);
break;
case (FT_sp_trigger):
sprintf (filename, "%s/tileset/%s/fieldstrigger.bmp", bman.datapath, tileset);
break;
case (FT_sp_row):
sprintf (filename, "%s/tileset/%s/fieldsrow.bmp", bman.datapath, tileset);
break;
case (FT_sp_push):
sprintf (filename, "%s/tileset/%s/fieldspush.bmp", bman.datapath, tileset);
break;
case (FT_sp_kick):
sprintf (filename, "%s/tileset/%s/fieldskick.bmp", bman.datapath, tileset);
continue; // remove this if you find a kick image
break;
}
if (i == FT_mixed) {
tmpimage =

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.17 2003/05/11 03:27:18 patty21 Exp $ */
/* $Id: network.c,v 1.18 2003/05/13 21:53:40 patty21 Exp $ */
/*
network routines.
*/
@ -760,7 +760,10 @@ net_new_game ()
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */
bman.players[p].special = SP_nothing;
bman.updatestatusbar=1;
for (i = 0; i < PI_max; i++) /* all types of illnes turn them off */
bman.players[p].ill[i].to = 0;
bman.players[p].frame = 0;
bman.players[p].frameto = 0;

@ -143,9 +143,7 @@ player_check_powerup (_player * p)
p->bombs_n++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
field_clear(fx,fy);
break;
/* we found a fire powerup */
@ -154,9 +152,7 @@ player_check_powerup (_player * p)
p->range++;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
field_clear(fx,fy);
break;
/* we found a shoe powerup */
@ -165,9 +161,7 @@ player_check_powerup (_player * p)
p->speed *= SPEEDMUL;
bman.updatestatusbar = 1;
}
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
field_clear(fx,fy);
break;
/* we found a death ?powerup? */
@ -176,11 +170,20 @@ player_check_powerup (_player * p)
bman.updatestatusbar = 1;
if (bman.gametype != GT_single)
net_game_send_ill (bman.p_nr);
bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
field_clear(fx,fy);
break;
/* we found a special */
case FT_sp_trigger:
case FT_sp_row:
case FT_sp_push:
case FT_sp_kick:
if (p->special==SP_nothing) {
p->special=ft-FT_sp_trigger+1;
field_clear(fx,fy);
bman.updatestatusbar=1;
}
break;
}
};
@ -355,7 +358,9 @@ player_drop_bomb (int pl_nr)
d_printf ("Player %d Dropped Bomb %d\n", bman.p_nr, i);
bomb->r = player->range;
bomb->state = BS_ticking;
if (player->special== SP_trigger)
bomb->state = BS_trigger;
else bomb->state = BS_ticking;
bomb->ex_nr = -1;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.13 2003/05/12 02:31:09 stpohle Exp $ */
/* $Id: single.c,v 1.14 2003/05/13 21:53:40 patty21 Exp $ */
/* single player */
#include "basic.h"
@ -29,6 +29,8 @@ single_game_new ()
bman.players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED;
bman.players[p].special= SP_nothing;
bman.updatestatusbar=1;
for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1;

Loading…
Cancel
Save