C#: Implicit conversion from null to struct (and more)

MyStruct some = null; // some == MyStruct(...)

This is a small post about a rather specific construct in C# syntax, permitting to assign "null" to struct-typed variables (which are non-nullable) and treat this specific case as you please.

If you did not come here looking for this particular thing, you may or may not be in a dire need of the post's subject, but explanation may be of interest.

Continue reading

Introducing: hxpico8

Have you heard of PICO-8? It's a "fantasy console" with little built-in sprite/code/level/sound/music editors and a carefully crafted spec. And (slightly changed) Lua scripting. And a web player export (example). A rather interesting option if you like working with restrictions and/or tiny pixelart.

Long story short, I've made a little Haxe compiler target that generates compact Lua code that runs on PICO-8. This post covers reasoning, some technical details, and tricks used to accomplish this.

Continue reading

Introducing: BitFontReader

BitFontReader screenshot

Let's talk about the process of making pixel fonts for a bit.

At first, it may seem like pixel/bitmap making fonts should be an easy process. After all, there were lots of pixel fonts back in the day, right? Although those were primarily raster FON files, while vast majority of modern programs require you to supply fonts in either TrueType (TTF) or OpenType (OTF) formats, both of which generally imply vector-based representations of glyphs (symbols).

Obviously, drawing a pixel font in a vector editor is as bad of an idea as it sounds.
Fortunately, there's a bunch (more like a couple) of programs specifically made for creating pixel fonts. However, these naturally imply that you will have to [re-]draw your font in the program itself, regardless of whether the program is to your tastes or not.

At this point one may be wondering, why isn't it possible to just draw the font in the pixelart editor of your choice and have it automagically converted into an actual font.
After thinking about this for some time (while trying to find "right-looking" fonts), my patience kind of ran out, and I've decided to make such a thing.

So I've made a program that does just that - you give it an image of your font, note the letters/symbols written in it, and get a code that you can import into BitFontMaker2 to make it into an actual font. It's small, clean, and runs right in the browser. Sounds good to be true? See for yourself:

Launch BitFontReader

(note: if the program does not load, change HTTPS in the URL to HTTP)

BitFive: Now with multitouch

This is only a small thing out of everything I need to make/finish/release in next months, but...
So there is now multi-touch support in openfl-bitfive, which is an alternative OpenFL HTML5 backend with focus on blitting and compatibility across platforms.
Usage is identical to Flash/AIR - you add an according event listener to your desired DisplayObject, and handle the TouchEvent objects it catches:

stage.addEventListener(TouchEvent.TOUCH_BEGIN, function(e) {
	trace("Touched at (" + e.stageX + ", " + e.stageY + ")");

And, same as it goes for mouse events, the rest is handled behind the scenes - events are routed automatically, and you don't need to worry about browsers and devices with partial or glitchy support.
You can even have your mouse events converted into touch events for ease of testing if you want (see bitfive_mouseTouches flag).

Addition is already live at both repository and haxelib, there's a demo available (probably want to view it from mobile device), and this post contains some extra details on what it took.
Also, if you needed this for some time, you can pretty much thank Ozdy (which is also the largest supporter of backend) for suggesting the feature.

Continue reading

Haxe: Simplistic .properties parser

If you have ever been using Java, you may already be familiar with .properties file format. This is a simplistic configuration file format, somewhat similar to INI:

# Comment
key = Value

For ones not liking that, there's also alternative syntax:

! Comment
key: Value

Where leading/trailing spaces are optional and are trimmed in parsing process.

Since I've seen people ask about this kind of thing, and also have seen people invent ridiculous (and non-functional) regular expressions to parse this file format, I thought that I may as well make an implementation that works "just right".

Continue reading

On “You can’t make good HTML5 games in Haxe”

You can't make good HTML5 games in Haxe

- A phrase usually popping up when it comes to a discussion about HTML5 and Haxe. Which is complete nonsense. Not just that it is nonsense, but it's also a good measure of how little (read: none) research the author of phrase has made on the topic. I'm quite tired explaining to people, why their opinion about this is incorrect, so I've decided to group key points into a post,

Continue reading