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:
+8
-11
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user