Linux Format

Generate and then solve mazes with C

Credit: https://github.com/joewing

You can find many mazegeneration programs in C on the web. Many of those output the mazes as texts. In this example, we’re going to set up Visual Studio Code (aka VS Code) and write a Cprogram that uses the SDL2 library to draw the maze and then solve it.

For this tutorial, the program was developed on a Raspberry Pi 4B, but a 3B would work equally as well. We’ll install this software:

SDL2 library

Visual Studio Code and extension

The Clang compiler and linker

The SDL2 (Simple Direct Media) library isn’t installed by default on a Pi. To compile against SDL2, we need the development versions, which include header files for C and libraries to link against. To see what’s available, run this command in a terminal:

Of the six libraries shown, we only need libsdl2-dev. Before you

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Ultimate Desktop Upgrade!
LXF316 will be on sale Tuesday 28th May 2024 Word processors that can help craft that novel you’ve always been talking about and organise large projects. Revive the old roleplaying system for a digital age as we recreate our own play-by-mail gaming
Linux Format4 min read
Linux
The #1 open source mag Future Publishing Limited, Quay House, The Ambury, Bath, BA1 1UA Email contact@linuxformat.com EDITORIAL Editor-in-chief Neil Mohr Art editor Fraser McDermott Production editor Katharine Davies Group editor-in-chief Graham Bar
Linux Format2 min read
Platform Support And Editions
Kali has a huge variety of install options, and these include images for ARM-based computers and pre-made virtual K machine images for most of the popular virtualisers. It’s even possible to install a version of Kali on to an Android-powered device.

Related Books & Audiobooks