All posts tagged GameMaker

I recently finished working on my HT3DR demo/prototype, and released it on the world two days ago. So far, people seem to like it, and that makes me happy.

I've done a few write-ups here and there to get the word out and promote it. One, in particular, dove into a few details I haven't talked about elsewhere, so I thought I'd share it here in case anyone might find it interesting:

Greetings fellow GameMaker users!

I recently finished putting the last touches on a game demo/prototype for a game called HT3DR, which is a remake/re-imagining of my old (and I like to consider, classic) GameMaker game, Hover Tank 3D. You can play the new game here: https://martincrownover.itch.io/ht3dr

I released HT3D way back in 2006! It is a complete game that took me over a year to put together, and though it looks a bit dated by modern standards, I am proud of it - especially considering the awful tools I had to use, and my complete lack of knowledge for building a thing like that.

I took a long break from GameMaker before working on this game, and I took it up as a challenge to see how much better I could do this time around, how much closer to my vision I could make it, and to get re-acquainted with GameMaker and its new features.

It took me 4-5 months to make my HT3DR prototype, and I ended up learning a lot - and so as I share my work with you, I thought I might share some of the things I learned as well.

Animation curves are incredibly useful

Before this project, I'd never used the new-ish animation curves feature in GameMaker. I had built a set of scripts many projects ago that emulated the common easing functions you find in other languages, like jQuery, through code, and I dropped them into all my projects. They were cumbersome to use, but they got the job done.

Animation curves take a lot of the guesswork out of things. It's easy to make a single animation curve asset for a particular action, like the purple "Swooper" ships in HT3DR, which contains all the different curves for their takeoff, landing, and A-to-B movements.

Batching helps

When I first started working on HT3DR, I was concerned about how well the game might run, even on my beefy computer - so I spent a lot of time making sure that as I added things to the game and tested them, the framerate wasn't dipping much.

At some point I was satisfied with performance and started just building out my demo level in earnest. I removed the FPs counter from the game as I tested the HUD, and never noticed a slowdown as I worked.

Once I had the near-final build of the level built, I started becoming curious about how things were running behind the scenes, and so I started testing performance again, and I was a little shocked to see that merely having a level full of walls (without enemies) had slowed the "real" fps from ~3,000 to ~300.

300 real fps isn't really that bad, but I wanted to cut down on waste. All my wall objects (1m, 2m, 4m, and convex/concave corners) all share the same texture, and they made up the majority of the level parts, so I wrote an object that batches them all into a single draw call, as opposed to over a hundred. The result was an increase of about 50-100 real fps, which seemed like a good gain.

I found this video, by DragoniteSpam, hugely useful in helping me figure this out: https://www.youtube.com/watch?v=PJwsJN-ZPxY

If I work further on this project, I might eventually consolidate all the static buildings into one draw call - maybe even the same one as the walls - and just merge them all into using one giant texture. Currently, the largest textures the game uses are 1024x1024.

Use state machines

All of the more complicated objects in HT3DR use a form of state machine to help sort out the code. For enemies, each object has a "state" variable and a "tick" counter, and uses an alarm timed to the tick. Each time the alarm fires, it calls a custom user event whose number corresponds with the state, which is responsible for doing whatever it ought to do. It then resets itself with the tick value, which can change based on the state.

This simple setup lets me have enemy AI only evaluate a few times every second, and it keeps the code from getting super long and becoming hard to debug just based on size.

The biggest drawback to this approach is GameMaker's hard limit of 16 custom user events, but I was able to keep my most complicated object (the end-level boss) under the limit pretty easily, so it worked out alright. Your mileage my vary, of course.

Parents and variable definitions keep things simple

I've been using GameMaker since around 2002, and I'm a little ashamed to admit that I haven't made much use of parent objects up to this point. I had a bad experience getting them to work right way back in GameMaker 5, and I always found ways around using them. Not this time!

Parent objects in HT3DR were incredibly useful. I don't even know how I could have made this without them. Giving all my walls a parent, all my enemies a parent, all the projectiles a parent, etc. saved me so much time, and made coding collisions, sound effects, and more a breeze.

Variable definitions, which are a bit newer to GameMaker, were equally helpful. I set all my default settings for an object type as variable definitions, and then changed them only when needed in the child objects. It made dropping a new wall object into the game, for example, almost as simple as just exporting it from Blender. Since I don't have to worry about setting up collisions, bullet reactions, etc. - it's all just there, ready for me to use from the parent object.

