An attempt to reimplement the Playdate Handheld C Api in SDL2
i’ve used this to create windows (and linux) binaries to for my playdate game’s from unaltered source code for the playdate. I attempted to reimplement the Playdate API headers in SDL2. It’s probably done in a very bad way but it does seem to work for my games and a tetris game i tested from someone else on github. A Lot is still not implemented and probably never will. A basic sprite class has been implemented as well as collision detection using bump.hpp (https://github.com/Polynominal/bump.hpp), The C Sprite example is working but a lot of the other games i tried do not work correctly. Audio is also only basic implementations for File and SamplePlayer, File routines have been implemented as well as well as some of the display and graphics functions. There might still be some issues with some of the graphics functions compared to playdate but for my game’s i’m happy with it
if you place a “Source1” or “Source2”, … folder inside the “Source” folder you can swap source folders by press F3 when the game is running. inside these additional source folders, you replicate the same folder structure as in the original Source folder but you can use different files for example colorized graphics. in order for this to work correctly you need to make sure that you implemented the kEventTerminate event and free your game’s assets / alloced memory when it’s called, otherwise you’ll have memory leaks. It works by first calling kEventTerminate and then kEventInit again so you need to make sure that you also reset global variables inside kEventInit. you can also provide a colors.ini file to determine the colors used for black and white. You need to make sure that the clear color lies between black and white. For an example on this i suggest to check some of my playdate game repo’s.