Practice Platformer in Gamemaker Studio 2 – Part 3 (Now with sound!)

Let’s see, what’s new this time?

  • There are now sound effects for almost everything (which have a whole story behind them that I’ll get to in a minute)
  • Created a new and improved background layer that I think looks a lot better
  • The game autosaves each time you move to a new room and the continue feature on the menu screen actually works now
  • Player character can now die
  • Added signs with readable text bubbles
  • Added larger enemy types with more health

I believe that’s everything since last time. Had a bit of a scare when adding the sound effects, but I suppose it taught me a few lessons as well. After adding some 8-bit-ish sound effects that were created using a program called BFXR, testing revealed that the game was now completely freezing up during combat. Since I hadn’t had this problem until adding the sounds I assumed that it must be related to the sounds, possibly some kind of conflict when multiple sounds played at once since that’s when the freeze seemed to be occurring. However, after disabling each sound effect one by one, and then just plain replacing them all with differently created ones, it turned out that the sound seemed to have no effect at all on the issue.

Next I made a backup copy of what I’d done so far (which I should have already been doing – Lesson #1) and started rolling back the last few sets of changes I’d made step by step, thinking that one of these recent changes must have been the culprit. Nope, that also did nothing.

After more testing to attempt to narrow it down, I found that the freeze only happened when killing an enemy while your character was jumping, so I started looking into the code related to each of these actions for both the player and the enemy. It only then occurred to me that Gamemaker Studio 2 has a debug mode, one that works very similarly the one I’m already familiar with in Visual Studio. I reeeeeeeally should have thought of that sooner. Embarrassing Lesson #2. Anyway, this was able to show me the exact line of code that was running each time the freeze occurred. It was a while loop that  must have been getting stuck in an infinite loop, but why was it doing this? It still wasn’t exactly clear what was causing this loop to get stuck.

Luckily, I guess I learned something from all those Computer Science classes after all and I was able to figure out exactly what it was triggering the freezes. Turns out it was all caused by one tiny little change I had made to the enemy collision box when creating the larger enemies. This had to be adjusted a little because thanks to their increased size they would just spawn stuck in the floor. Apparently I over-adjusted it by just the tiniest bit and so now whenever you killed and enemy and it switched into its death animation, which involves its corpse flying back in the opposite direction it was shot from, the corpses were now being told by the code to teleport into the floor, which sent the collision detection code crazy and crashed the game. Fun times.

These collision boxes have been the cause of most problems I’ve had with this game and I guess I still don’t know how to utilize them as perfectly as I’d like to, but I think I’m finally starting to get the hang of tweaking them properly so that sprites can stand/fall right where I want them to without getting stuck in the environment.

Aaaaanyway…that’s about it for this check in. 15 parts of this tutorial down, 17 more to go. More to come in a few weeks again, most likely.

Amazingly, still working on this game:

Sooooo…surprisingly (to me anyway) I haven’t procrastinated to the point of abandonment on this thing like I have with every other overly ambitious video game idea I’ve had over the last several years. I haven’t gotten a huge amount done on it this month since I just had final finals and graduation to deal with over the last few weeks, so there hasn’t been a lot of time for it, but I’d say there has still been a decent bit of progress anyway.

One thing I decided to take care of before getting too much further into this lengthy tutorial process was to create all original assets for this thing. The previous background, walls/floors, and bullet sprites were all placeholders that I just found on Google or just ripped right out of Contra. Everything in there is now hand drawn with the single exception of the gun, which is a Photoshop-edited version of the pulse rifle from Aliens. I like how it looks, but it doesn’t really match the rest of the art style does it? Maybe I’ll change it later, we’ll see.

Other additions include an animated menu screen with working New Game and Quit options (title to come later), a camera that follows the character, room transitions (though there are only two rooms right now), a shaking effect to firing the gun (which I’m not sure if I actually like. maybe it’ll feel better once there are sounds or I might just need to tone down the level of shaking a bit, not sure), parallax scrolling background layers, and controller support.

Something I’m not super thrilled with, but am kind of stuck with as part of this tutorial process is the 360 degree aiming. I feel like eight directional firing would be better and easier to control. I don’t think a game like this really needs to control like a dual stick shooter, especially one where you still have to manually press a fire button on top of aiming, but I don’t want to deviate too far from the tutorial model here and end up painting myself into a corner again. Also the character used in the tutorial has little stick figure limbs so the effect of the gun spinning around with his little stick figure nubs on it doesn’t stand out too much, but for my guy I just had to go with no arms because how am I going to have big white drawn arms that don’t look terrible when they start getting twisted around 360 degrees? Again, that wouldn’t be an issue with simple eight direction firing, but this is just going to have to stay like this for now.

Still less than halfway through this tutorial series so there’s still a lot more to go, but I’m feeling pretty good about it still, and I have a lot of ideas about what I’d like to start next. I think I’ll take some good advice I heard recently though and stick to something relatively simple for my first real attempt after this, something like a basic original Contra type side scrolling shooter. Best not to get ahead of myself though. Back to learning…