Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
5. May 2016

 

Introduction

Welcome to the first part of a multipart tutorial series on creating games using the Haxe programming language with the Heaps graphics engine.  Heaps is under development by Nicolas Cannasse, the guy that created the Haxe language in the first place.  In his own words:

Heaps is a cross platform graphics engine designed for high performance games. It's designed to leverage modern GPUs that are commonly available on both desktop and mobile devices. The framework currently supports HTML5 WebGL, Flash Stage3D, native Mobile (iOS and Android) and Desktop with OpenGL. 

Heaps is a very cool library, but not an incredibly well documented one.  So that’s where this tutorial series comes in.  We are going to look at creating 2D then 3D graphics using the Heaps engine.  For this series I will be doing both text and video versions of each tutorial.

 

Setting Up Your Haxe Development Environment

This tutorial is going to assume you are using Windows, if you are on another operating system, the steps are going to vary slightly.

First head to Haxe.org/download and download the appropriate Haxe installer for the most reason version.

image 

In my case I am going with the Windows Installer.  Run the executable and say yes to any security messages you receive.  You want to install everything like so:

image

 

Install where ever you like:

image

 

Verify your install worked correctly.  Fire up a command prompt and type haxelib version:

image

 

That was easy, eh?  Next you will probably want an IDE or Editor.  Personally I am using Haxe Develop, a special port of Flash Develop.  This is a Windows only IDE though.  Another option is Visual Studio Code with the Haxe language extensions.

 

Finally we need to install the Heaps library.  It’s not registered with Haxelib yet, so we currently have to install it from Github.  Run the command:

 

haxelib git heaps https://github.com/ncannasse/heaps.git

image

 

And done.

 

Creating a Hello World application

Now let’s create our first application to make sure everything is up and running correctly.  A simple hello world app.

Assuming you are using HaxeDevelop, go ahead and create a new project via Project->New Project

image

 

I created a JavaScript project like:

image

 

Inside our project folder, we need to create a folder for our resources.  I simply created a directory called res.  Simply right click your project in the Project panel and select Add->New Folder...

image

 

Next we need a TTF file, I personally used this font.  Simply download that zip and copy the ttf file into the newly created res directory.  You can open an Explorer window to that directory by right clicking it and selecting Explore.  I personally renamed it to not be all caps, it should work either way though.  If you are using HaxeDevelop, your project should look something like this:

image

 

We have two final bits of configuration.  First we need to text HaxeDevelop that we use the Heaps library, and that the resource folder is named Res.  Right click your project and select Properties

image

 

Next select the Compiler Options tab.  First add an entry to Compiler options with the value –D resourcePath=”res”.  Then add a value to Libraries of heaps.  That’s it, click Apply then Ok.

image

 

Finally some code!  First we need a WebGL canvas for our application to run in.  Simply open up index.html located in the Bin folder and add a canvas.  Your code should look something like:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8"/>
	<title>JSTest</title>
	<meta name="description" content="" />
</head>
<body>
	<canvas id="webgl" style="width:100%;height:100%"></canvas>
	<script src="JSTest.js"></script>
</body>
</html>

 

Now we need to edit our main Haxe code.  By default it will be called Main.hx and it’s the entry point (and entirety) of our program.  Enter the following code:

import h2d.Text;
import hxd.Res;
import hxd.res.Font;
import js.Lib;

class Main extends hxd.App {
        var text : Text;

		// Called on creation
        override function init() {
			// Initialize all loaders for embeded resources
			Res.initEmbed();
			// Create an instance of wireframe.tff located in our res folder, then create a font2d of 128pt size
			var font = Res.wireframe.build(128);
			// Create a new text object using the newly created font, parented to the 2d scene
            text = new Text(font, s2d);
			// Assign the text
			text.text = "Hello World";
			// Make it read, using hex code ( RR GG BB, each two hex characters represent an RGB value from 0 - 255 )
			text.textColor = 0xFF0000;
        }

		// Called each frame
        override function update(dt:Float) {
			// simply scale our text object up until it's 3x normal size, repeat forever
			var scaleAmount = 0.01;
			if (text.scaleX < 3.0) text.setScale(text.scaleX + scaleAmount);
			else text.setScale(1);
			
        }

        static function main() {
            new Main();
        }
    }

Now go ahead and run your code by either hitting F5 or click this button image

You should see:

GIF

 

Congratulations, your first Haxe programming using the Heaps library.  Next up, we will jump into 2D graphics with Heaps.

Programming , ,

9. March 2016

 

So I’ve decided that it’s time to do another series about Haxe development here on GameFromScratch.  I did a short five part tutorial series on using Haxe and NME a few years back before it was rebranded OpenFL, but haven’t really touched it much since.  Before jumping in to a Haxe game engine, I had to decide which game engine to jump into!  Part of my decision is going to be informed by a poll I’m currently running on Twitter.  Of course, it’s useful to take a current look at the Haxe game engine landscape.  I did a post entitled Choosing A Haxe/NME Game Engine three years ago, but simply put, a lot changes in 3 years!  So what follows is a quick roundup of the most popular Haxe based game engines and a quick blurb about each.  If I miss one, please be sure to let me know in comments below, on Twitter or via email!

