All people is aware of microcontrollers are much more highly effective than they was once. For underneath a greenback, now you can do a complete lot greater than log information or flash an LED. However simply how far are you able to push these little chips? David Montero Crespo needed to search out out, so he determined to construct a online game that runs totally on an ESP32-S3 microcontroller with 8MB of PSRAM.
And we’re not speaking a few sport of Snake — Crespo developed a whole 3D racing sport. That is likely one of the final issues one would anticipate to work nicely on a resource-constrained system. 3D racing video games require heavy processing to generate the graphics, and this has to occur quick. If the body charge is simply too sluggish, this type of sport is about as enjoyable as watching paint dry.
The sport {hardware} (📷: David Montero Crespo)
The {hardware} itself could be very modest: a dual-core ESP32-S3 clocked at 240 MHz and a 320×240 pixel ILI9341 SPI TFT show utilizing 16-bit RGB565 colour. By fashionable PC or console requirements, that is proper subsequent to nothing. But Crespo’s sport delivers an unmistakably traditional arcade really feel, strongly harking back to Sega’s OutRun.
To make that potential, he leaned on some intelligent graphics methods quite than brute drive. The street makes use of a segment-based pseudo-3D renderer drawn back-to-front, a way standard in late-Nineteen Eighties arcade machines. Hills, curves, and roadside surroundings are procedurally generated at startup, so the sport world doesn’t depend on giant saved maps. Atmospheric fog will increase towards the horizon, serving to disguise draw distance limitations whereas additionally including realism.
The participant’s automobile is absolutely 3D. The car is an imported OBJ mesh with a whole bunch of vertices and triangles, textured utilizing scanline affine mapping — once more a deliberate compromise between visible high quality and efficiency. Six computer-controlled site visitors vehicles independently change lanes and speeds, and the physics mannequin simulates acceleration, friction, gravity on hills, and centrifugal drift by means of curves. Crashes set off a brief restoration delay, similar to an actual arcade racer.
An ESP32 improvement board runs the sport (📷: David Montero Crespo)
The sport additionally features a day-to-night lighting cycle, tunnels, buildings, lamp posts, and a round speedometer HUD displaying speeds as much as 300 km/h. The whole body is drawn right into a double buffer saved in exterior PSRAM earlier than being pushed to the show, stopping seen tearing regardless of the SPI connection’s restricted throughput.
The venture has been made publicly obtainable on GitHub, so get busy downloading it if you happen to really feel the necessity for pace.
