Have been continuing the improvement to core mechanics. This weeks focus...
TubesI originally showed tubes in the devlog
around a year ago, and to be honest I've barely made any use of them in my level design experiments since. They were a bit limited in terms of gameplay and also a total pain to place in the level editor, so I have totally changed the way they work (it's all brand new code).
Past TubesThe old tubes were basically an entrance and exit point which were linked, but there was no concept of actually travelling along the tube. In the editor I had to manually place the visible tiles, and then place entry and exit game entities on top of that, and finally give the entry and exit points ID numbers so they knew how they should link together.
This meant a single tube required different info on 3 different layers, so it was really awkward to make changes or move them around the level.
Plus, since the game entities were just teleported from the entrance to the exit - with a fixed delay period - you don't really get a sense of the entity moving through the tube. It also didn't cope with multiple entities being in the tube at the same time.
The camera has to move quickly to keep up with Leilani when she suddenly appears at the exit of the tube.
Present TubesThe new tubes are inspired by
Mario 3D World's clear pipes.
I started the new tube implementation by deciding how I want to edit the tubes in the editor. (This is always a good way to start a new feature as making the editing easier is always worth it in the long run, even if it means more code work right now). Drawing lines to represent the tubes seemed to be the easiest way. So there's a new layer called Tubes, and any lines drawn on there will be turned into tubes automatically!
(By the way, the editor I use is
http://www.mapeditor.org/)
So, the game reads in these lines and splits them into a number of straight tube segments. It forms junctions where the straight segments meet, and links them together. Entities now have a bespoke bit of code for travelling through tubes, during which they traverse along tube segments until they reach an end point. It's nice to build the idea of tubes into the core entity behaviour rather than hacking it in at a higher level like I did previously. It means any entity type in the game can potentially travel through tubes without requiring much more work from me.
The tube bulges to show where entities are inside the tube. I will need to improve the way the bulge is drawn - it's not very nice at the moment how it just disappears when going around a corner in the tube. I'm not sure how to approach that yet.
I'm pleased with how it turned out! I think this will be way more flexible for me to use, and more fun for the player too.
A little bonus feature.. the bulge in the tube can bump enemies and blocks that are next to the tube! You can see Leilani also get bumped by the tube in the previous gif.
Future TubesThere are some other features I could add. I'm thinking of allowing Leilani to enter vertical tubes from the top (currently she can only roll into the side openings of tubes). Since she can dig into soil blocks from above, it seems silly that she can't enter tubes that way.
I could add three-way or four-way junctions where the player can hold directions to alter which path is taken. I could also add things like one-way tubes with gates on the end that prevent you from going back in (although in most cases just using a downwards-facing tube exit would achieve the same thing).
Finally I need to handle the case where two entities meet each other when travelling along the tube in opposite directions. I will probably just make them bounce off each other and reverse direction, unless a spiky enemy meets Leilani in which case it should also hurt her as normal.
Think I've written enough! Thanks for reading!