public void HandleCollision(PlayerStriker playerStriker, GameTime gameTime) { CheckBounce(); if (CheckIntersect(playerStriker)) { velocity += (position - playerStriker.position) * (float)gameTime.ElapsedGameTime.TotalSeconds; } velocity *= friction; position += velocity; }
public bool CheckIntersect(PlayerStriker playerStriker) { var playerX = playerStriker.position.X; var playerY = playerStriker.position.Y; var deltax = position.X - playerX; var deltay = position.Y - playerY; var distance = Math.Sqrt(deltax * deltax + deltay * deltay); if (distance < radius + playerStriker.radius) { velocity *= collisionSlowdown; //slow it down return(true); } return(false); }