diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 07:43:41 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 07:43:41 +0000 |
| commit | 33b50738e63a3c79861bcfd88cb39377f85776c4 (patch) | |
| tree | a7857f0b219e02337da6d8a1a6b66693760b9b6e /src/game/client/components | |
| parent | e21b6983abaefd0037435c76e9b41cfbbfbe51d5 (diff) | |
| download | zcatch-33b50738e63a3c79861bcfd88cb39377f85776c4.tar.gz zcatch-33b50738e63a3c79861bcfd88cb39377f85776c4.zip | |
added dead reckoning to the characters
Diffstat (limited to 'src/game/client/components')
| -rw-r--r-- | src/game/client/components/players.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 4e315f32..43ff3e77 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -158,7 +158,7 @@ void PLAYERS::render_player( bool stationary = player.vx < 1 && player.vx > -1; bool inair = col_check_point(player.x, player.y+16) == 0; - bool want_other_dir = (player.wanted_direction == -1 && vel.x > 0) || (player.wanted_direction == 1 && vel.x < 0); + bool want_other_dir = (player.direction == -1 && vel.x > 0) || (player.direction == 1 && vel.x < 0); // evaluate animation float walk_time = fmod(position.x, 100.0f)/100.0f; @@ -194,8 +194,8 @@ void PLAYERS::render_player( } gameclient.effects->skidtrail( - position+vec2(-player.wanted_direction*6,12), - vec2(-player.wanted_direction*100*length(vel),-50) + position+vec2(-player.direction*6,12), + vec2(-player.direction*100*length(vel),-50) ); } @@ -425,27 +425,27 @@ void PLAYERS::render_player( void PLAYERS::on_render() { - int num = snap_num_items(SNAP_CURRENT); - for(int i = 0; i < num; i++) + //int num = snap_num_items(SNAP_CURRENT); + for(int i = 0; i < MAX_CLIENTS; i++) { - SNAP_ITEM item; - const void *data = snap_get_item(SNAP_CURRENT, i, &item); + // only render active characters + if(!gameclient.snap.characters[i].active) + continue; - if(item.type == NETOBJTYPE_CHARACTER) - { - const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); - const void *prev_info = snap_find_item(SNAP_PREV, NETOBJTYPE_PLAYER_INFO, item.id); - const void *info = snap_find_item(SNAP_CURRENT, NETOBJTYPE_PLAYER_INFO, item.id); + const void *prev_info = snap_find_item(SNAP_PREV, NETOBJTYPE_PLAYER_INFO, i); + const void *info = snap_find_item(SNAP_CURRENT, NETOBJTYPE_PLAYER_INFO, i); - if(prev && prev_info && info) - { - render_player( - (const NETOBJ_CHARACTER *)prev, - (const NETOBJ_CHARACTER *)data, - (const NETOBJ_PLAYER_INFO *)prev_info, - (const NETOBJ_PLAYER_INFO *)info - ); - } - } + if(prev_info && info) + { + NETOBJ_CHARACTER prev_char = gameclient.snap.characters[i].prev; + NETOBJ_CHARACTER cur_char = gameclient.snap.characters[i].cur; + + render_player( + &prev_char, + &cur_char, + (const NETOBJ_PLAYER_INFO *)prev_info, + (const NETOBJ_PLAYER_INFO *)info + ); + } } } |