In preparation of Ludum Dare 30, I decided I wanted to do a 2d platformer game in haxe, and since I like HaxePunk (and it can read data from the free level editor Tiled) I decided to take go with it.
But however much I like HaxePunk (and the tiled integration) it has a few limitations that bothered me, and after some research I decided to create a custom fork to be able to mess around with it as much as I needed.

In this post I will show what features I have implemented. If you are interested then check out the code from Github (instructions further down) but be warned. I have only spent a few hours on this to get it to state that will work for me. Use it on your own risk!

 

1. The github repo for my modified code (note that it resides in a branch called “tiled”):

https://github.com/Tommislav/HaxePunk/tree/tiled

 

2. Merge of libraries:

Because I knew what I will need, and to get started faster, I have merged a couple of different libraries together.

 

3. Parallax scrolling:

parallax

Tiled does not support parallax layers, but it does support custom layer properties.
I changed it so that if you set layer properties “scrollx” and “scrolly” then we will get the parallax scrolling seen in the image above. Although not in Tiled itself… only when running in haxe.

This is how you set layer properties by the way

 

layerproperties

 

4. Cloud platforms

cloud

A type of platform not supported by HaxePunk where you only detect collision from above. So you can jump up on it from below without hitting your head, but stand on it.
The way I do this in Tiled is that I use a custom layer for collisions, and custom “collision-tiles” (that I won’t draw in the game).
Set a custom tile-property of “type=cloud” on your cloud tile and go ahead.

This is how you set tile properties in tiled:

tileproperties

 

5. Behaviour Trees

I added this library for convention.
If you’re unfamiliar with behvaiour trees this is a good read: http://obviam.net/index.php/game-ai-an-introduction-to-behavior-trees/

 

6. Check out my code and use it

Feel free to check out the code and use it, but bear in mind that I’ve only modified it to the point where it will work good enough for me during this competition. You’ll get the code AS-IS.

  • Download the source with git by opening the terminal and write:
    git clone git@github.com:Tommislav/HaxePunk.git
  • navigate into your newly created project directory:
    cd haxepunk
  • then make sure to switch to the correct branch:
    git checkout tiled
  • Now create a new openfl-project (in a new directory)
    openfl create project name_of_my_project
  • Open settings.xml and add the folder you just checked out as a regular source folder:
    <source path=”../HaxePunk-fork” /> (use correct path)

To load the tiled-data: just use the original instructions on HaxePunk/tiled (https://github.com/HaxePunk/tiled). You should be able to use it in the exact same way, only with my added features.

Disclaimer!

I have only modified the code to the point where it “just works”.
These changes are not ready for any kind of pull-request back into the main library by a longshot. That would force me to do a lot of cleaning and probably research as well. I’m happy enough with this version. Feel free to use it if you like.

If you have any questions about this, or if you actually end up using it, then please let me know.

Untitled-2


Leave a Reply

You must be logged in to post a comment.

[cache: storing page]