crisp game lib portable for funkey
Seperate repository for funkey-s / RG-Nano as i had to modify games and library to account for a bug that only occurs on those devices. The trig functions need to have normalized angles (between 0 & 2 x PI) or it will fail over time and draw squares instead of circles and so. And i could not easily fit in those changes in the original authors repository where i plan to PR the SDL1 & SDL2 port against
original repo is here https://github.com/abagames/crisp-game-lib-portable/ this version is based on my SDL1 port with adaptations for the funkey and rgnano Below you can find the original Readme

The library starts up on the menu where you choose a game and play it, at the beginning of each game it will tell you the controls / behaviour


Minimal C-lang library for creating classic arcade-like mini-games running on devices and browsers. Re-implemented version of crisp-game-lib for smaller devices. You can play sample games in your browser.



Copy game_Template.c to game[your game name].c
Comment out other games in menuGameList.c and add void addGame[your game name](); and addGame[your game name]()
...(snip)...
void addGameReflector();
void addGame[your game name]();
void addGames() {
/*addGameThunder();
...(snip)...
addGameReflector();*/
addGame[your game name]();
}
Write your own game in game[your game name].c and rename void addGame_Template() { to void addGame[your game name]() {
Build for browser and debug
Once the game is complete, revert other games that were commented out in menuGameList.c and build it for other devices
Install LovyanGFX library
Create cglp[target device]/ directory (e.g. cglpM5StickCPlus/)
Copy cglp[target device].ino, ./src/lib/* and ./src/games/* files to the directory
Verify and upload cglp[target device].ino with Arduino IDE
Copy ./src/cglpPlaydate directory
Create cglpPlaydate/build directory
Move to cglpPlaydate/build directory and cmake ..
Open crisp-game-lib-portable.sln with Visual Studio
Build the solution (see Building for the Simulator using Visual Studio)
Note: Some features are limited due to device resource limitations.
Install Emscripten
Run dev npm script to start the dev server and watch js files
Run dev_c npm script to watch c files and build wasm files
The source codes for library and games are written device-independent. Besides, you need to implement device-dependent code for the following functions:
Device initialization function (e.g. setup() in Arduino) that calls initGame()
Frame update function (e.g. loop() in Arduino) that calls setButtonState() and updateFrame()
setButtonState()Drawing and audio processing functions that are defined in machineDependent.h
md_getAudioTime() function should return the audio timer value in secondsmd_playTone(float freq, float duration, float when) function should play a tone with freq frequency, duration length (in seconds) and staring from when seconds on the audio timermd_drawCharacter(unsigned char grid[CHARACTER_HEIGHT][CHARACTER_WIDTH][3], float x, float y, int hash) function should draw the pixel art defined by grid[y][x][r, g, b] at position (x, y). Since hash will be the same for the same pixel art, you can cache pixel art images using hash as an index and avoid redrawing the same imageSample device-dependent codes are cglpM5StickCPlus.ino and cglpPyBadge.ino.
You can use an AI chatbot to port game source code for crisp-game-lib to crisp-game-lib-portable. By providing the prompt and set of files to the chatbot, you can obtain the code ported to the C language. I have tried this using Claude 3 Opus, but it is expected to work to some extent with other LLMs as well. The ported code is not perfect, so it needs to be manually checked and corrected.