Oh... and this is not a review in any sense of the word.  I have very little working experience with the majority of engines I am about to cover and have no informed opinion to share as a result!  They are also in no particular order unless you can consider “completely random” as a type of order!

 

Haxe Game Engines

 

 

Flash Engine Ports

 

HaxeFlixel

http://haxeflixel.com/

HaxeFlixel is an interesting story... it started life as a Haxe port of the popular Flash 2D game engine, Flixel.  Then, well, Flixel basically died and HaxeFlixel lived on.  In fact HaxeFlixel 4.0 was just released, while Flixel hasn’t been updated in years.  It is a complete 2D game engine for Haxe.

 

HaxePunk

http://haxepunk.com/

Wow, I could almost copy and paste the HaxeFlixel entry for HaxePunk.  It also started life as a Flash library port, and since lives on while it’s inspiration is no longer updated.  That said,FlashPunk is much less active than HaxeFlixel.

 

Haxeling(Starling Port)

https://github.com/Haxeling/haxe-starling

This one is more of a WIP than the prior two, and is a port of the popular Starling Flash library to the Haxe language.  There are limits right now such as the lack of an HTML5 target and a few missing features.  Starling is perhaps best known for being the framework Angry Birds was initially created in.

 

Away3D

https://github.com/away3d/away3d-core-openfl

A port of the Away3D 3D flash framework to the Haxe language.  One of the few 3D libraries that has model loading support out of the box (oddly...).  Obviously from the name, this is a 3D focused library.

 

Popular Haxe Frameworks

 

Kha

http://kha.tech/ || https://github.com/KTXSoftware/Kha

Kha is a low level framework whose design favors speed over other priorities.  It supports 2D and 3D but again is quite low level (so no model api for example).  Kha runs at the level similar to SFML, SDL or JGWL, with game engines built over top of it.  Such engines include:

KhaPunk || Cycles || Komponent2D || Kha2D

These engines work at a higher level of abstraction (further from the metal), making use of Kha to provide multimedia functionality.

 

NME

https://github.com/haxenme/nme

NME is the library that lead to OpenFL.  It is similar to Kha in that it provides low level cross platform implementation of the technical “stuff” that makes up a game, then more high level game engines are built on top of it.  Haxe became OpenFL, but it seems there was a community that want to see NME continue as it was, so NME seems to have some life as well.

 

OpenFL

http://www.openfl.org/

Starting life as an implementation of Flash API in a cross platform manner using the Haxe programming language.  Basically it allows Flash developers to seemlessly transition to Haxe development.  A number of engines are layered on top of OpenFL.  As mentioned above, OpenFL was originally NME, although they have no evolved in different directions.  OpenFL was used to make several commercial games such as Papers Please. HaxePunk, HaxeFlixel and Stencyl all are (or were) layered over top of OpenFL.

 

awe6

https://github.com/hypersurge/awe6

awe6 is awesome, but oddly never really seems to have taken off.  I’m glad to see that it’s still under development even if there isn’t much of a community around it.  awe6 is build around the idea of inversion of control (and dependency injection) and I really can’t do it justice in a single paragraph.  The lack of a community though makes this very much not an engine for people that aren’t able to solve problems on their own.  I did a closer look at awe6 years ago, and it should remain equally valid.

 

snowkit

http://snowkit.org/

This is one of the new kids on the block and a very cool looking collection of tools.  Snowkit is composed of flow – a build tool, snow – a low level media library, luxe – a game engine built on snow, mint – a UI library, linc – hxcpp bindings to several popular game libraries (SDL, OpenAL, etc) and hxsw a string/shader library.  The collection all together is snowkit and provides, with haxe, a complete framework for creating games.  It’s a cool concept, but it’s also much more complicated due to all the moving pieces.

edit—To clarify, snowkit is an umbrella term for all of the above mentioned technologies combined as well as the community around it.  The actual game engine is luxe, not snowkit.

 

lime

https://github.com/openfl/lime

Lime isn’t a game engine, it’s a cross platform media layer.  Basically OpenFL and other libraries/engines are built on top of lime.  It provides logic for windows, input, audio, rendering, networking, etc... in a cross platform manner.  Obviously it’s pretty low level.  Heck OpenFL is pretty low level and its over top of lime after all.

 

BabylonHx

http://babylonhx.gamestudiohx.com/

BabylonHx is a Haxe port of BabylonJS which I looked at in depth here.  I like BabylonJS, it’s a great Javascript game engine with a clean easy to understand design.  BabylonHx is an incomplete port of babylonjs...  how incomplete I do not know.

 

Cycles

http://cyclesgame.org/

