Thread: Flying game
View Single Post
Flying game progress...any ideas on the Alice code?
Old
1101Student
Guest
 
Status:
Posts: n/a
Arrow Flying game progress...any ideas on the Alice code? - 05-08-2011, 11:17 PM

The recommended way to solve this problem is to,

Loop forever
Turn mouse coordinates into acceleration values
Add acceleration values to ship's current speed
doTogether
move ship forward at its horizontal speed
move ship up at its vertical speed

But its still that first step (turn mouse cords into acceleration) that is causing me troubles.

OK. The 1st step is to turn the mouse coordinates into a normalized range. What I'm going to do is map the values into the range 0 to 1. So to do this for the horizontal part its going to look like controlPad.getMouseX()/controlPad.getMouseMaxX().

Now I have a value that lies between zero and 1 - it will be zero when the mouse is at the left edge of the screen and 1 when it is at the right. Thatís sort of the reverse of what I want - I want max on the left and min on the right. I could go with
1 - controlPad.getMouseX()/controlPad.getMouseMaxX().

That gives me a range 1 (left) down to 0. Its getting close to what I want (if we multiply by MAX_H_ACCEL we get values from MAX_H_ACCEL on the left edge - which is correct down to zero on the right edge - which is wrong, should be -MAX_H_ACCEL). The final step (before the multiplication by MAX_H_ACCEL) is to do another simply step to shift that 1 to 0 range to the 1 to -1 range (you can do this by multiplying then adding an offset).

Can I get some help on the Alice code?
   
Reply With Quote