Don't be like me. Use object parents. And use variable definitions.

Chip away at your project

As I get older, I seem to have less and less time for my hobbies - game-making included. And so some days, I wanted to add a big new thing to HT3DR, but I just didn't have the time. I learned to accept that, and just chip away at small stuff instead, and it made this project much easier to make progress on.

Try to do something every day or so. Make it a habit to keep working and tinkering, small or large. Whether you just add a new global variable, or you try some crazy idea and it ends up being something completely useless at the end of the day, at least you learned something. And tomorrow will be better because of that.

Writing your own shaders is challenging, but rewarding

I've been using the internet since the 90's and I don't think I'm bad at searching for things - but as I learned to make my own shaders in GameMaker, I found it incredibly difficult to find good resources explaining the what and why of it all. I know resources like Shader Toy exist, but without someone stepping you through what each bit of code is actually doing, even open source shaders can be hard to glean value from.

I was about to just buy a book and spend a few weeks skimming through it when I found another great set of videos from DragoniteSpam, all centered around writing shaders: https://www.youtube.com/playlist?list=PL_hT--4HOvrdkihto8Xu7hhp1-5Gj8zsa

It was incredibly useful to hear him explain why he did certain things, what each step did, etc. In fact, I credit DragoniteSpam for unknowingly motivating me to get this project done. I would have never started it if I had had to contend with GameMaker's awful built-in 3D lights.

Don't re-invent the wheel

With that said, also don't re-invent the wheel. If others have done the work before you, utilize it. There's no shame in getting help.

I spent a few days working on my own bloom shader before admitting that it looked terrible. I poked around a bit for other solutions that might work, and came across the Post-Processing FX addon by FoxyOfJungle/Kazan Games.

I bought it, added it to the project, and a half hour later my bloom effect was just what I wanted - along with a couple of other effects that I wouldn't have added otherwise, like vignette and color/exposure adjustments.

This is an incredible tool, and I can't recommend it enough. I'm glad I didn't spend more time trying to make something inferior.

Backups are important, but source control is king

Using Github desktop is something that I've been doing for many projects now, but it really takes the pressure off of making big changes to a project.

In the old days, I would have saved a new version of the project before making big changes, and I would have constantly weighed my want to do so against not wanting to store hundreds of copies of my files. With Github, I just committed my project, made the big changes, tested, and committed again if everything went fine. Easy.

This made a couple of operations, like loading my project up in VS Code and doing a find/replace across the entire project, a lot less stressful. 😅

Find something you love and just make it

Many people are already doing this, but it doesn't hurt to restate it: if you have an idea, just try to build it.

In game development, my best projects are always the ones that I care about the most, and the ones that I spend time thinking about when I'm not actively working on them, and they only get to that point when I actually sit down and just start working on them.

Back in 1993, after I first played Starfox and saw the possibilities for even early 3D games, I fell in love with this stuff. I am an artist, and was learning how to draw in perspective around that time, and I drew so many basic polygonal images influenced by that game. One of those drawings was a tank, and it served as the inspiration for all of this - a thing that's been bouncing around my brain for almost 30 years.

I know an empty project is a daunting proposition, but it's so rewarding and fun to see your ideas come to life - and it has to start somewhere. Make a thing!

424 57 0

Today, I released the first update to gamemaker-3d-io, a Blender addon I created to help get 3D models from Blender into GameMaker Studio 2.

This update brings some new functionality to the addon: in addition to triangle lists, it can now also export line lists and point lists. Some neat effects can now be achieved!

I also refactored the addon a bit, splitting out the data prep and output-building functions into their own modules. And I cleaned up the export menu to be more organized in a better way.

Get the addon at the link above, or at Github. If you happen to use this addon for your game, be sure to leave me a note and let me know what you think!

675 97 0

Blender addon update

Martin · 2 years

It's been out for a few days, but in case you haven't seen it, I've finally updated my addon for Blender, which allows you to output 3D models to GameMaker Studio 2. The latest iteration of the addon will output models to GameMaker's vertex buffer format, so you can load the files natively, without including a bunch of scripts in the game.

You can read more about the addon here: https://martincrownover.com/blender-addon-gm-vertex-buffers/

Or you can go straight to the Github page, here: https://github.com/massivecatapult/gamemaker-3d-io

614 97 0

I've updated another of my old GameMaker examples to be compatible with GameMaker: Studio! This time, however, I've completely re-imagined the old example, and replaced it with something that demonstrates the same principles, but in a totally different way.

