From de3c0860d6ae4c83c8eb1184a57a100b14cf4450 Mon Sep 17 00:00:00 2001 From: stpohle Date: Sat, 8 Nov 2003 20:14:31 +0000 Subject: [PATCH] some animation problem fixed.. mostly the frames still wasn't all with float --- include/map.h | 6 +++--- include/packets.h | 5 ++++- src/bomb.c | 6 +++--- src/field.c | 16 ++++++++-------- src/packets.c | 28 ++++++++++++++++++++-------- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/include/map.h b/include/map.h index 55b138a..81f47af 100644 --- a/include/map.h +++ b/include/map.h @@ -1,4 +1,4 @@ -/* $Id: map.h,v 1.4 2003/11/08 06:27:58 stpohle Exp $ */ +/* $Id: map.h,v 1.5 2003/11/08 20:14:31 stpohle Exp $ */ /* map.h */ #ifndef _MAP_H_ @@ -6,8 +6,8 @@ struct __ex_field { unsigned char count; - unsigned char frame; // we may have to change this.. because the frames -} typedef _ex_field; // might have all put to float. + float frame; +} typedef _ex_field; struct __field { diff --git a/include/packets.h b/include/packets.h index 495ed02..f38c707 100644 --- a/include/packets.h +++ b/include/packets.h @@ -80,7 +80,10 @@ struct pkg_field { signed char mixframe; // data for the mixed frame Sint16 frame; // frame (frame > 0 && FS_stone) unsigned char special; // to save special stones, or the tunnel number - _ex_field ex[4]; // count up every explosion there is on this field for ever direction + struct { + unsigned char count; + unsigned char frame; + } ex[4]; // count up every explosion there is on this field for ever direction Sint32 ex_nr; // number to identify the explosion. }; diff --git a/src/bomb.c b/src/bomb.c index 1b21e06..fbf736e 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -1,4 +1,4 @@ -/* $Id: bomb.c,v 1.49 2003/11/08 19:53:07 stpohle Exp $ */ +/* $Id: bomb.c,v 1.50 2003/11/08 20:14:32 stpohle Exp $ */ /* everything what have to do with the bombs */ #include "bomberclone.h" @@ -20,7 +20,7 @@ draw_bomb (_bomb * bomb) if (bomb->state != BS_trigger || ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT))) { /* check the framenumber */ - bomb->frame += timefactor; + bomb->frame += (timefactor/3.0); if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames) bomb->frame = 0.0f; } @@ -277,7 +277,7 @@ draw_fire (int x, int y, int d, int frame) dest.x = gfx.offset.x + x * gfx.block.x; dest.y = gfx.offset.y + y * gfx.block.y; - src.y = (int)frame * src.w; + src.y = frame * src.w; src.x = d * src.w; gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100)); diff --git a/src/field.c b/src/field.c index 8dad960..4902cab 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.49 2003/11/08 19:53:07 stpohle Exp $ */ +/* $Id: field.c,v 1.50 2003/11/08 20:14:32 stpohle Exp $ */ /* field.c - procedures which are needed to control the field */ #include "bomberclone.h" @@ -133,7 +133,7 @@ draw_stone (int x, int y) } else if (stone->type > FT_nothing && stone->type < FT_death) { - src.y = stone->frame * gfx.field[stone->type].h; + src.y = (int)stone->frame * gfx.field[stone->type].h; dest.h = src.h = gfx.field[stone->type].h; dest.y -= (gfx.field[stone->type].h - gfx.field[stone->type].w); srcimg = gfx.field[stone->type].image; @@ -152,7 +152,7 @@ draw_stone (int x, int y) srcimg = gfx.powerup[d].image; if (stone->frame >= gfx.powerup[d].frames) stone->frame = 0; - src.y = stone->frame * gfx.block.y; + src.y = (int)stone->frame * gfx.block.y; } if (srcimg != NULL && stone->type != FT_tunnel) @@ -171,7 +171,7 @@ draw_stone (int x, int y) if (y < map.size.y - 1 && gfx.field[map.field[x][y + 1].type].h > gfx.field[map.field[x][y + 1].type].w) { src.x = 0; - src.y = map.field[x][y + 1].frame * gfx.field[map.field[x][y + 1].type].h; + src.y = (int)map.field[x][y + 1].frame * gfx.field[map.field[x][y + 1].type].h; dest.h = src.h = gfx.field[map.field[x][y + 1].type].h - gfx.field[map.field[x][y + 1].type].w; dest.w = src.w = gfx.field[map.field[x][y + 1].type].w; @@ -189,8 +189,8 @@ draw_stone (int x, int y) draw_fire (x, y, d, -1); } - if (debug) - font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) + 10); +// if (debug) +// font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) + 10); return; }; @@ -248,7 +248,7 @@ field_animation () /* animate this stone */ if (stone->type == FT_stone) { if (stone->frame < gfx.field[FT_stone].frames) - stone->frame += timefactor; + stone->frame += (timefactor/4.0f); } else { /* animation is a powerup */ /* select right powerup animation */ @@ -261,7 +261,7 @@ field_animation () /* do the animation of the FT_mixed */ oldframe = (int)stone->frame; - stone->frame += timefactor; + stone->frame += (timefactor/4.0f); if ((int)stone->frame != oldframe && stone->type == FT_mixed) { stone->mixframe++; if (stone->mixframe < FT_death || stone->mixframe >= FT_mixed) diff --git a/src/packets.c b/src/packets.c index 7733248..da69a45 100644 --- a/src/packets.c +++ b/src/packets.c @@ -324,7 +324,8 @@ void send_field (_net_addr * addr, int x, int y, _field * field) { struct pkg_field f_dat; - + int i; + d_printf ("send_field [%d,%d]\n", x, y); f_dat.h.typ = PKG_field; @@ -337,8 +338,10 @@ send_field (_net_addr * addr, int x, int y, _field * field) if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y) return; - memcpy (&f_dat.ex, &map.field[x][y].ex, 4*sizeof (_ex_field)); - + for (i = 0; i < 4; i++) { + f_dat.ex[i].count = map.field[x][y].ex[i].count; + f_dat.ex[i].frame = (int)map.field[x][y].ex[i].frame; + } f_dat.type = map.field[x][y].type; f_dat.mixframe = map.field[x][y].mixframe; f_dat.special = map.field[x][y].special; @@ -352,6 +355,8 @@ send_field (_net_addr * addr, int x, int y, _field * field) void do_field (struct pkg_field *f_dat, _net_addr * addr) { + int i; + if (addr->pl_nr == -1) return; @@ -360,7 +365,10 @@ do_field (struct pkg_field *f_dat, _net_addr * addr) map.field[f_dat->x][f_dat->y].type = f_dat->type; map.field[f_dat->x][f_dat->y].mixframe = f_dat->mixframe; map.field[f_dat->x][f_dat->y].special = f_dat->special; - memcpy (&map.field[f_dat->x][f_dat->y].ex, &f_dat->ex, 4*sizeof (_ex_field)); + for (i = 0; i < 4; i++) { + map.field[f_dat->x][f_dat->y].ex[i].count = f_dat->ex[i].count; + map.field[f_dat->x][f_dat->y].ex[i].frame = f_dat->ex[i].frame; + } map.field[f_dat->x][f_dat->y].frame = I16TOF (NTOH16 (f_dat->frame)); map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (f_dat->ex_nr); } @@ -856,8 +864,10 @@ send_fieldline (_net_addr * addr, int line) f_dat.special[i] = map.field[i][line].special; map.field[i][line].frame = 0.0f; map.field[i][line].ex_nr = 0; - for (j = 0; j < 4; j++) - map.field[i][line].ex[j].frame = map.field[i][line].ex[j].count = 0; + for (j = 0; j < 4; j++) { + map.field[i][line].ex[j].frame = 0.0f; + map.field[i][line].ex[j].count = 0; + } } send_pkg ((struct pkg *) &f_dat, addr); }; @@ -890,8 +900,10 @@ do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr) map.field[i][f_dat->line].type = f_dat->type[i]; map.field[i][f_dat->line].special = f_dat->special[i]; map.field[i][f_dat->line].frame = 0.0f; - for (d = 0; d < 4; d++) - map.field[i][f_dat->line].ex[d].frame = map.field[i][f_dat->line].ex[d].count = 0; + for (d = 0; d < 4; d++) { + map.field[i][f_dat->line].ex[d].frame = 0.0f; + map.field[i][f_dat->line].ex[d].count = 0; + } } };