about summary refs log tree commit diff
path: root/src/game/client/components/players.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-03 20:03:01 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-03 20:03:01 +0000
commit53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b (patch)
treed9014120bd015f7e3fcc4f2cf997321ba0494b70 /src/game/client/components/players.cpp
parent37f3fa6c6efe231d5a172dbee6a50d63bf42b910 (diff)
downloadzcatch-53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b.tar.gz
zcatch-53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b.zip
added favorites. no saving of them yet however
Diffstat (limited to 'src/game/client/components/players.cpp')
-rw-r--r--src/game/client/components/players.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp
index f2d81323..68cf032b 100644
--- a/src/game/client/components/players.cpp
+++ b/src/game/client/components/players.cpp
@@ -58,6 +58,22 @@ void PLAYERS::render_hand(TEE_RENDER_INFO *info, vec2 center_pos, vec2 dir, floa
 	gfx_quads_end();
 }
 
+inline float normalize_angular(float f)
+{
+	return fmod(f, pi*2);
+}
+
+inline float mix_angular(float src, float dst, float amount)
+{
+	src = normalize_angular(src);
+	dst = normalize_angular(dst);
+	float d0 = dst-src;
+	float d1 = dst-(src+pi*2);
+	if(fabs(d0) < fabs(d1))
+		return src+d0*amount;
+	return src+d1*amount;
+}
+
 void PLAYERS::render_player(
 	const NETOBJ_CHARACTER *prev_char,
 	const NETOBJ_CHARACTER *player_char,
@@ -112,7 +128,7 @@ void PLAYERS::render_player(
 	if(player.attacktick != prev.attacktick)
 		mixspeed = 0.1f;
 	
-	float angle = mix(gameclient.clients[info.cid].angle, player.angle/256.0f, mixspeed);
+	float angle = mix_angular(gameclient.clients[info.cid].angle, player.angle/256.0f, mixspeed);
 	gameclient.clients[info.cid].angle = angle;
 	vec2 direction = get_direction((int)(angle*256.0f));