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.

One comment on “Practice Platformer in Gamemaker Studio 2 – Part 3 (Now with sound!)

  1. ignitedmoth says:

    Nice! 😀 Looks like you’ve made a lot of progress and learning a lot of cool stuff as you go along. That’s awesome.
    Haha and I like the bleakness of the readable text and then the sudden “Under construction. Fuck Off!” 😛

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.