0

高度なオブジェクト射影式の合成に問題があります。私はすでに、次のようないくつかの基本的な物理シミュレーション式を把握しています。

  • オブジェクトの速度: x += cos(angle); y += sin(angle); *角度は、マウスの位置または tan(...ターゲット値と初期値) のいずれかによって取得できます

しかし、それは角度に基づいて直進するだけです。

  • 重力: Yvelocity = Yvelocity - gravity; if(!isHitPlatform) { Obj.y += YVelocity }

  • バウンス:// No point if we've not been sized... if (height > 0) { // Are we bouncing... if (bounce) { // Add the vDelta to the yPos // vDelta may be postive or negative, allowing // for both up and down movement... yPos += vDelta; // Add the gravity to the vDelta, this will slow down // the upward movement and speed up the downward movement... // You may wish to place a max speed to this vDelta += gDelta; // If the sprite is not on the ground... if (yPos + SPRITE_HEIGHT >= height) { // Seat the sprite on the ground yPos = height - SPRITE_HEIGHT; // If the re-bound delta is 0 or more then we've stopped // bouncing... if (rbDelta >= 0) { // Stop bouncing... bounce = false; } else { // Add the re-bound degregation delta to the re-bound delta rbDelta += rbDegDelta; // Set the vDelta... vDelta = rbDelta; } } } }

これらの 3 つの式を組み合わせて、角度によって決定されるアーチにオブジェクトを投影できる効率的で軽量なアルゴリズムを作成する方法が必要ですが、停止する前に数回跳ね続けます。各ポイント間の不連続。*注: 手榴弾を af(x) = -x^2 式で決定すると、傾斜が大きくなるにつれてジャンプの不連続性が大きくなり、式を逆にして x = +-y 値を見つける必要があります (+ または - 、境界を確認してください)。

4

1 に答える 1