A small post about using System.IO.Compression.DeflateStream
for compressing data in C# (and Haxe-C#).
Category Archives: Generic
Fast approximate arctan2/atan2 function
(click to interact)
Preparing your game for deterministic netcode
If this looks slightly familiar, that's because it is
Considering that frequency at which people ask me about what it takes to do netcode (and what they need ready for it) continues to rise year-to-year, I figured that it's about time that I finally make a blog post about this.
This one's about deterministic netcode as it is by far most requested and also the kind where it's possible to give more specific advice than "it depends".
Continue readingGameMaker: smart floor/ceil functions
Simplest possible predictive aiming
This is a blog post about aiming ahead to hit moving targets! It has interactive elements.
Continue readingGrid-based contour traversal
This is a small post about the algorithm I wrote for the recent pixel font tool to establish paths of shapes and holes on the image.
Continue readingA small guide on writing interpreters, part 2
label hello: select dialog("Hello! What would you like to do?") { option "Count to 5": for (var i = 1; i <= 5; i = i + 1) { wait(1); trace(i + "!"); } return 1; option "Nothing": jump yousure; } label yousure: select dialog("You sure?") { option "Yes": trace("Well then,"); return 0; option "No": jump hello; }
Example of supported syntax
As some might remember, earlier this year I have published a small guide on writing interpreters, which went over the process of implementing a basic interpreter capable of evaluating expressions consisting of numbers, operators, and variables.
This continuation of the guide further expands upon concept, outlining how to support calls, statements, and branching - enough for a small scripting language.
Continue readingSimple intersection checking between rotated rectangles and circles/points
(click to interact)
(mouseover/click to play GIF)
(click and drag to adjust rectangle size/position/rotation; distance to a circle is shown)
Suppose you have a rotated rectangle and a basic shape that rotation doesn't matter for (such as a point, circle, or a line segment), and you want to check whether the two are intersecting - be that for collision handling, hit testing, or whatever else.
On a glance this might seem like a bother because things are rarely too simple with rotated rectangles, but in this case it isn't - because you can "unrotate" the rectangle.
This small post is about that.
Continue reading2d pivot points explained
(click to interact)
(mouseover/click to play GIF)
(spaceship graphic by Kenney)
Nowadays, most development tools provide ways of setting pivot/center point for imagery - that is, the relative point around which the image will rotate and usually be positioned relative to.
However, ability to define multiple pivot points per image remains relatively uncommon, despite being something that you want to have projectiles fire from a correct point of a sprite, display weapons/attachements at right relative points, or do anything else that demands relative offsets.
This small post is about that.
Continue readingConverting key code to key name and vice-versa
(click to interact)
(mouseover/click to play GIF)
Interactive demo (if JavaScript is enabled)
This is a small post about how to convert key codes to key names and/or convert key names to key codes. Comes with sample code for GameMaker and a generic version.
Mostly published because it covers majority of common and semi-common buttons.
Continue reading