- Published on
Using only text editor and terminal to program in C and SDL
- Authors

- Name
- Fred Luartes
Previously, I was doing SDL2 Tutorials from Parallel Realities. It allowed me to create simple games with just the terminal, text editor, C and SDL2. I only learned C programming during university but that was ages ago, so I had to relearn C. I'm still not yet fully familiar but I think I can create simple programs and games using C.
For SDL2, I was planning to learn raylib first but I saw the tutorials by Parallel Realities and I liked what I saw. Text tutorials with full code. I've been meaning to learn via YouTube videos but I think learning from text tutorials and code is much better for programmers. That's why I went with the SDL2 tutorials.
Using C
When I learned C programming way back when the internet is limited to rich people with dial-up or fiber connections, my coding environment is mostly Turbo C, then Dev C++ (I know). So I was stumped on how to setup my machines for C programming. I have both Windows and Linux for my machines and I want to code from both machines. So I setup my Windows machine for both MSVC and minGW (w64devkit). For Linux, I just installed build-essential and made sure gcc and gdb are both installed. For macOS, just install XCode Command Line tools. It comes with clang and lldb.
CMake
For cross-platform development with Windows, macOS, and Linux, I used CMake. It allows to detect your build environment and use that accordingly. I just edited my CMakeLists.txt and CMakePresets.json files to configure the compilers of all 3 OSes.
Text Editors
For my text editor, I had the option to use Visual Studio with Windows and KDevelop with Linux. But, I opted out of the IDE way and used Sublime Text. I sometimes use Visual Studio Code if I want my terminal and text editor in one program. Mostly Sublime Text and the terminal available with the OS. Debugging is a pain with C but I managed to run my programs by using gdb on Windows/Linux, and lldb on macOS.
Terminal
For the build step, aside from configuring CMakeLists.txt and CMakePresets.json files, I used a build.bat file on Windows, and build.sh file on Linux/Unix. I learned this from Casey Muratori's Handmade Hero streams (shoutout). So I put my gcc game.c -o game and other commands to build and run the game in my build script. Here's a sample of my build script that I ran on one of my SDL projects:
cmake --preset unix-default
cmake --build --preset unix-default
./build/my-shmup-01
SDL for gamedev
So why SDL? Why not Unity/Unreal or why not XNA/Monogame or something else? I wanted to code in C and I wanted to use a cross-platform library and practice some coding chops while learning gamedev. My other choices were libGDX (Java), LWJGL (Java/OpenGL), and Godot (game engine). I alternated between SDL, libGDX, and Godot to get a feel for different gamedev environments.
Closing
I like gamedev. I feel that I'm closer to getting good at programming if I focused on creating simple games using code. But, I'm also working as a backend developer and there are times that my day job consumes my hobby coding time. For now I'm pausing gamedev to focus on backend development. I also wanted to get deep on my backend engineering knowledge. I started to code games to improve my coding skill in the first place, so me coming back to backend dev isn't much of a surprise. I'll write again next time if I continued gamedev in my spare time or if I coded other programs more related to backend development.