相关疑难解决方法(0)

如何计算弹跳角度?

我玩了一会儿,但我简直无法理解.

我制造了一个发射导弹的坦克,当导弹击中墙壁时,我希望它们反弹,但我希望它们能够以正确的角度反弹.

现在我没有任何障碍,当导弹越过viewportRectangle我制造的时候导弹就会反弹.

我正在寻找的解决方案是否相当先进?

有相对简单的方法吗?

c# xna physics

62
推荐指数
5
解决办法
7万
查看次数

Python和Pygame:球与圆的内部碰撞

我正在制作一个游戏,其中球一个更大的圆圈内部反弹.较大的圆圈不会移动.

这是我目前用于这些冲突的代码:

def collideCircle(circle, ball):
    """Check for collision between a ball and a circle"""
    dx = circle.x - ball.x
    dy = circle.y - ball.y

    distance = math.hypot(dx, dy)

    if distance >= circle.size + ball.size:
        # We don't need to change anything about the circle, just the ball
        tangent = math.atan2(dy, dx)
        ball.angle = 2 * tangent - ball.angle
        ball.speed *= elasticity + 0.251

        angle = 0.5 * math.pi + tangent
        ball.x -= math.sin(angle)
        ball.y += math.cos(angle) …
Run Code Online (Sandbox Code Playgroud)

python pygame physics collision-detection

7
推荐指数
2
解决办法
7924
查看次数

标签 统计

physics ×2

c# ×1

collision-detection ×1

pygame ×1

python ×1

xna ×1