In this example, I will be using the 2D game engine Scratch (free to use) to programme the character but don't worry is you use a different game engine as the principles are basically the same.
Firstly you will need to create to create 2 variables, 1 for the characters speed on the x-axis and 1 for the characters speed on the y-axis. You can call them anything you want but ideally use something obvious such as "x speed" and "y speed". These variables can then be used in the programming code to create a realistic sense of gravity.
All the snippets of code below are explained in their captions and how they relate to the overall flying process.
This code toggles through the costumes when the up arrow is pressed |
This code uses the x speed variable to speed/slow the character when the left or right arrows are pressed |
And finally the gravity creating code...
This code creates the illusion of gravity at the outset and then relates to it as the up arrow is pressed, representing the jet-pack being powered |
Why not try it yourself, you can remix and edit the project here.