SyntaxBoom
Languages & Coding => Other Languages => Topic started by: Jackdaw on Aug 26, 2025, 06:14 PM
A long with the BlitzMax and Cerberus-X version of this example based from a chapter from the book 'Game Programming Patterns (https://gameprogrammingpatterns.com/)'. I've also created a Free Pascal version using SDL2 and the SDL-for-PASCAL bindings, which are listed here (https://www.libsdl.org/languages-2.0.php).
To compile it you will have to download the Lazarus IDE (https://www.lazarus-ide.org/) and SDL2 (https://www.libsdl.org/). You can use the tool fpcupdeluxe (https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases) to build Lazarus IDE from scratch. If using fpcupdeluxe, it's recommended that you build the FIXES-4.0 branch.
Demo video
(https://www.dropbox.com/scl/fi/9y6ra4650d2r3r0k2q180/example_001.webp?rlkey=gd5p2so7yavbnneh8t794ry87&st=nm4jc9lr&raw=1)
You will need to download the warpsara-nohelmet-anim-sheet-alpha_1.png (https://opengameart.org/sites/default/files/warpsara-nohelmet-anim-sheet-alpha_1.png) file from https://opengameart.org/content/space-sara (https://opengameart.org/content/space-sara) and place it in a directory called media, and rename it to warpsara-nohelmet-anim-sheet-alpha.png.
If you want to a few simple tutorial on using SDL with PASCAL, then you can find them here (https://www.freepascal-meets-sdl.net/).
As this is a multi-platform demo, supporting Windows, Linux and macOS. It will not fit into a single post, so you can download the files from here (https://www.dropbox.com/scl/fi/ycibmhlv23hpfyyod49uy/example_sdl2_001.zip?rlkey=aag6kii6sxtlxy4f9im3tequi&st=wb91b4zf&dl=0).
NOTES:
The SDL2 libraries required for Windows and macOS are included, though on macOS you may be better off building your own. On Linux, you can use the SDL2 repositories from your distribution.
On macOS you will also need xcode 16.2 and the command line developer tools installed. If the computer is Apple silicon, then before you extract the zip file. It will need to have the quarantine flag removed by opening a command terminal and executing: xattr -c example_sd2_001.zip.
You can build the dylibs yourself. You will need cmake installed and the SDL2 and SDL2_image. Plus you will need to be familiar with install_name_tool to rename the dylibs @rpath.
Tips for building the libraries on an Apple Mac with CMake GUI, or the command line.
Make sure that the following CMake variables are set.
For SDL2.dylib
CMAKE_BUILD_TYPE: Release
CMAKE_INSTALL_ PREFIX: Set this to the root directory for all the SDL2 libraries to be built. e.g. ~/developer/libraries/SDL2
CMAKE_OSX_ARCHITECTURES: arm64;x86_64
CMAKE_OSX_DEPLOYMENT_TARGET: 11.0.0
For SDL2_image.dylib
All of the above, plus the following.
SDL2_DIR: <path_set_in CMAKE_INSTALL_ PREFIX>/lib/cmake/SDL2
SDL2_MAIN_LIBRARY: <path_set_in CMAKE_INSTALL_ PREFIX>/lib/libSDL2main.a
Thanks for that. Very interesting Demo. Getting "Game Programming Patterns" ;)