This is a retro arcade style racer in the vein of Pol Position. Race against a CPU player on 4 different tracks!
- Day to Night cycle
- Personal scores saved locally
- Competitive AI
- 4 unique tracks
Key(s) | Action |
---|---|
Left/Right Arrows | Turn Left or Right |
Z/X | Accelerate and Break respectively |
The inspiration behind this project was to build something that worked like a retro game engine. To me, this means tile based or pixel rasterization; I chose the ladder. Unfortunately, calculating each pixel individually has some serious performance drawbacks, especially in an interpreted language like JS. To overcome these performance limitations I did 3 things:
- Extracted the pixel data as a one-dimensional array to prevent rendering to canvas more than once a frame
- Utilized a web worker to calculate pixel data for half of the screen
- Precalculated Math heavy pixel data
The result is an engine that runs at least 10 times faster than it would without utilizing these performance improvements. The rendering resolution could be set much higher, but I opted for a very low resolution of just 160x100, both for the retro pixelated aesthetic as well as ensuring decent performance on older smartphones. In addition, I render the cars, signs and the traffic light as bitmap images rendered on top of the rasterized image to save on performance and code complexity.
This game engine is based off OneLoneCoders command prompt game "Console Racer", which was originally written in C++.