Make a rocket simulation for Mini Micro, and then test your piloting skills — how high can you go, and still land safely? For the code to this simulation, check out https://beanzmag.com/mini-micro-rocket-sim-game. You’ll need Mini Micro, a free program you can download from https://miniscript.org/
Launch the MiniMicro software and then type edit and press Return or Enter to open the code editor. Carefully type in Listing 1. This program is a simple physics simulator, and in physics, it’s always important to keep track of your units — whether your values are in meters, feet, or furlongs per fortnight.
So the program includes a lot of comments about units; for example, the fuelMass in line 1 is measured in kilograms (kg). Once you’ve typed in this code, click the Run button (or close the editor and type Run). You should see a rocket sitting on the ground, with the message “Press spacebar to launch!”. Tap the spacebar to fire your engine or hold it down for a longer burn. Your rocket will quickly accelerate away from the ground. It will continue to go up for a long time after you release the spacebar, just like a ball thrown into the air. But also like a ball, gravity will eventually make it fall, faster and faster.
If you’ve saved enough fuel, and time it just right, you can land your rocket safely where it started. If the speed indicator is a higher number than -10, it will be considered a safe landing. If the rocket falls too quickly… Well, better luck next time!
The core part of this physics simulation is in lines 42, 46, and 50-51. The acceleration (a) is calculated from the engine thrust, divided by the total mass of the rocket if you are firing the engines. The rocket is also affected by gravity, whether the engines are firing or not. Then we take this acceleration and multiply it by the time step (dt) to update the ship velocity (v) in line 50, which tells us how fast the ship is moving.
Finally, we apply the velocity to move the ship’s position (altitude) in line 51. That’s pretty much it — everything else is for updating the display.
If you want to tweak the simulation, try changing the values of the variables defined in lines 1-5. Both fuelMass and burnRate start at 100 – this means that, if you held the spacebar for just 1 second, you’d use all your fuel. Try raising fuelMass or lowering burnRate to make the rocket’s fuel last longer.
You could also change the rocket’s mass (dryMass) or the thruster strength (Isp) to make your thrusters more impactful. Less rocket weight and more thrust, for example, will make the rocket go faster and higher.
The display includes keeping track of your maximum altitude and speed. So make a game of it: how high can you get your “max altitude” and then land without crashing? My record is 90 meters. Can you do better?