network player animation fixed

origin
stpohle 22 years ago
parent 732c0e5b14
commit 343cdd47b9

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.11 2003/12/28 04:51:24 stpohle Exp $ */
/* $Id: basic.h,v 1.12 2004/01/03 04:39:20 stpohle Exp $ */
/* basic types which we need everywhere */
#ifndef _BC_BASIC_H_
@ -48,11 +48,10 @@
#define EXPLOSIONTIMEOUT 0.5
#define ANI_FIRETIMEOUT 2
#define ANI_BOMBTIMEOUT 1
#define ANI_PLAYERTIMEOUT 1
#define ANI_PLAYERILLTIMEOUT 1
#define ANI_STONETIMEOUT 5
#define ANI_PLAYERTIMEOUT 0.66
#define ANI_PLAYERILLTIMEOUT 1.0
#define BOMB_TIMEOUT 5
#define BOMB_TIMEOUT 4.0
#define ILL_TIMEOUT 20
#define ILL_SLOWSPEED 0.01
#define ILL_FASTSPEED 0.5

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.11 2004/01/03 02:12:33 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.12 2004/01/03 04:39:20 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -194,7 +194,7 @@ extern int dead_playerani ();
extern void draw_player (_player * player);
extern void restore_players_screen ();
extern void move_player (int pl_nr);
extern int stepmove_player (int pl_nr);
extern float stepmove_player (int pl_nr);
extern void player_drop_bomb (int pl_nr);
extern void get_player_on (float x, float y, int pl_nr[]);
extern void player_died (_player * player, signed char dead_by);
@ -202,7 +202,6 @@ extern void draw_players ();
extern void player_animation (_player * player);
extern int check_field (short int x, short int y);
extern int check_exfield (short int x, short int y);
extern void player_calcstep (_player * pl);
extern void player_calcpos ();
extern void player_set_ilness (_player *p, int t);
extern void player_clear_ilness (_player *p, int type);
@ -223,17 +222,6 @@ extern void do_explosion (int p, int b);
extern void restore_explosion (_bomb * bomb);
extern int explosion_check_field (int x, int y, int p, int b);
// menus
//extern void draw_select (int select, _menu menu[], int x, int y);
//extern int menu_loop (char *menutitle, _menu menu[], int lastselect);
//extern void draw_menu (char *text, _menu menu[], int *x, int *y);
//extern void menu_get_text (char *title, char *text, int len);
//extern void menu_displaymessage (char *title, char *text);
//extern void menu_displaytext (char *title, char *text, Uint8 r, Uint8 g, Uint8 b);
//extern char *menu_dir_select (char *title, char *path, signed char dirflags);
//void menu_clearkeybuff();
//void draw_menubox (int x, int y);
// configuration
extern void config_init (int argc, char **argv);
extern void config_menu ();

