HTML5 Game Development with GameMaker

HTML5 Game Development with GameMaker Cover

The introduction of HTML5 has revolutionized the web browser as a legitimate gaming platform with unlimited potential. Making games for the browser has never been simpler, especially with GameMaker Studio. Developers have full control over asset management, built-in systems for physics, particles and path finding. In addition, it offers a rich scripting language and extensions for developers now enabling everyone to create games and monetize them quickly and easily.

HTML5 Game Development with GameMaker will show you how to make and release browser based games using practical examples. This book utilizes GameMaker’s powerful scripting language allowing you to create your first game in no time. With this guide you will develop a thorough skill set and a coherent understanding of the tools to develop games of increasing complexity, gradually enhancing your coding abilities and taking them to a whole new level.

The GameMaker Studio environment allows you to jump right into building browser based games quickly and releasing them online. The chapters focus on core practical elements, such as, artificial intelligence and creating challenging boss battles. This book guides you on how to use advanced features easily and effectively, these include, data structures and demonstrating how to create rigid body physics with simple explanations and visual examples. By the end of this book you will have an in-depth knowledge of developing and publishing online social browser based games with GameMaker.

The Games

Want to see what you will be making in the book? Below are playable versions of the various games as they were coded in the book.

Chapter 1: Cat and Mouse

Chapter 3: Space Shooter

Chapter 4: Highschool Horror

Chapter 5: Mayan Mayhem

Chapters 6-9: Destruct

Purchase the Book

This book is for anyone with a passion to create fun and action packed web browser games using GameMaker Studio. This intuitive practical guide appeals to both beginners and advanced users wanting to create and release online games to share with the world, using the powerful GameMaker tool. To purchase a copy go to:

