My game engine in Go

I haven’t posted in a while, but I’m promise it’s not because I’m lazy! I’ve been working on a fun project this past month which I’m going to share here. It’s a game engine written in Go. I also used SDL2 for many internal operations.

The history

The best way to really learn something is to explain the subject to someone or to put what you learned in practice. My original idea on learning Go was to create a game editor for a JS framework I had used in the past. That was a good idea, but it wasn’t as fun as creating my own game with Go! I looked for game engines written in Go so I could start playing around. The problem here is that there are no stable engines written in Go yet. I could have written a game without an engine and it would have been completely fine, but once I had the idea to build a game engine I just had to do it! Challenge accepted.

I read a bunch of tutorials about game engines so I could get a better idea on what kind of architecture was best suited. I ended up finding a gem on gamasutra. For example, Michael Kissner wrote a whole series on writing a game engine on gamasutra. I ended up finding on gamasutra and other places like that the best to architect a game engine would be writing one that used the Entity Component System pattern. I really liked this thought because it tries to avoid the spaghetti code.

I also bought a book about game design patterns by Robert Nystrom. It was good read. He has the book available for free if you want to check it out on his website. If you like the book or read the whole thing you should consider buying it. I feel like it is one of those books are worth having in your library.

I originally thought about naming the project blue hawk, but when I googled I realized it was too common. Then I thought green bee. That name was also picked… The reason I’m picking those animals is because 1) they are fast; 2) they fly which is awesome. I’m from Brazil and we have many awesome animals. One animal that I really think is gorgeous is the macaw. I googled and nothing other than macaws showed up. Great! I named the project Macaw! I’m still working on the logo, but if you have never seen a macaw you can see from the extracted image from wikipedia down below.


The project

The nice thing about game engines is that there are always things to be done (and fixed). Right now people can use it to write a very simple game. It can draw images (animated or not), geometric shapes (rectangles), perform simple physics, contains collision detection, detect keyboard input, and it communicates between systems. On my computer it draws at 400fps+ in this veeery simple pong game. You can check out the source code and see what I’m talking about.


The nice thing about this game engine is that it is very simple to start writing your own game. Of course I know how the internal works and it helped a lot, but it took me less than 30 min to write the whole pong game! It was awesome! Simple is good. I’m sure I did many things that were not optimal, but you gotta start from somewhere and without code reviews, things might scape from your eyes.

This post is short. It is more like an announcement. I’m happy with the result accomplished and I’m hoping to write more about this topic or related ones in the future!

Any problems you can comment down below, go to freenode on channel ##macaw, or open an issue on the github repository.

Leave a Reply

Your email address will not be published. Required fields are marked *