I'm fascinated by the prospect of a little lander working its way to the surface of an alien world.
This project is a Web-based (and overly) simple simulation of a craft trying to successfully softly land on the surface of a moon or planet. I wanted to use this project as a vehicle for learning more about Web Components, ES Modules, Event-based communication, and using PWA technologies.
Check out the work in progress at ndorfin.github.io/moon-lander
Runs at a set frequency
Each interval:
-
Simple (1-dimensional)
Ignore rotation and X-axis movement. The lander is flying straight down with no lateral movement.
- Get current Y position
- Get current speed
- Get current booster amount
- Apply gravity
- Take speed and divide by interval to get new distance
- Set new current Y position
-
More complex (2-dimensional)
Now mix in the lander's rotation, current vector. The user needs to thrust against their vector, while still maintaining the desired altitude.
- Get current X and Y position
- Get current speed and direction (vector)
- Apply gravity to vector
- If Lander is out of bounds, end the game.
- If Lander is still in bounds, continue.
- Stop the event loop
- Remove handlers and clean up.
- Show end screen
- Display time spent
- Display success/fail message
- Game Engine
- Intro screen
- Game Controls (and instrumentation)
- Lander Vehicle
- Vehicle Booster
- Planet surface
- Success / Fail screen
Keyboard and other input capturing is done by the Game Engine.
This component first renders all the controls that match the given model of metrics to display.
- The user's phone x-axis motion to control lander rotation
- Thumb press on the booster button to add thrust
- Deploy landing legs when near landing, or the user must deploy them at the right speed and altitude.
- Navigate craters, hills, and boulders
- Massive lateral speed
- Rapid orbits can affect day/night cycling
- The higher the altitude, the more round the terrain!
- Use a parallax or exponentially scaled background, so that the terrain rushes up to the lander as it approaches.
- Use a fixed fuel-tank, too much thrusting = running out of fuel quicker.
- Explore multiple planets, with different environments:
- Gravity changes
- Atmospheres / Wind
- Landing in liquids
- Dealing with foreign objects / fauna
requestAnimationFrame()
and smooth intervals vs. fixed intervals.