Entrypoint
The main entry point is ./src/app/main.ts which initiates screens, and starts the initial screen
./src/app/screens/planetSurface.ts.
What is a Screen?
Everything in the engine is organized around the concept of a screen which handles input and state management for a given renderer (ie: what you currently see on the screen).
- init: A function called during initiation of the class which sets up the ECS for a given screen
- onEnter: A function called every time you return to the screen from another screen
- onExit: A function called every time to leave the screen for another screen
- keyboard: A function for all your keyboard handling
- mouseClick: A function for processing all mouse click events
- mouseMove: A function for processing all mouse move events
- logicLoop: A function for processing all your game's logic
- renderLoop: A function for processing all your game's rendering
Main Game Loop
- Execute any shared global logic (ie: think something like the passage of time which occurs regardless of the current screen)
- Execute current screen logic
- Clear screen
- Execute current game screen renderLoop
- Go to 1
Run dependencies:
npm install
To run:
npm run start
How to Play
You can use the arrow keys to walk around.
Use 1 or 2 to switch between drill and wrench. Drill can break rocks on planet surface.
Press space to open doors.
Additional Code Credit
I ported the Javascript ray caster from https://github.com/almushel/raycast-demo to Typescript and cleaned up the code to make it more reusable. The ported code is found in ./src/lib/rendering/rayCaster