clamp player push to non-zero range

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4070 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-12-26 16:25:49 +00:00
parent ee9f87b609
commit 0aba25d6f8
+1 -1
View File
@@ -513,7 +513,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime)
if(pl->type==ENT_PLAYER && hitplayer)
{
float dx = hitplayer->o.x-pl->o.x, dy = hitplayer->o.y-pl->o.y,
push = dx*d.x + dy*d.y,
push = (dx*d.x + dy*d.y)/max(dx*dx + dy*dy, 1e-3f),
px = push*dx, py = push*dy;
pl->o.x -= f*px;
pl->o.y -= f*py;