Friday, May 20, 2016

A walk in the park

A walk in the park
After a long time of absence, here I am making a post again.
This time, however, it is about a game.

I have been using the Godot engine for quite some time, but rarely created anything with it. So I decided to take 3-4 days to simply finish a game, no matter how it will turn out.

Turned out to be a small 5-10min game. Mistakes were made. But a lot of reusable code was made as well, and I have realized that it was a great exercise.
I will have to create more games like these in order to gather enough experience and reusable-code.

If you are trying to create games, let me give you advice you have probably heard before. Start small. Start small, and create a lot. Make reusable code and carry it over from project to project. Use GitHub or GitGud to store your code.

In a lot of cases, it simply boils down to experience. There is a lot of Ad-hoc things when it comes to writing game code so a lot of the time, you simply will not be able to create reusable code. I struggled to accept this since I was being told, by everyone, that OOP is the only way to go. It isn't. In fact imperative style programming is down right necessary when it comes to games. Not everything can be reused. And not everything should be reused. Sometimes you just need to get something done. Such as starting music when the second level is introduced. Or placing the player back into the game scene in the rare occurrence he gets pushed out of bounds. All of these things must be placed in some kind of main routine that handles unexpected or one-time events. Objectifying everything will lead you to madness and you will not get anything done.

If there is enough interest, I might go further in detail about this. I have learned a lot from making this game.
But not really enough to make the types of games I'd like to.

So if you are a struggling game developer, don't worry, you are not alone. It surely is not a walk in the park.

Saturday, January 9, 2016

How to use Glade3, Gtk+3 and Perl 5 to create GUI Applications

First, we will need to install the required dependencies. So make sure you install the following dependencies:
  • libgtk3-perl
  • glade
You can install them via a Package manager or the console. If you are using the console, copy and paste the following into the command line:
sudo apt-get install glade libgtk3-perl -y
They say an image is worth a thousand words. So here is an image that illustrates exactly what you should do next. I'll go over the main points.

Glade and Perl

On the right is GVim and on the left is the Glade editing interface.

First, make sure you
use Gtk3 qw(-init);
To initialize Gtk. You do not need to create a window if your layout is contained within one, like mine. All you have to do is:

my $builder = Gtk3::Builder->new();
my $window_1 = $builder->get_object("window1");

Basically, you create a builder, feed it the glade project save file, then you take out the windows you want (in my case that is "window1" and "window2") and finally, you "show" the ones you want to be visible.

Also, as demonstrated in the image, you can use package syntax (e.g. Handlers::my_callback) to link the signals. This extremely useful, since you can segregate functionality into multiple packages and keep things relatively clean.

If you feel I missed a point, the example is not clear enough or there are factual errors in the article, please let me know in the comment section so that I can fix them. Thanks for reading!