This minimalistic example provides you with a function to shuffle strings. That is, returned string contains all characters from source string, but mixed in random order.
Code follows,
Continue reading⚂ But do the random phrases cache
This minimalistic example provides you with a function to shuffle strings. That is, returned string contains all characters from source string, but mixed in random order.
Code follows,
Continue reading
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.
Continue readingThe 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.
Text versions follow,
Continue reading
This rather cute-looking example demonstrates creation of 3d-person camera in GameMaker' 3d. And character rotation. And a few other things.
Descriptions and explanations following,
GameMaker has a built-in keyboard_string
variable that lets you do simple text entry,
but what if you also want a caret
(so that the user can enter/erase text in the middle of the string)?
This is a post about that - a pretty reasonable input field.
Originally posted on Mar 16, 2013 (archive), revised in 2023.
Continue reading
Once in a while you might want to get a resource index out of it's string name, like so:
instance_create(x, y, 'obj_item' + string(irandom_range(1, 3)));
But, resource indexes aren't strings, so that wouldn't work.
You could add indexes into an array, or have a little switch-statement, but take a bit to set up.
So let's see what else you can do about this,
Continue reading
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
If you are working with GameMaker, you might have wandered, how to make paths similar to standard ones but in 3 dimensions, or how to efficiently draw path of non-1px width, or other things not covered by path functions.
For this reason, I have made the following function:
Continue readingThis 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.
Continue reading