There's a dolby contest and it has inspired me to work more on Musical Trade Route. Short history of the game - it was my LD30 something entry for Connected Worlds. I had it on android for a while, but a bug caused the screen to blank out. GPlay doesn't allow reverting back to a previous version if the newer one covers more devices. I started picking up collaborations/contracts and never got back to working on it.

So I am thinking about incorporating my 3D tests and making the game into a flight simulator. merrak could probably do this instantly

Here's what I am thinking. The vector magnitude is calculated as:

P = sqrt ( Px^2 + Py^2 + Pz^2 )

I know my magnitude will be 1 because I would like the player to move 1 step in any direction. Now the difficult part is back calculating x, y and z.

I know what phi1 would be because the angle1 is determined by the player - say using the left and right arrow keys to subtract or add 1 degree. If we tilt the 3D space by 90 degrees, having the y axis pointing up, phi2 would then be the angle2 also determined by the player - for example using the up and down arrow keys. Finally, the theta/gamma angle would be 90 - phi2 since the distance from the z axis is opposite angle from the rise off of the x, y plane.

Just remember, the left-right angle is angle1 (phi1).

The up-down angle is angle2 (phi2).

cos phi1 = Px / sqrt ( Px^2 + Py^2 ) = cos angle1

cos phi2 = Pz / sqrt ( Pz^2 + Px^2 ) = cos angle2

cos theta = Pz / P

since P = 1, we can write this as:

Pz = cos ( 90 - angle2 )

Hurray, we found the z-axis coordinates. Let's plug it back in:

cos angle2 = cos ( 90 - angle2 ) / sqrt ( ( cos ( 90 - angle2 ) ) ^2 + Px^2 )

sqrt ( ( cos ( 90 - angle2 ) ) ^2 + Px^2 ) = ( cos ( 90 - angle2 ) ) / ( cos angle2 )

cos ( 90 - angle2 ) ) ^2 + Px^2 = ( cos ( 90 - angle2 ) ) / ( cos angle2 ) ^2

Px^2 = ( ( cos ( 90 - angle2 ) ) / ( cos angle2 ) ^2 ) - ( cos ( 90 - angle2 ) ) ^2 )

Px = sqrt ( ( ( cos ( 90 - angle2 ) ) / ( cos angle2 ) ^2 ) - ( cos ( 90 - angle2 ) ) ^2 ) )

Hurray???!??!?!? we found Px. Let's simplify it and put Pz back into it - since we already have it calculated.

Px = sqrt ( ( Pz / ( cos angle2 ) ^2 ) - Pz^2 )

Now let's calculate Py since we have Px.

cos angle1 = Px / sqrt ( Px^2 + Py^2 )

sqrt ( Px^2 + Py^2 ) = Px / cos angle1

Px^2 + Py^2 = ( Px / cos angle1 ) ^2

Py^2 = ( Px / cos angle1 ) ^2 - Px^2

Py = sqrt ( ( Px / cos angle1 ) ^2 - Px^2 )

Phew, ok so now we can determine movement in the 3D space. Next post, I will go into the pitch and yaw calculations, which are quite a bit easier.

Anybody who thinks that Stencyl should automatically have 3D needs to think about these calculations