Custom script to build my C++ games

So, I’ve completed section one of my Udemy course. There are eleven sections total. It’s a bit odd, in that the course instructor is using Microsoft Visual Studio, and I am not. Actually, I’m not even using Windows. So there are a few differences that I think are worth noting.

One of the biggest differences, is when he is done adding something, or doing something, he simply presses a debug/play button at the top, and his newfangled app launches. Now, there are several options for good Linux IDE’s to do this sort of thing, but I’m a bit of a minimalist myself, and I feel it helps me learn more as well, so I’ve been using Geany to type out and build the programs.

sfml_timber_1

Geany works great, is lightweight, has a compile and run button, and text color coding specific to whichever language you are working in. To be honest, I couldn’t be happier with the experience. At present, however, I need to link the SFML files to my compiled code to run the game. There are ways to do this in Geany, but I wrote a simple script that does everything for me instead:

#!/bin/bash

# You need libsfml installed on your system!

g++ -c Timber.cpp
g++ Timber.o -o timber-app -lsfml-graphics -lsfml-window -lsfml-system

./timber-app

echo “type ./timber-app to launch”
exit

I call it build.sh. After I’m done coding, and I’m ready to try my game, I just double click on the build.sh script, and it compiles, links, and launches my game. Pretty easy! So far, I’m working through a tree cutting game called “Timber”. You can check it out on my GitLab if you’d like. Just remember, if you download the files, you must install libsfml before running the build.sh script.

Linux – keep it simple.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s