GameMaker: trace/log function

Debugging GameMaker games can be fun. Or not fun. Depends on what your defintion of "fun" is.
Either way, in GameMaker: Studio, a new debugger was added, which you can (and probably should) enable via File - Preferences - "Scripts and Code" - "Use the new Debugger".
That includes a profiler, a step-by-step debugger, and a bunch of other useful things.

But, alas, sometimes, there is no time to explain, no time to write the best code of century, and certainly no time to sit down and stare at variables in watch window. You got to make games fast. And debug fast.

GameMaker: Studio noticeably spots a "console" dock, which is used to display compilation and runtime information, errors, and bunch of other things. But the important part is, that you can also send your own messages into it via show_debug_message. That's nice, since throwing a look at dock is fast. But, you know, what's not fast? Using show_debug_message to do so.

So this post is basically about what I've came up with to improve use of the thing, both for Studio and not.

Continue reading

GameMaker: GM8 code editor color scheme for Studio

If you are using GameMaker: Studio and find default dark theme to be odd, you probably have already switched to lighter "GM8" theme via File - Preferences dialogue.

But, alas, switching to "GM8" theme does not change code editor color scheme, and you still get the default dark gray-orange theme in middle of your light-colored IDE.

So I thought that it would make sense to publish a GM8-esque color scheme that I've made and am using locally for a while now.

This color scheme follows GM8 style closely, with few exceptions like displaying resource names in teal instead of yellow (which grants higher contrast and generally looks better).

To import a color scheme, go to File - Preferences - Scripts and Code, click Import button, and pick the obtained file.

It is hard to make a large post about thing as small, so here's the file:

Download COL

Alternatively, file' contents (to be saved as gm8x.col and imported into GMS):

<Colours>
  <Color0>0</Color0>
  <Color1>8388608</Color1>
  <Color2>16711680</Color2>
  <Color3>32768</Color3>
  <Color4>128</Color4>
  <Color5>128</Color5>
  <Color6>128</Color6>
  <Color7>8388736</Color7>
  <Color8>11171870</Color8>
  <Color9>16777215</Color9>
  <Color10>14744314</Color10>
  <Color11>10512464</Color11>
  <Color12>5988454</Color12>
  <Color13>16120058</Color13>
  <Color14>255</Color14>
  <Color15>2633011</Color15>
  <Color16>11913437</Color16>
</Colours>

Have fun!

GameMaker: Testing two game instances at once

If you are using GameMaker: Studio to create multi-player games (via not-so-recently added network_ functions or by utilizing existing DLLs) without separate projects for server and client, you might have stumbled upon one annoying limitation - you can't run two instances of game from IDE.

From a glance, this looks like a small issue, but it gets tedious really fast - to run a second instance, you have to either compile the game (takes time and monotonous file dialog actions), or find a compiled .win file in depth of temporary directories (or otherwise retrieve it's location via means of WinAPI), and pass it to the runner via command-line, like

...\AppData\Roaming\GameMaker-Studio\Runner.exe -game (path to *.win file)

But that's no fun, right?
At least I've found so.
So I took a bit of time and made a small GML snippet to lift this unfortunate limitation.

Continue reading

GameMaker: Windows-specific functions for Studio

While working on one of recent projects, I've stumbled upon few common issues that many meet - even if you are only targeting Windows in GameMaker: Studio, you cannot access files outside the game's AppData directory (not even in program directory). Neither you can order system to open a file, meaning no external "readmes" to be easily hooked up with game, nor portable configuration files, and some other limitations.
So I took an evening and made a simplistic DLL library to bring equivalents to some functions (sleep, execute_shell, non-sandboxed I/O) back for Windows target. Function list is as following:

Continue reading

Notepad++: Syntax highlighting for GameMaker Studio

npp-gml-gms

Some time ago I've introduced a Notepad++ syntax highlighting file for GameMaker 8.1 and earlier versions. At the time, making a GameMaker: Studio version seemed slightly less senseful, since dynamic scripting functions are no longer supported, and code in XML files is escaped slightly, but then... oh do wait, extensions!
Extensions in GameMaker: Studio are imported into each project locally, permitting easy modification of their files. Of course, this also implies ability to edit GML files in them. Which in turn permits editing them with external editor of choice without having to deal with XML conversions.
So I took those several minutes needed, and updated UDL (user defined language) file for GameMaker: Studio. It contains all functions, variables, and constants present as of version 1.2.1264 (released January 22, 2014). Apart of new keywords, it now sticks to editor style better as well.
Oh, and you can fold code with comments (//{, //}). Foldable sections are awesome.

Download UDL (XML)

(or grab source from PasteBin, if Dropbox is somehow inaccessible)

... and if you prefer Sublime Text, there's GameMaker plugin for that too (by Cycododge).

GameMaker: Click ‘n drag to pan view

vis-view-drag

Today I'm going to tell a bit about implementing "click and drag to scroll" type of effect in GameMaker. This particular thing is useful for strategy games (and normally bound to middle mouse button), applications (where visible area may exceed available window space), and various mobile games and applications (where visible area may be panned by tapping and dragging the finger).
Effect itself looks like this:

Continue reading

Introducing: OpenFL-bitfive

OpenFL-bitfive logo

Today I'm officially releasing OpenFL-bitfive, an alternative backend to OpenFL-html5. Similar to standard backend, OpenFL-bitfive assists you at creating HTML5 games (apart of standard Flash, Windows, Mac, Linux, Android, iOS, [...] ones) with use of comfortable Flash-like OpenFL API. A difference is that while focusing only on certain feature set, OpenFL-bitfive reaches quite higher performance and compatibility in its niche, also making it possible to develop mobile HTML5 games using the framework. This post goes in-depth about it.

Continue reading

GameMaker: Opening GM5/6/7/8 projects in Studio

Opening GameMaker files with GameMaker: Studio

One of first questions ever when starting with GameMaker: Studio is how does one open pre-Studio GameMaker projects (such as GameMaker 8.1, GameMaker 8.0, 7, 6.x, 5.x...). If you got here from search, you probably already tried opening these by dragging them over the program window or attempting to pick these from "Open" menu which does not allow to switch file types. Thus you are probably thinking something in the lines of this now:

Sad handdrawn character standning. Caption says 'Rewrite all the code?' in italics.

But no, of course it isn't that bad (why would someone do this to you?), and you can get your projects running in GameMaker: Studio by importing them. This posts explains how and why.

Continue reading

GameMaker: Compacting Studio project files

If you have ever inspected directories of newly created projects for GameMaker: Studio, you may have noticed that even the seemingly empty project does "weight" a bit. 4 megabytes, to be precise (or 2 and half if zipped). Now you could say that it's not a lot nowadays, but it does stack, and those extra megabytes now and then could have came useful somewhere else (especially if keeping multiple backups of same project or periodically sending it over to someone). And, overall, it's a bit more than you'd logically expect from something that doesn't do anything (yet).
Reason of this is that upon creation your project looks roughly like this:

That is, most of space is occupied by Configs folder. It, in turn, mostly contains data and placeholder images for entire variety of platforms that GameMaker: Studio supports.
A thing is that far not many of those are actually needed in most situations, since splash screens and icons are commonly replaced with game-specific ones, and items left unmodified are commonly not used at all.
This post goes a bit into "optimizing" GameMaker: Studio projects a bit to reduce filesize drastically.

Continue reading