Haxe: migrating For-loops

Migrating from C-styled for-loops to Haxe for-loops

If you are migrating to Haxe (or just porting an existing application) from another C-like language, such as JavaScript or ActionScript, you may have already noticed that for-loops in Haxe differ a bit from standard format that you would expect to see in languages of this type. To be precise, they lack common 3-statement format support. This article is dedicated to different methods of "migrating" your for-loops without rewriting contents entirely.

Continue reading

Haxe: Replacing NME/Browser (Jeash)

If you are working with HaxeNME, you might have noticed that compiled JS/HTML5 applications do not necessary work same as other platforms. Or don't work at all. Or don't compile because of some uncommon unimplemented method that you've used.
Reasons of such behaviour are even somewhat understandable - process of recreating Flash API on JavaScript+HTML5 isn't exactly an easy task, especially since multiple features do not exist in both of two in the same way or do not exist in second at all, meaning that implementation may require a trick or two to work.
And as code base is accumulating "tricks" by multiple contributors, it does not necessarily remain entirely stable.
For example, if you've decided to clear your BitmapData-based 640x480 buffer via BitmapData.fillRect, you are making a huge mistake - the function is not just doing this pixel-by-pixel, but also via ImageData API.
Overall, this article is dedicated to substituting Browser/Jeash part of NME by your own library in JS compilation.

Continue reading

“live-reloading” web pages via AutoIt

So I've been recently looking for something to help with micro-debugging (mostly verifying output) of my JavaScript+HTML applications via automatically reloading test page on source change, and found a variety of solutions,

A bit of a trouble, isn't it? For most purposes, it'd suffice to check for file time change and refresh the page in the browser. So might as well do that with help of AutoIt.

Continue reading

GameMaker: Troubleshooting strange outlines on images

Strange outlines around images in GameMaker and fixing them
With the glitch (left) and without (right)

If you've ever tried to scale imagery (sprites / backgrounds) up while having texture (/pixel) interpolation turned on, you might have encountered some drawing artifacts. These normally look like the left part of above image, being either random black/white dots or a whole semi-transparent outline around the image. This article goes a bit in-depth about why these occur and how to fix them.

Continue reading

Vector: GameMaker: Studio logo in Windows 8 style

GameMaker: Studio logo in Windows 8 style

This vector icon was originally drawn by me as illustration for one of discussions I was participating in at end of April, which rolled from discussing GameMaker: Studio functionality to discussing it's current logo to making guesses how it could be made better and particularly if Windows 8 - like style would have worked for it. I'm not sure whether this is a good logo generally, but I think it could be useful at times when current 3d-looking Studio logo does not quite fit aesthetically.
To maximize ease of adaptation, scalable vector source file (SVG) is also included here.

Download SVG Download PNG Download HD PNG

(note: as of 2014 or so, GameMaker no longer uses this particular icon, but you can still use this I guess)

Also I've made a GameMaker: Studio HTML5' loading bar extension out of this logo, which looks like this:

Continue reading

Notepad++: Syntax highlighting for GameMaker ≤ 8.1

Similar to other few posts about Notepad++ on this blog, this one also contains a user defined language for said program. As you can guess from title, it's for pre-Studio versions of GameMaker Language (GML).
I've made this UDF file a while ago actually, but wasn't publishing it, since it seemed that there is at least one more solution existing for this. Apparently not anymore.

This language definition supports all standard language structures of GameMaker. As well it highlights all existing functions, constants, and "special" variables (like global/self/other). Colour "conventions" are kept to ones of GameMaker. User-defined script and constant names are not automatically detected, unfortunately, but you may include these in Keyword Group 6 manually for them to be highlighted.

Download UDF

And if you are looking for GameMaker: Studio syntax highlighting, there's a UDL for that as well.

GameMaker: Android hardware button handling

Standard set of 4 Android hardware buttons

One of common questions about GameMaker: Studio include "How do I detect presses of hardware buttons (Home, Menu, Back, Search)?".
Despite of common assumptions, usage of these in GameMaker: Studio is pretty straight-forward - mentioned button events are automatically mapped to according keyboard button events. So, handling these is as easy as adding standard keyboard events.
More information about each follows,

Continue reading

GameMaker: Recursive folder copying

In some situations you may want to copy a folder from your GameMaker game. And it would seem trivial but not that easy. file_copy can only copy files, and folder functions only allow you to create, check, and search folders for files. However, given these standard functions, implementing a folder copying routine is fairly easy.

Idea used here is to find a list of files and folders via file_find_*, and then go through them, checking whether they are files or folders, copying or recursively calling recursively function script accordingly. Sure that poses a potential problem if you were to copy entire disc contents to other location, but you are probably not going to be doing that via GameMaker... right?

Attached example contains the function and brief demonstration of functionality (you have to input source/destination paths as text).

Download GMK

Code follows,

Continue reading

GameMaker: Basic 3d bone animations

This example demonstrates how to create fairly basic bones for use in GameMaker 3d games fairly easily. Such can be used for character and environment animations, provided that they can be split in rotatable parts to some extent.

Advantages

As you may know, GameMaker does not quite support vertex animations. That means that models have to be either composed on-fly (which is a slow method), or "baked" as a number per-frame models (which takes amounts of memory proportional to how smooth you want your animations look). Bone animations, on other hand, work fast (since only transformation calculations need to be done), and require small amounts of memory.

Implementation

Idea of bone transformations is that you have so called bones, which can be attached to other bones, which makes them rotate together. That means, to find transformation matrix (position, rotation, and scale) of any given bone, you need to go through all of its "parent" bones, combining matrices. Normally this would be a slightly tricky task (especially if engine of choice does not have matrix operations built in), but, fortunately, GameMaker includes a set of functions to manipulate matrices (d3d_transform_).

Attached example includes a minimal system for linking bones together, drawing them, and a sort of procedural animation example.

Download GMK

GameMaker: Shadow casting in platformer games

This is a very old example of mine actually (creation timestamp says Sep 2010), which I've recently fixed & improved at request.

It demonstrates a simple algorithm to cast shadow from instance in platformer game. So when player jumps, shadow is displayed on ground below (realism!).

For the sake of simplicity and performance, shadows are checked against bounding boxes by default. Pixel-perfect checking is added as a separate condition, requiring affected objects to be children of obj_complex.

If you're interested in how this works behind-the-scenes, here's an illustration:

Outlined instances are ones used for finding top-most position below the player (which shadow will be cast onto). Red line is a number of point checks to indicate top-most point on objects with precise masks.

As another random visual tweak, there's a piece of code added to make shadow shrink as caster gets further from ground. A small touch, but these add up over time.

Download GMK