2d Rocket Landing Sim

Introduction: 2d Rocket Landing Sim

You will need to make a backdrop, draw rockets, and an indicator to begin (of course you'll need an internet connection to use scratch) if you just want to play the simulation/ game, click here, or go to https://scratch.mit.edu/projects/432509470/

Step 1: Physics Engine

Rocket simulators cannot exist without physics simulation, and so you will need all of the variables as follows:

  1. Vh or VelocityHorizontal as shown in the example
  2. Vv or VelocityVertical as shown
  3. EnginePower, to indicate thrust generated by the rocket
  4. EngineAngle, for steering by gimbals
  5. total velocity, for indicator and touchdown conditions
  6. exploded, for reasons we will get into in the next step

After creating the variables, go to "motion" tab, and put down the blocks [change x by()] and [change y by()]

Place your Vv in the [change y by()] and Vh in the [change x by()] and put the whole thing in a loop.

To add gravity, just add a [change Vh by (-1)] to the loop.

To add some semblance of drag, add the following block to the loop:

[set Vh to (0.99*Vh)]

[set Vv to (0.999*Vv)]

Oh boy now it's time for the "engines"

Since this will be controlled by gimbals and direction pointing, we need something that will allow the rocket to travel in the direction it is pointing at. as the engine rotation will have some effect on the direction of thrust, the engine angle will contribute to the total thrust direction slightly so add that, and ask the computer to perform a bit of trigonometry and voila, the engine output is done.

Step 2: Game Mechanics

As a "game" this must have controls, a win condition, and some way for the game to end.

For the controls, all that needs to be done is to connect keys to some of the variables we set earlier

Assign two keys to the engine direction and one to enginepower, as shown above

For the win condition, use one specific color or y level to be the ground, and here I put a large portion of the map as unlandable area. as you see here, there is use of the "exploded" variable, it prevents the costume setter from switching back to an unexploded from when explosion is triggered. the parameters are being more or less perfectly upright, and having a very low velocity. now after the landing, the rocket is placed at a certain y level to prevent floating rocket, and everything is set to 0.

For starting conditions, set it to a reasonable angle at a reasonable place, or make it random, it's your choice

Step 3: Indicators

and finally just to make it playable for more people, i added indicators, and you should too, visual indicators are easier to spot, and the code is displayed above.

Block Code Contest

Participated in the
Block Code Contest

Be the First to Share

    Recommendations

    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge
    • Stick It Challenge

      Stick It Challenge
    • Electronics Contest

      Electronics Contest

    Comments