DEV Community

Richard Oliver Bray
Richard Oliver Bray

Posted on

Thinking of moving from Web dev to Game dev? Try HaxeFlixel.

I've been working on a game using HaxeFlixel for the past few months and it's been a blast. It's the first proper game engine I've used and although it has a small community there's always someone online willing to give a helping hand if the answer isn't on Stack Overflow.

If you're a web developer (preferably one who uses Javascript), and you've had a wanted to develop your own game that can run natively on desktops and consoles, Haxeflixel is definitely a great place to start. If you've read my previous post, What is Haxe and why should I care about it, you'll know how similar Haxe is to Javascript, well Typescript so it's a pretty smooth transition from web to game development.

What is HaxeFlixel?

HaxeFlixel logo

HaxeFlixel is sort of a weird game engine. It was originally a popular Flash engine called Flixel written in Actionscript 3 (AS3). But as Flash went down in popularity so did Flixel. Since Haxe is very close to AS3 syntax wise and can be exported to the popular flash language, it made sense to move Flixel to Haxe, but there's more under the hood than just a simple Haxe. HaxeFlixel is built on top of something called OpenFL which is what allows it to export games or applications natively to consoles, desktops and mobile devices (as well as web browsers).

What is OpenFL?

OpenFL logo

OpenFL is an open-source framework used to create games and applications. It was built to filly mirror the Flash API which means it supports easily rendering and animating vector images, bitmaps, and text, using the graphics hardware of the platform it exports to. OpenFL has many more features which you can read about here. For the Haxe version of OpenFL as opposed to the Typescript/Javascript version, it comes with something called Lime.

What is Lime?

Lime logo

Lime is described as a "flexible, lightweight layer for Haxe cross-platform developers". It's basically what takes care of the exporting of software natively to their targetted platform. So for example, if I wanted to export a game to Mac, it would take care of the inputs, audio, windowing, network access etc.. It also does the same for Windows, Linux, HTML5, Android iOS and consoles. It's as simple as running:

lime build windows

in your terminal (or command prompt), once you have HaxeFlixel installed.

Why should I use HaxeFlixel?

For starters, it's really simple and quick to install. If you've got VS Code installed it would take less than a few minutes to get up and running from scratch (as in you don't have Haxe on your machine). Because it's based off the Flash the API it isn't difficult to understand, they have great documentation online and also in their source code.

A piece of code like this:

package;

import flixel.FlxState;
import flixel.text.FlxText;

class HelloWorld extends FlxState {
    override public function create() {
        super.create();
        var text = new FlxText(0, 0, 0, "Hello World", 64);
        text.screenCenter();
        add(text);
    }

    override public function update(Elapsed:Float) {
        super.update(Elapsed);
    }
}
Enter fullscreen mode Exit fullscreen mode

Will display the text 'Hello World' in a Window running at 60fps on any platform you want.

lime test html5
lime test flash
lime test mac
lime test windows
lime test linux
lime test ios
lime test android
Enter fullscreen mode Exit fullscreen mode

HaxeFlixel Hello World

And as I mentioned in my previous post the syntax is super similar to Typescript/Javascript so if you're a front end web developer this is very familiar territory. It's also FREE and doesn't require you to learn a new GUI which is a plus for me.

I plan to write a tutorial series as some point showing you how to get a simple HaxeFlixel game up and running but for now, have fun developing games. And if you have any questions, please don't hesitate to ask me, or anyone in the Haxe Discord server.

Top comments (0)