Hanging on Balloons

Posted October 25, 2017

One of the best things you can do for yourself in gamedev is to have good tools and an efficient workflow. I’ve already shown how I handle path movement in [Speer] in another post, now I want to show you another small trick I’m using to make level creation easier and quicker.

Note: As always this article will show how I’ve implemented it in HaxeFlixel, as that is the framework I’m using. The general idea however is framework-agnostic and can be implemented anywhere.

[Speer] features balloons that carry various items around the stages:


I’ve coded this system to be flexible, so as long as an object inherits from a certain class, it can be attached to a balloon and will be updated automatically. But how do I actually attach items to balloons? Well, the most intuitive way would be to actually, physically attach an item to a ballon, wouldn’t you say? I would, so that’s what I did. Enter hookUpBallons():

private function hookUpBalloons():Void{
            if (B.tileCoords.x == C.tileCoords.x){
                if (B.tileCoords.y == C.tileCoords.y-1){

This one might require some explanation. When the map data is parsed ( using HaxeFlixel addons, see this post for more info ) every Balloon that is created gets added to the Group grpBalloons. A Balloonable is an instance of a class that can be attached to a balloon, and those are saved in grpBalloonables.

Once all entities have been instantiated and added to their respective groups, I call hookUpBallons() in my PlayState. The function then loops through all Balloons and all Balloonables and checks their position in the tilemap; if the Balloonable is one tile below the Balloon, it gets attached to that balloon. Note: tileCoords is not a HF-internal property, but it basically just takes an object’s x and ypositions and converts them to tile coordinates in the current map.

So when I position the items like this…


…then the items will be attached to the balloons in-game:


However, if I move an item just one tile to the right…


…it’ll fall down as soon as the game starts:


And that’s pretty much the whole secret. This way I don’t have to set any IDs or explicitly make any connections. I can just intuitively do what I want done: Attaching an item to a balloon. It’s little things like this that make game design not only more efficient but also more fun.

Take It to the Next Level!

Become an excellent patron on Patreon and snatch yourself some kickass perks such as early access, early builds, exclusive updates and more!

You will also be added to the Wall of Excellent People!

Want To Buy Me a Coffee?

Coffee rules, and it keeps me going! I'll take beer too, though.

Related Posts

PogoGirl Devlog #30: The Game Is Released!

| [PogoGirl] [PC] [Devlog]

A mad scramble to the finish line.

PogoGirl Devlog #29: Scrap Brain

| [PogoGirl] [PC] [Devlog]

A mad scramble to the finish line.

PogoGirl Devlog #28: Release Date!

| [PogoGirl] [PC] [Devlog]

The Day of Pogo is imminent!

By using the Disqus service you confirm that you have read and agreed to the privacy policy.

comments powered by Disqus