Skip to content

Kevin215399/Sprig-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 

Repository files navigation

--------------- Hardware ------------------

This engine is designed for the hackclub sprig. It has 8 buttons, a 1.8" TFT adafruit screen with SD card, and a speaker. It is powered by two double-A batteries and controlled by a raspberry PI pico W.

--------------- Software ------------------

The engine was written entirely in C by me.

Interpreter

Custom made interpreter uses shunting yard algorithm to parse lines. It has a call stack to run functions and branch code.

Smart Renderer

The renderer uses a buffer that stores the state of the pixels on the screen and updates the screen depending on the mode:

  1. Normal This mode is used for all the editor UI. It bipasses the smart renderer and manually draws rectangles and text onto the screen, clearing only when required. Great for UI, but not for quick refresh rates.

  2. Fast but Flicker This mode clears the entire screen and redraws it every frame. Light for the CPU, but causes flickers and refresh delay

  3. On Change (default) This mode draws only the pixels that have changed between frames. It is the recomended mode as it is the quickest overall.

  4. Slow but Smooth First this mode scans for pixels that have changed, and creates a pallete using the colors on the screen. Then an algorithm takes each color and converts it into the least number of rectangles. While very smooth, it requires more CPU time making it slower than "On Change".

Collision

The collision engine first parses space into "cells" that completely cover all of the colliders of the objects. Then each cell is iterated over to check for collisions using Seperating Axis Theorem (SAT), which allows for collision detection while the objects are rotated.

Load Balancer

The Raspberry Pi Pico W has 2 cores. To maximize efficiency, tasks are assigned to the cores dynamically based on load. This ensures that neither core is idle during runtime. The primary purpose of core 0 is object manipulation, script execution, and load balancing. Core 1's primary purpose is rendering. If core 1 finishes early, it will start processing collisions, reducing idle time and allowing core 0 to catch up. The cores communicate with eachother using FIFO stacks.

Runtime Manager

All of these processes combine together to run the user programs. This flowchart shows the interaction and ordering of the processes.
FlowChart

About

This is a custom made engine for the Sprig. It is written in C.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors