Hi all!
More Challenge LevelsI've continued to work on content this week, including a couple more
Challenge Mode levels. These are pretty quick to create, and are a fun way to explore different uses of the game's mechanics, or harder challenges involving them, that wouldn't easily fit into a normal level.
One of the new levels involves kicking macas into boost rings to hit blocks and collect shells:
This clip is from the end of the challenge where I got a lucky chain reaction:
Rotating PlatformsI showed these platforms last time. I'd like to make more effort to keep this devlog interesting, and thought that going into more detail about how these platforms work would be good.
AnimationThe animation for the platform feels quite smooth, but there's a few factors that made it easier to animate than it might look at first.
To start with, the shadows and highlights aren't added until the animation is all done. The top and bottom edges of the platform also don't animate while it spins. This means the animation can be done using just two colours, yellow and purple.
Since the chevron pattern repeats with alternating colours, the second half of the animation is actually just a copy of the first half, with the yellow and purple colours swapped. As a very basic example, here's a single frame with the colours alternating. It doesn't really work as an animation as there aren't enough frames to indicate which way the platform is spinning - you can force your brain into thinking its rotating to the left or the right. (The yellow chevron looks a bit like Pac Man if you imagine him moving to the right.)
Adding a single frame - and a copy of that frame with swapped colours - turns it into a four frame animation, which looks much better.
Finally, adding another two intermediate frames (and again, copies of those frames with swapped colours) makes the animation feel very smooth.
I didn't draw all the animation frames perfectly from the start - it was definitely a process of just tweaking pixels until it looked smooth. Since I only had to worry about two colours, rather than a lot of detail, tweaking the animation was fairly painless to actually do.
General MechanicsThe idea of the platform is that rolling on it (but not walking on it) will rotate it.
As the platform rotates, the entities on it will move in the same direction. It works simply like a conveyor belt, if the platform is rotating to the right, then all entities on the platform also move to the right and eventually fall off the platform. This doesn't make physical sense - in reality if the platform was spinning the entities would just move in circles - but for a 2D game it feels like it works fine to model it as a conveyor belt.
The platform moves up and down as it rotates, which will be described later. For now we can ignore this.
How Fast to Rotate?This works by looking at all the entities that are standing on the platform, checking if they're rolling, and if they are, then looking at their X velocity. From these velocities, we need to calculate a target rotation velocity for the the platform. The platform builds up towards that rotation velocity over a short time. If nothing is rolling on the platform, it will gradually decrease the speed back to zero.
Single EntityIf there's a single entity rolling on the platform, this is easy. For example if Leilani is rolling at a velocity of 7.5 units per second, the target rotation velocity of the platform is set to -7.5 units per second. Once the platform reaches its target velocity, the conveyor-belt-effect of the spinning platform will counteract Leilani's movement, and keep her in place. This is useful for gameplay purposes as you can rotate the platform for a long time without worrying about falling off it.
Multiple Entity - Adding VelocitiesIf there are multiple entities rolling on the platform, we have the problem of deciding how to combine their velocities.
The solution I started with was to add up all the velocities of the rolling entities. This works well when two entities are rolling in opposite directions on the platform - their velocities will cancel out, and the platform won't rotate, which is the desired outcome:
However, if two entities are rolling in the same direction, adding their velocities together results in the platform rotating twice as fast as either of them are rolling. The conveyor effect of the platform will then cause at least one of the entities to fall off the platform. It doesn't feel right:
Multiple Entity - Averaging VelocitiesThe next version of the calculation was to average the velocities. This fixes the previous case - the two entities rolling at the same velocity will be held in place by the conveyor effect:
However, if the entities are rolling at different velocities, the platform will rotate at a speed partway between the two. Neither will be held in place, since one is rolling slower than the platform's conveyor effect, and one is rolling faster:
Multiple Entity - Adding Extreme VelocitiesThe final version of the calculation is to take the highest positive velocity, the highest negative velocity, and add those together. This fixes the previous case by giving priority to the fastest of two entities rolling in the same direction. In practise, the fastest entity is usually Leilani, so it seems fair to hold her in place on the platform, while the other entity moves:
If two entities are rolling in opposite directions, they'll both be taken into account - because the highest velocity in each direction is added together - so their speed can still be cancelled out, the same as before.
During gameplay these situations are probably not likely to come up very often. But, if they do, the platform's behaviour will hopefully feel fair to the player.
Vertical MovementAdding the vertical movement to the platform is simple (given that the game engine can already handle moving platforms). Every frame, the platform's Y velocity is set based on its rotation speed, causing it to move vertically.
The platform can be setup with limits on its movement. Once it reaches the limit, it'll no longer move in that direction. As discussed in the previous devlog post, the platform also rotates more slowly when it's reached its limit. This is done by simply halving the target rotation speed calculated for the platform. If Leilani is rolling at 7.5 units per second, the target rotation speed for the platform will be -3.75 units per second. The platform's conveyor effect will no longer be strong enough to hold Leilani in place, only to slow her down.
Variations - Screw DirectionThe platform has some variations. The first is one with the opposite screw direction, indicated by the chevrons on the platform pointing in a different direction, and the appearance of the background screw being different.
Chances are that I won't actually use this variation in the final game. During normal gameplay, I imagine that most players are never going to pay attention to the direction of the chevrons, and instead would just feel a general confusion that the platforms don't behave how they expect. I'd prefer that the player just internalises the fast that rolling to the right makes the platform move upwards.
Variations - OrientationThe platform can also work rotating vertically instead of horizontally. This is basically exactly the same. The main difference gameplay wise is that Leilani is the only entity that will be able to interact with the platform; when enemies roll into a wall they either die or rebound off the wall. Leilani is the only one to slide down the wall in a way that could rotate the platform.
It's worth noting that Leilani can only rotate these platforms in one direction, when she's sliding
down the wall. This felt 'right' to me, as Leilani isn't indicated as having any grip on the wall during brief periods where she's rolling upwards on the wall. It's only when she starts to slide down the wall that she is really gripping it.
This brings up an interesting point - I previously described that the rotation speed of the platform is calculated by looking at the velocity of all the rolling entities. In fact, it's up to each individual entity to decide whether it's in a state where it can affect rotatable platforms. Thus the Leilani entity is able to make its own decision that it can rotate these types of platforms when sliding down a wall, but not when sliding up it.