Weapons, in a lot of games they are very important. And although they might seem quite simple (you just push a button and it works), there is quite a bit more to them. To illustrate this, I’ll give a detailed explanation of how I programmed the shotgun in my arcade game.

When I started building my arcade cabinet I didn’t have any wires, but that soon changed as I added the buttons to it, which meant 3 outgoing wires from the breadboard (2 to the button, 1 to the pi), and 2 for the voltage supply to the buttons. After that came the sound system, which used even more wires, then I added the LED-strip, and the central power supply and…, Well, you get the point. I kept on adding those wires without any rhyme or reason and it all just became one big jumbled mess.

The game that will run on my cabinet is coming along nicely. The game is based on Super Crate Box, and follows the original closely. Four weapons are implemented right now (pistols, dual pistols, machine gun, grenade launcher), as well as 2 enemies and 2 levels. Here is some footage of the game that will be running, recorded on my laptop.

Last post, I discussed using the APA102 LED strip with the raspberry pi. You can create very cool effects with it, but doing so requires quite a bit of code, so I created a library with some basic utility functions and animations for the APA102 LED driver, and I’ll be expanding it in the future as I need more animations for my arcade cabinet. In this post I’ll cover the basics of this library.

LED-strips are awesome things, and they aren’t hard to use if you know how to use them, but only íf you know how to use them. While there may be many guides to connecting it to an Arduino, guides on using it with the Raspberry Pi are quite sparse, and not everything might be as straightforward as it seems. We’ll be using C++ and the wiringPi library to drive an APA102 led strip.

Previously we saw how to get sound to work on the Raspberry Pi with SDL2 and the SDL2_mixer library. Although this works for simple situations, you’d like your game to have a more sophisticated sound system as we often have many different sound effects playing at once, as well as background music. We could load and play these every time we need them, but when things get busy on the screen this might lead to quite the performace drop.

I love Go. I love it’s simplicity, it’s static typing, it’s speed, it’s networking capabilities and how you can get libraries from GitHub with just one command without any further setup. But Go alone is often not enough, and you need something more, and that is where Gorilla Mux comes into place. The nature of Go often means you’re writing quite a bit more code than with other languages, but you get simplicity in return for that. To prevent some code from becoming way too big, I’ve been searching for an easy way of writing middleware for Gorilla, but most of the Google results involved implementing http.Handler or a different interface, which in my opinion is way too unwieldy when you can also use a very powerful feature of the Go programming language: the closure.

Last time we saw how to connect an amplifier and speakers to the Raspberry, now we’ll look at playing some sound with the SDL2_mixer library, but first we’ll have to enable sound. As I said in my previous post, sound on the Raspberry Pi is not as straightforward as you’d like it to be, so there are quite some steps involved to get it working properly.

Every time you make something, you run into problems in places you least expect them, and my arcade machine is, sadly, no exception. I expected the graphics without X11 and the performance of the game to be huge problems, but it all just worked. Something I didn’t expect to be problematic however, was the sound, but oh, have I been wrong. So to save you the troubles of finding all this out yourself, this is a guide to get SDL2_mixer running on your pi.

Although C++ is quite a common language in professional game development, it is often considered to be quite the overkill for writing a simple 2D game like the one I’m making for my arcade cabinet, but still I chose C++. To be honest, it wasn’t my first choice, as I first used Python with Pygame. It worked fine on my laptop, but when I tried to draw even one single image on my Raspberry Pi, the framerate dropped to a staggering 7 FPS.

Ever since the Raspberry Pi came out, I’ve been wanting to create some kind of game machine with it, but never got to it. So, just before christmas, my uncle gave me a spare Rasbperry Pi he had, and I decided to make something cool with it, and so the idea of making an arcade cabinet was born. I’m not the greatest sprite artist, but I was lucky, as a while ago, I bought the Humble YoYo-bundle, which contained the pro version of GameMaker:Studio, and the source code to a couple of games. Game Maker was actually the program that got me into programming, a lot of years ago (back then it was on version 7 and didn’t even support sprites with alpha channels)