GameMaker: Passing variables into Create event

Time to time I see questions being asked about whether it's possible to set variables prior to instance' Create event being executed or otherwise passing values into the freshly created instance.

Most often, people will say that, no, you can't do that, but here's a bunch of strange workarounds instead (executing in alarm event \ moving all Create code into a user event).

Now, as you might be suspecting by the title of the post, that is not quite correct - there's a bunch of substantially more valid methods of approaching the problem. This post covers them.

Continue reading

GameMaker: Using external version control

Over time, I have witnessed a particular scenario a few too many times:

  1. A person demonstrates complete unwillingness to learn how to use version control, be that due to "lack of need" or delightful claims of their existing approaches (which most often turn out to be manual backups) being sufficient or even superior.
  2. A person loses days, weeks, or even months of work due to human error and/or hardware failure(s).
  3. Noticeably bitter about the situation, a person attempts to continue defending their position.

Having spent far too much time arguing with people and explaining how to use version control, I have decided to make a blog post that would cover a few things on the matter:

  • Explain the advantages of version control over "simpler" backups.
  • Explain (step-by-step) the basics of using a common combination for version control being BitBucket (service) + Git (software) + SourceTree (GUI client).

While this tutorial is oriented on GameMaker: Studio users, it can also be easily applied for other tools.

Continue reading

Understanding isometric grids

Isometric grid coordinate conversion demo
A GIF of the interactive demo seen later in this post.

Questions about the algorithms related to isometric grids are not uncommon. In fact, they are a little more common than you could expect them to be, given the relative simplicity of things.

So I have decided to write a little blog post on the two things important here:

  1. Converting local isometric grid' coordinates to global screen-space coordinates
  2. Converting global/screen-space coordinates to isometric grid' local coordinates
Continue reading

Top-down bouncing loot effects

GIF
In action

A little while ago, I was asked about what would be a good approach to creating an effect for a top-down game where coins would fly out of a smashed object. Not recalling any tutorials on the matter, I've made an example of this exact thing, and this is a post detailing everything related to such an effect.

Continue reading

GameMaker: applying “with” to multiple objects

As you may know, GameMaker Language has a Pascal-like "with" structure:

with (value) { code }

but it's not exactly like the Pascal version. In GameMaker, it can take an instance:

var bullet = instance_create(x, y, obj_bullet);
with (bullet) direction = 180;

or an object type (and will apply the expression to each instance of it):

with (obj_bullet) instance_destroy();

This can be rather handy under the multiple circumstances.

However, initially the same block can not be applied to multiple values, and that's less handy.

Sometimes you can cheat by applying the expression to a shared "parent" type of objects, but that is not always the case (and can have side effects if there are more object types meeting the condition).

So let's consider your options for applying a piece of code to all instances of several types: }

Continue reading

GameMaker: Tetris in full Drag & Drop


Click to launch the HTML5 version of the game

First, take a look at the above link. There's score, 7 tetriminos, slowly growing difficulty - standard things for a Tetris game. The catch? There isn't a single line of code. Nor a single variable. It's all done in GameMaker's "drag & drop" visual scripting.

The story of how this even happened is like so - yesterday was another day when my internet connection disappeared for half of the day without any logical reason whatsoever. As I look at the top of my now-static TweetDeck timeline, and notice this bunch of tweets from Vlambeer's Rami Ismail. While you can generally agree with points outlined, few things could have had better clarification:

  1. Difficulty depends not only on developer's coding skills, but also on the tools used.

    For example, making a "space invaders" game in most modern tools with built-in memory management, collisions, and function sets is easy enough, but should you go lower level... storing invader information in an array? Storing and moving around dynamically created player and invader bullets?? Programming trajectories and destructible defenses??? Not as much careless fun as you may have envisioned. Pong may seem suddenly simpler with base requirements of just a bunch of variables and inverting ball x/y velocity for bounces.

    Additionally, certain tools are best suited for certain task. For example, it is easy to make a turn-based puzzle game in PuzzleScript (hence the name) due to the way engine is based on "rule" definitions. Making a platformer game in PuzzleScript, however, is a much harder feat. It isn't, by no means, impossible, but requires more planning than it would take with a "platformer-centric" engine.

  2. Game development isn't just about having the right tools/resources/experience, but also actually using them creatively. As such, programming in general is often about finding an approach to the problem that isn't the most blatantly obvious or expected but produces results more efficient in terms of computer of development time.

To not make it all look like a rant or a opinion piece, the rest of this post is about creative use of tools - particularly, making the aforementioned Tetris in GameMaker without a single line of code or variable.

Continue reading

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: 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

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