I talk about boulders, buttons, doors, portals, ladders, and wind! Lots of pretty pictures in this post!

Posted by joshyaxley on Jun 29th, 2015

Hello there! Firstly, I must apologise for the lack of any posting recently, I've had a busy week and a half due to finally graduating from university. However, I'll be back in full swing now!

Not the graduate we deserve, but the graduate we need.



In my last Dev Blog post, I talked about some of the staple types of platforms in platformer games. This blog is a continuation of that, except I'll be talking about some of the more interesting and dynamic objects that I included.

Boulders

From the start, I wanted to be able to add some 'puzzle'-esque types of obstacles in Faerie, and that led to the introduction of a 'movable block'. Seen as I was using a pre-built physics engine, the introduction of my boulders was very simple. All I had to do was make a new object, assign it a circular physics fixture, and then tell it to collide with practically everything.







The only thing that irritates me about my boulders is that they are (behind the scenes) perfectly circular. This means that they won't work exactly as a real-world boulder would, and makes them sort of 'slippy' and hard to stand on top of. They're still perfectly usable, as long as the player jumps off of them before they fall off, and I'll have to wait until testing to see how people handle them and if it's a problem.

The alternative would be to give them a polygonal shape, for example, by making them octagonal, and this was my first attempt at them. This, however, resulted in a lot of annoying collision nuances that I couldn't seem to get rid of, such as the Player getting stuck in the boulder if they collide at an angle etc. I tried several ways to fix these issues, but none of them were very effective, so I ending up using a circular fixture shape instead.

Buttons and Doors

My boulders could be used as ledges to get to previously unreachable places, but I wanted to give them another use, and hence I came up with the idea of including buttons.

A button would be an object in the floor that would activate whenever an object was above it. To code this, I simply used the collision_point function to check if any movable object was above it:

Using obj_DynamicParent meant that any child of obj_DynamicParent would activate the button, which included boulders and the Player object.

The button on its own was not very interesting, as it just turned itself off and on, but didn't do anything else. I needed to make another object that could link with the button, and change its own state based on the state of the button. I went for a door-type object.

In the room creation code, each door is assigned a particular button object using that button object's unique instance ID:

The door constantly checks the state of the button that it is paired with, and then updates its physical fixture based on this. The door starts off just like a wall, but, if its button is on, it updates its physics fixture so that it shrinks. Likewise, if its button is off, it updates its physics fixture so that it grows until it is a full wall again.

Now I had a system where a Player couldn't progress until they could cover a button with a boulder, and hence open the door to continue the level. The Player themselves could stand on the button and see the effect, but as soon as they stepped off of it, the door would close.





Portals

This addition was inspired (read: stolen) from Terry Cavanagh's VVVVVV, but they appear in many other games too. The idea is simple: enter one portal, and leave via another. However, my portals aren't just limited to the Player, and practically any object (including boulders and enemies) can be transported through the portal.

For example, here's a Spike Boulder that rolls indefinitely down a hill:







And here are some Spirit Flowers that fire out explosive Pollen Pellets which can fly through portals:







The portals (like the doors), are assigned a portal partner in their room creation code:

Then, on collision with a dynamic object, they change that objects x and y positions to coincide with the position of their portal pair:

An issue I first had was that as soon as an object was teleported, it would be colliding with the new portal, and so would be instantly teleported back to where it came from ad infinitum. This was easily solved by adding a boolean named active which determined whether the portal could be used, and setting it to false whenever an object came through the portal, and then back to true in an alarm.

I also added an option to have portals that reset the objects speed to zero, as this would be helpful in some cases (e.g. any portals near spikes might need precision movement, so carrying over your previous speeds might make things harder to judge).

And just like that, I had another way of making interesting levels!







Ladders

I touched briefly on ladders in an earlier blog post, and there really isn't much to them. The ladder objects themselves don't have any code, and all the interaction is handled in the Player object.

If the player is near to a ladder and presses 'Up', then they stick to the ladder:

The boolean variable 'ladder' is then used in other Player control code to limit whether or not they can move sideways or jump, as well as in a section of code that makes the Player 'stick' to the ladder:

This code makes sure that, if the Player is on a ladder, then they have the same x position as the closest ladder to them. The phy_speed_y=-0.2775 was included to counteract a bug which I talked about in this blog post.

Wind

The last thing that I'm going to talk about in this post is my wind (*insert fart joke here*). This object is very simple, and just applies an upwards force to any moving object that it is colliding with.







My next post will talk about making the Player able to attack, and giving them things to attack!

Also, it would be remiss of me if I didn't also include the video that I made of me playing through one of Faerie's current levels:

Demo will hopefully be ready in a week or two!

Feel free to follow me on your favourite social media!

Josh