@ -1,4 +1,4 @@
/* $Id: map.h,v 1.7 2004/01/03 03:01:30 stpohle Exp $ */
/* $Id: map.h,v 1.8 2004/01/03 04:39:20 stpohle Exp $ */
/* map.h */
#ifndef _MAP_H_
@ -11,6 +11,9 @@
#define FIELDHURRYSIZEMIN 5 /* min size for the field */
#define FIELDHURRYTIMEOUT 120.0 // game timeout for hurry and dropping mode (1min)
#define ANI_STONETIMEOUT 1.0 // factor for the animation frame je seconds
#define ANI_POWERUPTIMEOUT 0.5 // factor for powerup animations
struct __ex_field {
unsigned char count;

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.52 2004/01/03 03:29:44 stpohle Exp $ */
/* $Id: field.c,v 1.53 2004/01/03 04:39:21 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */
#include "bomberclone.h"
@ -243,7 +243,7 @@ field_animation ()
/* animate this stone */
if (stone->type == FT_stone) {
if (stone->frame < gfx.field[FT_stone].frames)
stone->frame += (timefactor/4.0f);
stone->frame += ((timefactor/4.0f) * ANI_STONETIMEOUT);
}
else { /* animation is a powerup */
/* select right powerup animation */
@ -256,7 +256,7 @@ field_animation ()
/* do the animation of the FT_mixed */
oldframe = (int)stone->frame;
stone->frame += (timefactor/4.0f);
stone->frame += ((timefactor/4.0f) * ANI_POWERUPTIMEOUT);
if ((int)stone->frame != oldframe && stone->type == FT_mixed) {
stone->mixframe++;
if (stone->mixframe < FT_death || stone->mixframe >= FT_mixed)

@ -660,7 +660,7 @@ send_playermove (_net_addr * addr, int p_nr, _player * pl)
p_dat.m = pl->m;
p_dat.d = pl->d;
p_dat.p_nr = p_nr;
p_dat.speed = pl->speed;
p_dat.speed = HTON16 (FTOI16(pl->speed));
p_dat.tunnelto = HTON16 (pl->tunnelto);
send_pkg ((struct pkg *) &p_dat, addr);
@ -684,10 +684,12 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
pl->m = p_dat->m;
pl->d = p_dat->d;
pl->speed = p_dat->speed;
pl->pos.x = I16TOF (HTON16 (p_dat->pos.x));
pl->pos.y = I16TOF (HTON16 (p_dat->pos.y));
pl->tunnelto = I16TOF (HTON16 (p_dat->tunnelto));
pl->speed = I16TOF (NTOH16 (p_dat->speed));
pl->pos.x = I16TOF (NTOH16 (p_dat->pos.x));
pl->pos.y = I16TOF (NTOH16 (p_dat->pos.y));
pl->tunnelto = I16TOF (NTOH16 (p_dat->tunnelto));
player_animation (pl);
}

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.57 2004/01/03 03:29:44 stpohle Exp $
/* $Id: player.c,v 1.58 2004/01/03 04:39:21 stpohle Exp $
* player.c - everything what have to do with the player */
#include <SDL.h>
@ -240,7 +240,7 @@ int check_exfield (short int x, short int y) {
/* make only a smal step until i can go around the corner
return the rest speed for this move */
int
float
stepmove_player (int pl_nr)
{
_point bomb1[MAX_PLAYERS * MAX_BOMBS],
@ -378,9 +378,8 @@ void
move_player (int pl_nr)
{
int oldd,
stepsleft,
speed;
int oldd;
float speed, stepsleft;
_player *p = &players[pl_nr];
oldd = p->d;
@ -536,14 +535,14 @@ player_animation (_player * player)
return;
if (PS_IS_alife (player->state)) {
player->frame += timefactor;
player->frame += (timefactor * ANI_PLAYERTIMEOUT * 15 * player->speed);
if ((int)player->frame >= player->gfx->ani.frames)
player->frame = 0.0f;
}
if (PS_IS_dead (player->state)) {
if ((int)player->frame < gfx.dead.frames)
player->frame += timefactor;
player->frame += (timefactor * ANI_PLAYERTIMEOUT);
}
};
@ -564,30 +563,6 @@ dead_playerani ()
};
void
player_calcstep (_player * pl)
{
_pointf d;
player_animation (pl);
d.x = 0;
d.y = 0;
if (pl->d == left)
d.x = -pl->speed * timefactor;
else if (pl->d == right)
d.x = pl->speed * timefactor;
else if (pl->d == up)
d.y = -pl->speed * timefactor;
else if (pl->d == down)
d.y = pl->speed * timefactor;
if (map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_block
&& map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_stone) {
pl->pos.x += d.x;
pl->pos.y += d.y;
}
};
/*
calc the position on the screen for moving network players
@ -599,15 +574,18 @@ player_calcpos ()
int oldm,
oldd,
p;
float oldspeed;
for (p = 0; p < MAX_PLAYERS; p++) {
pl = &players[p];
if (PS_IS_netplayer (pl->state) && PS_IS_alife (pl->state) && pl->m != 0) {
player_animation (pl);
oldspeed = pl->speed;
oldm = pl->m;
oldd = pl->d;
if (pl->speed > 0.0)
stepmove_player (p);
pl->speed = oldspeed;
}
}
};

Loading…
Cancel
Save