The new example is a 3D Starfield simulation, and it replaces the old 3D Night Sky file.

This new example uses the same technique as the old one, creating a model and using primitives to add points to it which draw as our "stars", but this new example also adds some linelists to the mix, as well as some infinite motion. I think it's a much more fun way to see this technique demonstrated, and it wont feel quite as redundant when I get around to updating the day/night cycle example as well.

As usual, you can download this new example over at my GameMaker Examples & Tutorials page. Thanks for checking it out!

I've updated my old 3D animated water examples to be compatible with GameMaker: Studio today, combining the two former examples into one superior example.

The previous examples used two methods for creating the water effect. The first used layers of scrolling, textured 3D planes drawn with an additive blend mode to make a detailed, if not always pretty, body of water. The second used a pre-animated texture, created in PhotoShop, to create a similar effect. A skybox was also employed, to make for better background scenery.

This new example combines methods from both of these files to create, in my opinion, a superior effect. With this updated example, the layers of scrolling texture have been relegated to a surface, which gets updated each step. This surface is then drawn over a base color plane for the water, all over a skybox with pre-baked reflections built in.

The effect could probably be more detailed, or could benefit from shader support for true reflections, but for what it is, I think it's a notable improvement.

You can find the updated file for this example on my GameMaker Examples & Tutorials page.

I spent some time experimenting with my Blender addon and GameMaker's 3D the other night, and I realized that the models it was creating were not entirely how they should be. It seemed that if you used the option to flip the object's Y axis on export, which is often necessary because GameMaker and Blender's world axes are different, then the model's normals would be flipped.

This wasn't immediately obvious to me, since the correct orientation of GameMaker's built-in models has always been kind of ambiguous, in my opinion. After following the code in the manual to make some of the primitive shapes however, I compared the results to what my Blender addon was creating, and came to the conclusion that the output from my addon was not quite correct.

So after a lot of tinkering (Python and Blender API are not my strong suits) I believe I've finally got the addon updated to export models that are oriented correctly and which should always have correct normals. Additionally, I added a feature which a friend of mine had built into his own version of the addon, which will let you output the model script in an alternative way, to more easily allow you to add it to an existing model in your game.

You can download the updated version of my Blender addon at the original page, which I've changed to include the newly updated addon. That will always be the place to go for the most recent version.

A little late for the 4th of July holiday, but nevertheless, I'd like to present a new GameMaker: Studio example - particle fireworks!

This is a pretty simple example which procedurally generates everything you see, using GameMaker: Studio's built-in functions. Most of the effects, such as the fireworks, smoke, and stars, all use the particle system. The sky is made with colored shapes and the land is a primitive.

Even though I started this from scratch, I consider it the spiritual successor to one of my really old game demos, which was also a fireworks simulation. I created that one to test out the particle effects in GameMaker, back when they were somewhat new. Here's what it looked like, in case you want to see how far things have evolved:

I think it's safe to say that both GameMaker and I have gotten a lot better at particles over the years!

Anyway, I hope someone out there finds this new example useful. You can find it on my GameMaker Examples & Tutorials page.

To continue my string of updated GameMaker projects, last night I uploaded a new version of my old Mandelbrot Fractal Explorer project, finally making it compatible with GameMaker: Studio.

The previous version was built in GameMaker 6, and relied on old functions like screen_refresh(), which have since been removed from the program. Surfaces are much more robust these days, so I've employed them instead of the old tech. I've made a handful of improvements to the functionality of the program as well, including making the zoom center on the view (this had always bothered me before), adding a timer to the render process, and moving the fractal drawing code out of a script (which basically froze the program for input on every update/render) and into the step event where the fractal surface is updated progressively, and the user can easily interrupt it at any time.

Render times remain an issue of course, but this was originally just an attempt to see if I could build something that would render fractals at all, so I still consider it a success.

The full source for this project is now available on my GameMaker Examples & Tutorials page, so if you'd like to tear it apart, make it better, or just see how it works, go right ahead!

940 95 0

I've managed to get my 3D rain example for GameMaker updated for GameMaker: Studio. I'm accomplishing updates at a pace that I can't sustain, woohoo!

This new version is near-fully commented and includes an updated rain effect that uses very simple models instead of textured walls. It also introduces water splash ripples and has a much better skybox than before.

Check out the updated example at my GameMaker Examples & Tutorials page.

939 96 0