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!

Want sneak peeks and early access to stuff? Join my Patreon!

Become a Patron!
Just Want to Buy Me a Coffee?
Get Words in Your Inbox!

Be oldschool and sign up for my newsletter to get updates! Just enter your email address, prove you're not part of Skynet and you're good to go!

Powered by CleverReach. I will not send you spam or sell/give your email address to someone else.  You can of course unsubscribe at any time. By clicking the subscribe button above, you confirm that you have read and agreed to our privacy policy.

Related Posts

PogoGirl Devlog #5: SAGE: Aftermath

SAGE has come and gone, and I’m still reeling from how quickly it all happened. I guess the only thing to do is to pick through the rubble and try to make sense of everything! First off, I knew from the beginning that Go! Go! PogoGirl wouldn’t set SAGE on fire. It’s the Sonic Amateur Games Expo after all, and people mainly want to play Sonic games. Hell, I used to mainly want to play Sonic games.
Read More

PogoGirl Devlog #4: Road to SAGE 2020

On September 5th 2020 the virtual doors of the Sonic Amateur Games Expo will open for the 20th time, and Go! Go! PogoGirl will be a part of it! If you haven’t heard yet, I will publish a public demo of the game for everyone to try out. Naturally this is very exciting for me (and I hope for you too) but naturally, this also means work. A lot of work.
Read More

PogoGirl Devlog #3: Shiny Shiny Gems

Collectibles are as much a part of platformers as actual platforms. Whether it’s Sonic’s rings, Mario’s coins or Banjo’s notes, it seems like platformer worlds don’t have littering laws because these things are everywhere. And that’s good, because it’s really fun to collect them and sometimes they even help you out. Extra life, anyone? So of course Go! Go! PogoGirl will also have collectibles. After some thinking I settled on gems, because…I dunno, they look pretty and sparkly and coins are pretty overdone.
Read More

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

comments powered by Disqus