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.

Fool’s Mate Friday?

Fool’s Mate Friday is going to take a little detour, as I work on learning a new programming language.

If you have followed my blog at all, you will notice that I’ve made a bit of a shift away from Android. When I was working with Android, I was heavily invested in Java programming, both for games and app, as well as making custom ROM’s. I’ve come to realize though, that while Java is cross platform, it is a bit of a niche these days.

Java is used by Android, but rarely used by other computer operating systems. True, it CAN be run on just about any OS, but usually ISN’T. Most browsers have dropped Java applet support, and most OS’s don’t include Java support without installing some form of JRE (Java Runtime Environment).

As I’ve switched (at least temporarily) from Android to Ubuntu Touch (UBPorts), I’ve seen a real need for more robust apps for that platform. Unfortunately, UT doesn’t support Java natively, and that left me out in the dark.

But, God gave us brains, and I’m always trying to use mine to learn new things, or master things I already know. So, I’ve decided to take up a new programming language. Obviously, if you read the title, you already know that I picked C++.

It can be hard to just “learn” something new by reading a book, or looking at code. One of the things that helped me a lot when learning how to make Android games was to sign up for a class on Udemy by Rob Percival. He made the course fun and dynamic by making little creative games or applications to teach the student new concepts or ideas. With that in mind, I jumped back on Udemy and snagged a course (during the $10 site-wide sale) called “Beginning C++ Game Programming“. It focuses on teaching a complete noob how to program in C++ by creating 3 simple games.

One of the perks to this programming style is getting to see something get created from start to finish, and have a graphically playable product when I’m done. It uses the SFML library (which sounds like a dirty acronym, but really is an open source library – Simple and Fast Media Library) for handling the graphics, and it seems to be really intuitive and straightforward. It also seems to be very similar to using libGDX that I was using with Android, so that make working with it easy for me to learn.

Since Java and C++ are both object oriented languages, the concepts of each are the same, which is helping me in the learning process. Although I still try to type things the Java way, so that may take a while to get used to. Either way, I’m having fun with the course, and while I’ve only completed about 15% of the course, it has been interesting and fun.

sfml_timber_1

The course does use Microsoft Visual Studio, however, I’m just using Geany to type and compile my programs. Other than one or two little snags about include files being different from Windows and Linux, I haven’t had any trouble doing things my way. Hopefully you’ll enjoy hearing about the journey!

Linux – keep it simple.

Geany: the little IDE that could!

geany_ide.png

Recently, while working with some older equipment, I needed a lightweight java IDE to compile some java projects. I really wasn’t looking for something quite as big as eclipse or netbeans, I just wanted a simple, one stop solution that would allow me to build java programs on an older laptop.

So, I rubbed a magic lamp, and out popped Geany!

Well, more specifically, the laptop is running Debian Wheezy, and had openJDK already installed. With that alone, I could have built java programs from the command line, but it can get a little tedious. So, I looked on the repositories for an IDE that wasn’t too large.

Thus enter Geany. I first used Geany a long time ago as a text editor on #! (CrunchBang) Linux, but revisiting the program revealed that I was not using it to it’s full potential. Specifically, you can compile, build, and run various program types from within Geany. Of course, it only outsources the commands for you, so you need a java jdk in order to compile java, or a c++ compiler to compile c++. Geany just does all the command line work for you.

What Geany does accomplish for you, however, is a great user interface with templates and the ability to organize projects or view code with different filters. As you can see in the picture, I was testing out Logic Crazy’s Alpha Beta Chess program.

As well as showing you the code, it can do parenthesis highlighting, colors for different code type, and a class and method tree on the side. It really is a great program if you need a lightweight IDE. I know that I’ll be putting it to good use.

Linux – keep it simple.