GameMaker – Substitution “cipher”

This example provides a function to substitute all characters in a string, which present in first set of characters, by characters from second set. This can be used to substitute l/e/a/s/t/o characters in a string by 1/3/4/5/7/0 accordingly, turning your "Hello World" into "H3110 W0r1d" in single script call, or to replace/swap characters with completely irrelevant ones, providing simple "encryption" (e.g. Caesar cipher or various substitution methods) to challenge the player.

Functional part is presented by a single script, named string_subst(string, from, to), which returns string with all characters from set from replaced by according characters from set to. As long as both from and to are of equal length and do not contain repeating characters, output can be "decrypted" by passing parameters in swapped order, e.g.

var asrc, adst, source, encr, decr;
asrc = "0123456789"; // source "alphabet"
adst = "3456789012"; // destination "alphabet"
source = "51"; // source text
encr = string_subst(source, asrc, adst); // "encrypted" text
show_message(encr); // Displays "84;"
decr = string_subst(encr, adst, asrc); // "decrypted" text
show_message(decr); // Displays "51;"

Attached example demonstrates both "encryption" and "decryption", and has nice buttons.

Download GMK

Continue reading

GameMaker: Cycling random funky text

The idea behind this effect is simple enough - for every string character that should be randomized, replace it with any other character that has same width (so that the drawn string would not wiggle chaotically).

It uses 3 scripts total - one for general initialization, one for per-font init (creating a map of lists for what glyphs any given one could be replaced with), and one for actual string processing.

Can be handy for various abstract pieces, or as an interesting way to censor text.

Download GMK Live demo

Text versions follow,

Continue reading

GameMaker: Jetpack platformer

This is an older example of mine, featuring pixel-perfect movement and collision engine for jetpack platformer game. As extras, it includes particle spawning, and impact velocity calculations. Current version is updated to have a cleaner code style (no more bracket-less conditions and seriously doubtful operator combinations), as long as more comments (increasing comment coverage to a value close to 100%). Also there was a game being made around this concept once.

Download GMK

GameMaker: Circular cooldown rectangle

GameMaker: Cooldown rectangle

I do not know the exact name of this visual effect (angular/clockwise fade-in/fade-out?), but it is one of the most common things that you can see in interface of RPG and RTS games, displaying progress of construction/upgrade/ability cooldown. So, to the point...
You can read how this is actually being implemented, or just scroll down to the bottom of post and grab the code and/or GMK file.
Implementation of such is actually pretty simple, Continue reading

GameMaker: “flawed” AI path finding

In some cases, you may want object's AI to not pick exactly perfect path.

This example demonstrates creation of a basic "flawed" AI, that uses a rather plain method of finding path. Such will still make it reach destination in many cases, but will also allow player to "fool" the AI, making it stuck in dead ends or T-intersections (if player is standing right behind the wall).

To illustrate simplicity of concept, example is largely made in Drag & Drop.

Download

Continue reading