Door Mechanics


In Melkhior's Tower, doors are just regular entities with 4 additional properties:

  • Target scene
  • Target X position
  • Target Y position
  • Direction faced when appearing from the door

Doors are not linked to other doors, they don't need to be. When a door is hit, the player is simply transported to the target room and position. It doesn't matter where they came from.

The actual door entity is invisible during play, and normally sits inside the door alcove, surrounded by entities that make up the door frame. When the player hits the entity, the current scene is changed to the target scene, the player entity is placed at position X, Y and then turned to face the specified direction. They will almost always be facing the same direction, but there are edge cases where this may not be the case, so being explicit about it ensures they appear in the correct place.

The video below shows the door mechanics in action, with the door entities made visible and the target room being the same room, just to make it clear what's going on.

To avoid blocking, a door threshold entity is added at runtime. Player entities can walk over this threshold, but other entities cannot be moved into it. The threshold ensures that when the player spawns in the new room, there can never be an object blocking the way that cannot be moved. The video illustrates this. Princess Ashby is unable to push the barrel right up to the door because the threshold entity is in the way, but she is able to walk up to the door. The image below is an overhead view of the entities that make up the scene in the video:


It is possible to block a door spawn point by placing one of the player characters in the way. In this case, the block will be detected and the player will not be able to use the door. If this were ever to occur, the player would simply switch to the character blocking the way and move them.

The image below shows how a simple scene looks in the editor, with the door entities visible, and an overhead view showing exactly how the scene entities are positioned:

Finally, locked doors are achieved by simply placing a gate entity in between the door frame uprights, and just in front of the actual door entity. The gate entity has no connection to the door entity, it's just in the way of the player hitting the door.

Comments

Log in with itch.io to leave a comment.

Thanks. Where you refer to "the editor" is that your own tool or a Playdate development thing?

It's a custom tool I've written myself, specifically for Melkhior's Tower. It's a Windows application written in C#/Monogame. There's more info about it in this previous post: https://bitglint.itch.io/melkhiors-tower-playdate/devlog/1326794/map-editor

Thanks for the link. Interesting read too.