Snake in C
-
15 July 2026 |
-
development, c, sdl.
I’ve wanted to play around with some graphics in programming for ages but wasn’t really sure where to start, so a friend of mine introduced me to the Simple Directmedia Layer library.
LibSDL is a great place to start as it provides a set of easy-to-understand abstractions for drawing objects to the screen. It’s also cross-platform so you don’t get tied down to any specific architecture or operating system. Although it’s written in C, there are bindings for it in many other languages.
This was exactly what I was looking for and so I decided to try implementing a simple Snake game for the fun of it. It had also been a long time since I’d written any C, so I thought I’d like to dip my toes back into lower-level programming again.
After years of working in high-level scripting languages like JS and Ruby, writing C again was actually a lot of fun, as well as a little frustrating at times. One thing I enjoyed was just attacking a different problem space to web programming. It was refreshing just to persue a different objective from the usual request-response cycle, while using a different toolset.
The game is by no-means “complete” and there are lots of little tweaks that could be done to make it more playable and smoother, but it served as a good jumping off point for getting started with libSDL.