r/gamemaker•
Lazdev

"Optimizing Your games in GameMaker: Studio"

Hey fellow GMers,

The latest Game Maker Tech Blog is about optimization:

http://www.yoyogames.com/tech_blog/30

I was curious, do you guys do these? Especially curious about mobile games, as I have a few performance issues there myself.

Which ones are most important? Is the surface scaling one good? How much of a difference does it make? I've read about that before and I must say that I'm a little bit disappointed that the default drawing in Game Maker can't do that optimization by itself. I jumped onto game maker from Java to get away from the technical stuff ;)

Posted Nov 5, 2013, 7:30 AM UTC · edited

59
Telefrag_Ent•

Some good ones in there I haven't tried before, for me however the most important thing was sound quality when working with mobile devices. I had been working on a game for some time and every time I tested it on my Droid it got more and more laggy. I went through and optimized a ton and had, what I thought, was a very clean game, but it still lagged. Then I wen through all the music and sound effects and basically cut their quality in half. The game ran much smoother and the change in the quality couldn't even be detected.

3
danredux•

Some mistakes throughout. For example, drawing to a surface and scaling it is a horrible way to overcome scaling issues, because a 320x480 surface scaled up to 1400x1080 will look absolutely crap. Another example:

"It is important to note that this is not the case for any of the JavaScript modules (HTML5, Tizen or Windows 8), as they treat arrays differently. This means that you should initialize them from 0 upwards, and not in reverse."

Still initialize them in reverse, as there is no speed difference for JS platforms in the order, but there's no point writing the code twice...

3
LazdevOP•

My own scaling situation is that I have a 480x800 room that I'm letting Game maker scale to fullscreen by itself (no surfaces used) on different devices, for example a HTC wildfire will display the game in 320x240 while a HTC Desire will display it in native 480x800 and a HTC One X will display it in 720x1280. On PC the game will run in a 480x800 window.

Should I be using a surface instead like in the guide? Any ballpark figure on how much performance I might gain?

The HTC Wildfire (600mhz single core) is really struggling with the game at the moment, constantly running in slow motion at about 30fps instead of the correct 60.

1
noel_abercrombie•

Alongside those, I'd say swapping for() and while() loops for repeats, if it can be helped. I'm currently working on a Raycaster (think Wolfenstein), and swapping the depth scan from for to repeat gave it a 40%ish speed boost. This is a fringe example, but if you're doing lots of recursion, that's my tip.

2
Rawrcopter•

Do you know why this would be? I suppose I'll have to test in my own project, but it seems odds to see such a large increase from something so minor.

2
noel_abercrombie•

To be honest, I'm not actually sure why the gain was so large. I guess it's because of the check involved. Do sub X number of times uses less CPU operations than Do sub, check variable, if in range, do sub, etc. My project did use a lot of loops though (before I started to optimize it in other ways), so that tiny gain did add up in the end.

2
noel_abercrombie•

Did some testing, and these are my results replacing a loop that repeats 240 times a frame. If I went through and replaced every loop, it would likely be around the 40fps mark, I imagine.

http://i.imgur.com/PtViq2w.png The repeat actually looks like x = 0; repeat(view_width) { ... x += 1; } but you get the idea.

2
Rawrcopter•

Very interesting, thank you for taking to the time to do so! And is this done using GM:Studio? That red icon makes it look like a different version.

My game isn't crazy logic intensive (yet), but I replaced what loops I could with repeats, though I also did some other massive overhauls so I can't really say how much it affected my performance, but after everything, I saw a very large increase none the less.

2
noel_abercrombie•

That was done in GM8.1, which I normally work in (The project was started by someone else, in GM7 hence the icon). On studio the difference is lesser, but still there.

2