I am working on a vertical 2D platform auto-jumper game. Level generation is done procedurally using patterns and adaptive difficulty. Game will be released on iOS / OS X and uses Apples Sprite Kit
framework.
Physics are implemented using Sprite Kit
s own physics engine. Jumping for example is done by applying a force or changing the current velocity of the player entity. Something like that:
playerEntity.physicsComponent.velocity =
CGVectorMake(playerEntity.physicsComponent.velocity.dx, 850.0)
To keep player in it's own "flow zone" adaptive difficulty is very important. This requires the use of unique patterns which offer a unique situation of challenge.
Patterns are generated using a procedural concept. But this requires to know about the players physics behavior, especially jumping distances.
One way is to manually hard-code a few jump distances. A much more flexible way would be to get the jump distance - or jump radius and details like 'air time', etc. - from the physics system.
Unfortunately in Sprite Kit
there is no real point-equivalent of the force-vector unit.
So I am asking how to convert Sprite Kit
s physics into absolute point values. I need a function that I can put in for example a force vector and that outputs me the radius of the possible jump area for the player.
If I had an insight on how the Sprite Kit
physics work, for example a 'pixel per frame'-rate, but I guess that does not exist!? Something like the following:
/// Returns a rectangle describing an oval area in absolute points
func jumpRadius(withPhysicsBody body: SKPhysicsBody,
andVector vector: CGVector) -> CGRect {
// Compute area using physics body properties like mass, friction, etc.
// Return it ...
return ...
}