This one I know very little about, but I am going to change that, because the concept sounds really cool.  Basically it integrates into Blender and uses Haxe (and under that Kha) as the programming language.  Basically you create your game world in Blender and code the logic in Haxe.  It’s similar I suppose to Blend4Web or BDX.  The choice of Cycles is probably a poor one though, as Cycles is the name of the modern renderer for Blender.  I am intrigued though... enough that I am going to download it now, so that’s the end of this list... ;)  EDIT- Doh... coming soon.  Boo

 

The Ones I Missed

And the following are my wall of shame, the engines I missed and various members in the community pointed out to me (thanks for that btw). 

 

Heaps

https://github.com/ncannasse/heaps

Heaps is a game engine by Nicolas Cannasse, who can basically be considered the father of the Haxe language, as well as CastleDB and other important Haxe projects.  Heaps was used to make Evoland 2.  It is a 2D and 3D game engine capable of targeting WebGL, Flash 3D, Mobile and Desktops using OpenGL.

 

Flambe

http://getflambe.com/

A 2D cross platform Haxe based game engine including tools for importing Flash animations, creating particle systems and glyphs.  Can target iOS, Android, Flash, HTML5 and desktop targets using Adobe’s AIR.  Open source and MIT licensed.

Did I miss any (that aren’t unsupported or extremely unstable)?  Which of these engines are you most interested in?

Programming

29. February 2016

 

HaxeDevelop, an IDE specifically for Haxe development has been released.

image

 

HaxeDevelop is sadly a Windows only IDE, and there is a good reason for this.  HaxeDevelop is ultimately a fork of the popular FlashDevelop IDE, which has long been the best IDE for Haxe development.  This fork obviously focuses heavily on Haxe related functionality.  Like FlashDevelop, HaxeDevelop is free and open source.

 

Some noteworthy features:

Project Managment

HaxeDevelop has built-in support for many workflows.
Of course all Haxe target platforms are integrated. You can also start using frameworks like OpenFL, Lime, Flambe, Kha, HaxeFlixel, Adobe Flash and Adobe AIR with the build-in project templates. You can create, customize and share your own project templates.

HaxeDevelop projects


Navigate in your code

The Outline panel gives you an overview of your code.
Click in the tree to jump in the code or open imported classes. Note that anywhere in your code you can also press F4 to jump to the declaration of the element at cursor position. To jump back, press Shift+F4 (also works after using a code generator).

HaxeDevelop class outline


Compiler integration

The rich type system of the Haxe Compiler in HaxeDevelop.
HaxeDevelop magically combines the Haxe Compiler Completion with the build-in completion service for lightning fast completion. See Haxe compiler errors in the Results panel - double-click on errors to jump to the reported error location.

HaxeDevelop errors and warnings


Organized settings

Tools > Program Settings

Many aspect of HaxeDevelop are configurable.
All program specific settings and the plugins settings are stored in a friendly searchable panel.

HaxeDevelop program settings


Task Panel

View > Task List

Keep track of your project state.
The Tasks panel help you track your project state: see what you have TODO or the BUGs to fix. If these are not enough; you can even add your own custom keywords.

HaxeDevelop task panel

GameDev News

16. February 2016

 

Flixel was/is a popular game engine written for the Flash programming language.  It unfortunately hasn’t been updated in many years.  However HaxeFlixel is a port of Flixel to imagethe Haxe cross platform programming language which is very much in fact under active development.  In fact, HaxeFlixel 4.0 was just released today!  This is also the biggest released they have ever done, so HaxeFlixel is still very much alive.

 

From the release:

We are proud to announce the release of HaxeFlixel 4.0.0! This is without a doubt the biggest release yet, with nearly 2000 new commits on the core repository alone since the last release.

The highlights of this release are:

  • an improved API structure
  • a refactored rendering system
  • a much improved gamepad API
  • improved HTML5 support
  • improved OpenFL Next compatibility
  • an improved debugger console (now using hscript) with auto-completion
  • over 20 new demos
  • ...and much more

For a more in-depth breakdown of the changes, have a look at our changelog. If you are mostly interested in the breaking changes to upgrade a project using HaxeFlixel 3.3.x, please refer to theupgrade guide.

We would like to thank all contributors who helped with this release in any way, as well as our Patreon supporters. Check out the Financial Summary 06/15 - 02/16 blog post on Patreon if you're wondering what we do with your donations.

Going forward, there are two things we want to foucs on:

  • A stable API - Breaking changes should be the exception and only happen in major releases. This also means following semantic versioning more closely.
  • More frequent releases - 4.0.0 took longer than it should have. We aim to have smaller releases in the future, but release more frequently.

The HaxeFlixel team

 

I know I’ve said this a few times, but I really do intend to do more Haxe content in the near-ish future.

GameDev News ,

31. January 2016

 

Kha is a cross platform, open source, cross platform game engine for Haxe developers.  Also, as was just recently covered, they also launched Kode Studio, an IDE for Kha and eventually Haxe development.  With all of these recent launches, they also just relaunched their website at kha.tech.  The new design is much cleaner and better organized:

image

 

I intend to do some more Haxe coverage in the future and was considering using Kha or Snowkit.  Which framework would interest you most?

GameDev News

 

Month List

Popular Comments