Frontier is a 2D game that takes in space that serves as a tech demo for my core-js framework.
It is written in pure Javascript w/ Canvas rendering and no other frameworks.
It's fully playable at http://frontier.jgefroh.com.
This is not intended to be used in a commercial or production environment - it was just a fun hobby project I wrote.
![Screenshot 2024-04-19 at 7 07 34 PM](https://private-user-images.githubusercontent.com/1077095/324147840-74ef86c0-b3ae-4e99-8cef-3f1e0658694e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwNDY0NDksIm5iZiI6MTcyNTA0NjE0OSwicGF0aCI6Ii8xMDc3MDk1LzMyNDE0Nzg0MC03NGVmODZjMC1iM2FlLTRlOTktOGNlZi0zZjFlMDY1ODY5NGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MzBUMTkyOTA5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDhhODZlMDJkMTUwZDYzODM1OGJiZTc5NzE1OTMzNGNhZGM1NTIxOGRjMzg4MzhlZTk1YzkyNTUzZTE1MDk1MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.8Sll8YZc4OI3-232DbrNELq9xFn7VTMtia7vkk_1z0k)
![Screenshot 2024-04-19 at 7 08 14 PM](https://private-user-images.githubusercontent.com/1077095/324147842-eb8135b0-6e8b-4f0b-99ce-dd53409c4c97.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29t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w9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MzBUMTkyOTA5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTZmZDRjYzQ2ZDQ3MzNjNjJkYWNiYWYyOGE0MzUwYzNiMzU2ZTU0MjM0MGU5NjNiNGE5ZDIyNTFlZGVlMzYwNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.ZrXE5LmqNWLLQ8wFIcJGirMJmI3-SB9nk5MIRtzZyV0)
- Movement
- W - Increase thrust
- S - Decrease thrust
- A - Turn left
- D - Turn right
- Weapons
- 1 - Fire Weapon Group 1
- 2 - Fire Weapon Group 2
- 3 - Fire Weapon Group 3
- Combat
- \ - Toggle tactical mode
- Tab - Next target
- ShiftTab - Previous target
- V - View target
- T - Focus target
- Camera
- Left arrow - Move viewport left
- Right arrow - Move viewport right
- Up arrow - Move viewport up
- Down arrow - Move viewport down
-
- Zoom in
-
- Zoom out
- Misc
- I - View inventory
Install packages
npm install
Development server (127.0.0.1:9000)
npx webpack serve
Production build (assets must be moved manually into dist
folder.
NODE_ENV=production npx webpack build
Audio is merely an event that passes a message to play a specific sound starting at a specific time.
There are a variety of camera and viewport behaviors demonstrated including:
- User-controlled viewport, including zooming and panning
- "Follow mode" to center and visually track an entity
- "Focus mode" to keep two objects in view, adjusting pan and zoom as objects move.
- A secondary viewport that allows you to re-render using a different perspective and independent viewport configuration
A GUI system exists to render an arbitrary image, shape, or text at any particular canvas location, which can be requested by any system, allowing you to separate GUI components into individual systems.
- Arbitrary GUI element rendering, including images, text, and shape
- Automatic GUI click-handling, with appropriate events
- Dynamically defined and rendered table creation, great for list-based UIs
- On-hover style change behaviors
- Easy way to identify a target element and define an update to it (eg. text, position, visibility, color, etc.)
User inputs can be defined on a per-keystroke basis that translates them into particular action events other systems can subscribe to.
- Key-to-action mapping, including press, release, and hold.
- Support for modifier keys like
Shift
.
As a space game, there are a variety of systems built.
AIs work with a goal-based system that lets you define a top-level goal and have the AI (theoretically) select what tactics and actions to use to approach that goal. Action are scored based on importance, and then the steps of that action are executed in sequence to complete the action.
Collision is 2d collision system allowing for rotated rectangle collision checks. Collidable entities are defined as with a collision group, informed by an entity's association to a nation for gameplay purposes.
The physics system supports inertial-based movement.
- Sustaind acceleration of an object via application of multiple force vectors
- Travel path prediction based on changes to acceleration, bearing, etc.
Weapons are in the firing system. Different weapons have different stats, but they are all basic, continuous fire with a firing cooldown between shots.
Relationships are defined in terms of Nations and Factions. These then inform whether they can be targeted by other nations, as well as the collision system.