34 thoughts on “HTML5 Game Development with GameMaker

  1. Hi Jason, how specific to the html5 export are contents of this book? How much of it would it readily apply if I want to target, say, windows or android? Cheers!

  2. finding some errors in chapter 3 of your book.
    specifically, sound is called by the wrong name _01
    the sounds don’t seem to be playing anything as far as the bullets go?
    also, you never mention for the space bar shooting event, that the script should have the option object bullet and not self, until that is changed the space bar shoots the player forward instead.

  3. The majority of the book works perfectly for any platform. There are only a few things that are really HTML5 specific, but that would go with any platform.

  4. Hi Micheal,
    Thanks for letting me know. There is an errata page on Packt Publishing website of the known errors:

    As for the sound not playing, it is a known issue with the HTML5 module. When I wrote the book GameMaker Studio was releasing new builds quite frequently and all sounds worked perfectly in game. However, shortly after the book was released, something changed and sounds stopped working. It seems a bullet sound will be fired once, but then won’t repeat. Hopefully this is fixed in a future build. I should also mention that audio is by far the weakest aspect of HTML5, not just in games, but that there is no consensus among the browser developers 🙁

    Finally, I am not sure what you mean exactly by the spacebar shooting the player forward. Pressing the spacebar should just fire a bullet. If you can let me know what page you are on I can take a look at it 🙂

  5. In the book HTML5 Game Development with GameMaker there are additional sections with either errors or isn’t complete that you don’t have listed, but wanted to let you know about.

    On page 172, the example for the keyUp and keyDown conditions do not take the obj_Players facing into consideration.

    The code printed is:
    if (!keyLeft && !keyRight)
    if (hspeed >= 1) { hspeed -= 1; }
    if (hspeed = 1) { hspeed -= 1; }
    if (hspeed <= -1) { hspeed += 1; }

    if (keyUp)
    action = IDLEUP;
    if(facing == LEFT) { myAim = 150; }
    if(facing == RIGHT) { myAim = 30; }
    } else if (keyDown) {
    action = IDLEDOWN;
    if(facing == LEFT) { myAim = 205; }
    if(facing == RIGHT) { myAim = 335; }
    } else {
    action = IDLE;
    if (facing == LEFT) { myAim = 180; }
    if (facing == RIGHT) { myAim = 0; }

    It's also reprinted on page 174 in it's entirety.

  6. ops, copy and paste didn;t seem to work correctly. The code printed in my comment isn’t the code from the book, but what it should be instead.

  7. Thanks for catching this. I don’t know why I didn’t do this as it is obviously incorrect. Just me not testing things properly.

    It should also be updated on the errata page at Packt now. Thanks!

  8. Is there a GMX available for the game in Chapter 05? I followed it to the letter (up to the point of the cannons that constantly target the player) typing all that code, and hooking up the events. And got it to play. Then of course, I wanted to attempt modifying it to suit my own purposes and bjorked it all up. I know the script code is available via Packt, but it’s just the script code, I’d still have to hook it all back up. I just wanted to get it back to the point just prior to my own experimentations.

  9. There currently aren’t any completed files available, but I will talk to Packt and see what I can do.

  10. I don’t know if this is an appropriate spot to ask a question about a GameMaker topic, based on something in your book or not, but I’m curious… I followed the tutorial from Chapter 05, got it working, and made some changes specific to my own needs. Nothing fancy, just removed the IDLEUP, IDLEDOWN, RUNUP, RUNDOWN actions and added a THROW action with animation. Everything is working great, except when he runs off a platform, he maintains the RUN animation, whereas I want him to have an INAIR animation. I’ve tried several things, and can get the animation to play appropriately, except when he lands he plays out an IDLE animation first before doing what he needs to be doing (running or idle). In scr_AnimationControl I even tried to override the action if vspeed 0 or !isOnGround, but I still get that little extra animation when he lands. in scr_CollisionForecasting I removed the action = IDLE from the if (!place_free code segment, but still it plays that xtra animation upon landing. Any ideas on what I might be missing?

    If it’s not appropriate to ask these types of questions here, my apologies.

  11. Sure this is an appropriate place to asks questions, though not necessarily the quickest method to get an answer 😉

    The problem is actually really easy to fix. All you need to do is add the following code to scr_Player_AirControls:

    action = INAIR;

    In the book we only played the inair animation when the player jumped. Looking back at the code now, it was a better idea to place the code here then in the scr_Player_GroundControls script. Every state should handle itself when possible.

    Hope that helps!

  12. This is a great book! I’ve been waiting for something like this a long time! Question;IS THE scr_TNT_Activate code on pg 218 correct? I can’t seem to get it to work.Do you have a working game of toppling Towers?
    that we can see your code in? And now if you can do a book for creating RPGS with gamemaker you would be my hero for life!! I will pay in advance for a copy np.Jim

  13. Following your book to the letter (I believe) and just implemented the cat with it’s path and the collision logic to restart the game. When that occurs the original background music continues to play and a new ‘instance’, if you will, begins as well. This behavior continues with each death creating quite an aural mess. =) I suppose some kind of script could be created to check if it’s playing already and not start it again. But I’m concerned an earlier potential discrepancy between the book and the current version (1.2.1224 r29611) has me wondering if it’s the cause.

    When creating the two sounds, snd_bgMusic and snd_Collect, your book says to mark the ‘Kind’ as Background Music or Normal Sound in sound properties, respectfully. I have no such checkboxes or otherwise to define sounds on my screen (

    I’m going to move forward in the book, but I’d like to know how you would resolve the issues.

    Thank you, Jason!

  14. Hey L.R,

    Yeah, the audio system in GameMaker has change quite significantly since this book was released. The sound properties are no longer the same at all. I will take a look at the game and see what I would do to get the audio working correctly and post it shortly 🙂

  15. Hey Jim,

    The code should be correct. Is it not working at all? If you download the code off of the Packt website, it now comes with a GMZ file of the finished code. You can open that up and do a line by line comparison for all projects. 🙂

    As for the book suggestion, I have actually been thinking about exactly that concept. It’s just a matter of finding the time to do it. Good to know there is an audience for it!

  16. Thank you, Jason. Will a solution only be posted here or will the Errata information (PacktPub) be updated?

    Thanks, again!

  17. Hey L.R.

    I just sent the solution to PacktPub, so hopefully it gets put into the errata. But just in case, here is what you need to do.

    In obj_Overlord’s Game Start event, drag a Stop Sound icon into the Actions area and place it BEFORE the Play Sound icon with snd_bgMusic set as the sound. Now it will stop the sound before playing it and you should no longer have the aural mess.

  18. Hi Jason!
    I bought your book (eBook, Packt Publishing), is spectacular, magnificent.

    I wonder if such games can build upon the idea to make my own games and sell them.

    Of course, if these are successful have no problem sharing with you some percentage.

  19. You can definitely build off of the examples. The music isn’t owned by me and can’t be used without permission of the composer, Brian Werst.
    Just let me know what you’ve made so I can check it out!

  20. Thanks Jason.

    Of course, when you have something worth showing will be the first person to see him.

    Basically do this hobbye.

  21. Hi, Jason.
    First off, thanks for writing this book, it looks to be great, and was exactly what I was looking for so far. (Hope you find the time to get around to that RPG book idea, though. You’ll definitely have my money!)

    I’ve barely started, though, and found what appears to be an issue with the Timeline function in Chapter 1.
    Specifically, it does not appear to be looping as expected. (Tested on versions 1.3.1354 through the current 1.4.1398, to ensure it wasn’t a bug that had been fixed at some point.)

    When the game is run, the first two Collectible objects spawn randomly as expected, but no further objects spawn.

    Do you have any thoughts on how to solve this?

  22. Regarding my previous comment:
    Actually, this appears to be an error/bug specifically affecting HTML5 output.
    Changing to Target to Windows, and running a build shows that the Timeline loops properly as expected.

    So, it would seem that this is a GM:S bug affecting HTML5 output (or a flaw within HTML5 itself?).

    Still, if you know of a workaround, it would be most helpful.

  23. Yes, that is a bug with GameMaker. My original build on this site still works fine, so it isn’t HTML5 (or more specific a browser’s implementation of HTML5).

    There is no way to workaround the timeline issue directly. You could, however, not use a timeline and just use two alarms for the same purpose. You would just need to reset the alarm after the code is run and you would get the same result. Timelines are essentially alarms anyways 😉

  24. Hi, I am teaching gaming and animation using your book and they students and I love it. I am going through Chapter 3 and using GameMaker Studio and added a sound for the players bullet but can not find the Kind setting to set to Normal. I noticed this in Chapter 2 also but still can’t find any answers. Could you please let me know where this is or even if it is in the Studio version.

  25. There is no longer any “Kind” option in GameMaker. This book was written with Studio 1.1 and the audio engine was completely rebuilt in 1.3 (I believe). In fact all the sound_ functions should now be updated to audio_ as the legacy system is near the end of its life.

  26. Hi, I am working on Chapter 6 and starting on page 210 to page 214 I am creating an anchor and chain links. In the following script the chain is suppose to dynamically be created and attached to the anchor. The anchor and links do not appear in the room unless I comment out the code after the first for loop. I am not sure why. I added in some alerts and they all show up but the anchor and links do not. Any clues?


    for (i = 1; i < 10; i++)
    chain[i] = instance_create(x+ (i * 16), y, obj_ChainLink);
    //show_message("Chain" + i);

    //show_message("After 1st For");
    physics_joint_revolute_create(self, chain[1], self.x, self.y, 0, 0, false, 0, 0, false, false);
    //show_message("After 1st Link");

    for (i = 1; i < 9; i++)
    physics_joint_revolute_create(chain[i], chain[i+1], chain[i].x, chain[i].y, -20, 20, true, 0, 0, false, false);


  27. I’m not 100% clear on the issue. Are you saying that you have an instance of the Anchor in the room, and when you enter that room, you do not see the Anchor or the Chains? Do any of the objects have a draw event? Can you show a message and find out about the x and y location of the chains, are they saying they are where they should be? Let me know!

  28. I found the issue, for some reason the collision shape was incorrect for the glass and wood pillars and not a box like I thought I set it to. Thanks for the reply.

  29. Hello Jason, I’ve been running into situations where there will be local variables created in a “create” script and then called upon when used in a “Step” script and I am running into crashes as the game tries using the variables telling me the variable cannot be found. Once I move the variables over to the “step” script where they are used, it seems to work. I hope that this is a valid way to do things. I am concerned that when an instance is created using instance_create(); it will run the create code, hence declaring the local variables and if I don’t put them there, they won’t be created. The only work around I have found is to declare the variable before using it or at least at the top of the “step” scripts. I have not seen anyone else post about this and wonder if it’s my installation of GM:S that has issues. I have the latest version on Steam and haven’t been able to find information on this exact issue. Thanks for taking the time to read this. I was going to give specific instances of where I am running into this but thought a general description would be better.

    Here is the error I am receiving when running the game and activating an event/if statement (ie. in Chapter 4 when the ghost is going back to the bookpile, the isDissolving boolean is not recognized even though I am staring RIGHT at it in the “create” script):

    action number 1
    of Step Event0
    for object obj_Ghost:

    Push :: Execution Error – Variable Get -1.isDissolving(100013, -2147483648)
    at gml_Script_scr_Ghost_Step (line 28) – if (isDissolving == false)
    stack frame is
    gml_Script_scr_Ghost_Step (line 28)
    called from – gml_Object_obj_Ghost_StepNormalEvent_1 (line 1) – scr_Ghost_Step();

  30. I figured out the issue I was having that I posted on December 23rd. I mistakenly forgot to attach the create script to the Ghost object. You can delete my posts if you’d like.

  31. Glad to see you were able to figure out the issue. I can’t tell you how many times I have forgotten to attach a script and wondered what went wrong.

  32. hello jasan i found this error when running game of tower toppling
    action number 1
    of Draw Event
    for object obj_Menu:

    Push :: Execution Error – Variable Get 100023.win_Y(100064, -2147483648)
    at gml_Script_scr_Menu_Equipment (line 11) – if (win_Y > menuItems_Y – menuItem_Zone && win_Y < menuItems_Y
    stack frame is
    gml_Script_scr_Menu_Equipment (line 11)
    called from – gml_Script_scr_Menu_DrawGUI (line 10) – scr_Menu_Equipment(i, ds_list_find_value(inventory, i));
    called from – gml_Object_obj_Menu_Draw_0 (line 2) – scr_Menu_DrawGUI();

  33. Sorry for the long delay in responding, hopefully you figured it out. If not, from what it looks like, it appear you haven’t initialized your win_Y variable OR this script is being called before the place where you set that variable. I’d need to know a lot more than just the error.

Leave a Reply

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