fixed jittery player-player collision

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4069 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-12-26 16:13:29 +00:00
parent a415196823
commit ee9f87b609
+8 -11
View File
@@ -512,17 +512,14 @@ 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, mag = sqrtf(dx*dx+dy*dy);
if(mag)
{
dx /= mag;
dy /= mag;
pl->o.x -= f*(dx + d.x);
pl->o.y -= f*(dy + d.y);
if(collide(pl, false, drop, rise)) continue;
pl->o.x += f*(dx + d.x);
pl->o.y += f*(dy + d.y);
}
float dx = hitplayer->o.x-pl->o.x, dy = hitplayer->o.y-pl->o.y,
push = dx*d.x + dy*d.y,
px = push*dx, py = push*dy;
pl->o.x -= f*px;
pl->o.y -= f*py;
if(collide(pl, false, drop, rise)) continue;
pl->o.x += f*px;
pl->o.y += f*py;
}
// player stuck, try slide along y axis
pl->o.x -= f*d.x;