Coder Social home page Coder Social logo

moon-lander's Introduction

Moon Lander!

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

Design considerations

Event Loop

Runs at a set frequency

Each interval:

  1. 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
  2. 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.

End game

  • Stop the event loop
  • Remove handlers and clean up.
  • Show end screen
    • Display time spent
    • Display success/fail message

Architecture

Component tree

  • Game Engine
    • Intro screen
    • Game Controls (and instrumentation)
    • Lander Vehicle
      • Vehicle Booster
    • Planet surface
    • Success / Fail screen

Game Engine

Keyboard and other input capturing is done by the Game Engine.

Game Controls (and instrumentation)

This component first renders all the controls that match the given model of metrics to display.

Further ideas

  • 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

Questions

  • requestAnimationFrame() and smooth intervals vs. fixed intervals.

moon-lander's People

Contributors

ndorfin avatar

Watchers

 avatar

Forkers

ndorfin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.