Jump to content

Ways to implement Zelda-like rooms


OddPotion
 Share

Recommended Posts

Hey everyone. Lately I've been screwing around with a Zelda-like room system and I wanted to see how others would tackle it using Phaser.

Right now I just have a Tiled tilemap that has 2 layers, one for the background and one for collisions, and a player sprite. On update() I check the players position and set the cameras target position to match the bounds of the "room" the player is in and the camera slides over into place, very similar to the 2d Zelda games like the originial Zelda NES, Links Awakening, Oracle of Seasons/Ages, etc. It works extremely well, even with a huge tilemap with background, collision and object layers. The only problem is that the tilemap is really just one large room and the view into the room just snaps to certain places as the player walks around. Basically it's an illusion of rooms using the camera. All entities in the world exist and are updated even if they are in a different "room" or even on the opposite side of the map.

I've researched a bit and so far I feel I have a few ways:

1) Deactivate all entities that are off screen. Basically just stop rendering them and remove the physics body, AI, etc. There is a way to do this in Phaser api though I can't remember the function call right now. This way all entities are still existing in the game world, but are just not taking up cycles rendering or updating them. A con of this I think would be that with a lot of entities in the world just turning off it's render and update doesn't free up memory because the entities are never actually destroyed.

2) Basically when loading the tilemap create a separate pool of entities for each type of object on the map, but deactivate all of them. Keep a current_room property on all entities. When the player transitions to a new screen it's current_room prop is updated and then check all entities to see if it's current_room prop is the same as the players current_room, meaning they are in the same room, and if so deactivate all entities and activate the entities that are in the same room as the player.

3) On the tilemap set enemy spawn points in certain locations. There is a sprite pool for enemies_on_screen and when a player moves into a new room the enemies_on_screen are deactivated and we check through all spawner tiles on screen and spawn an enemy on that tile and push it into the enemies_on_screen. This way would be most similar to Zelda NES. The player enters a room and enemies spawn in a random location.

There are of course other ways I'm sure. I guess what I'm trying to figure out is how to structure the game world/rooms/etc. I don't like how "open" the game world is and how little structure my current system puts on rooms. But I like being able to design the whole overworld map at once in Tiled. I think if I would have to design each room separately and then fit them into place during runtime would drive me crazy. xD Any advice would be greatly appreciated! And I'm sorry if my thoughts seem jumbled, I've been up for too many hours and caffeine levels are dangerously low...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...