• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Design Best approach for top down entering/exiting houses

M

MahakGTR34

Guest
I'm working on a top down shooter and wonder what kind of design most people use for entering/exiting houses etc?
What do you guys think is the smartest and most efficient way?

I was first thinking of just creating a new room upon entering a house but then I will have to deal with saving instance positions etc etc.

The other option is to have overlaying tilesets for houses and display them upon entering a house...

I possibly see up and downsides to both methods, what other options are there?

Would love to hear from your experience before I go down one road just to find out there was a smarter way to do it. Thanks.
 
Last edited by a moderator:

NightFrost

Member
Is it not feasible to make the house part of main map? That is, are your outdoors and house maps to different scales?
 
S

Sybok

Guest
Not sure that there is a best approach as such, just more which suits your coding style really.

For myself, I’d keep it as one room and hide the assets you don’t want to see and show what you do want to see. This approach is simple and doesn’t matter if the internals of the house are vastly bigger that what you see from the outside, like you see in many RPG games.

The best approach is whatever you prefer.
 
M

MahakGTR34

Guest
The house interiors are about 2 to 3x in size. As you won't be able to enter every house in the game (i.e. adjacent house from the one you can enter) it shouldn't be an issue with careful map planning.

Going forward this way is there anything special you guys think I need to pay attention to?
 

Yal

🐧 *penguin noises*
GMC Elder
Since you can make rooms essentially infinitely big, I'd say the easiest way to solve this is to put your house interiors out in the void and have doors teleport the player around the map on touch. The drawback is that whichever direction you put your interiors, that's going to limit how far you can extend the map in that direction layer, so you need to keep that in mind when planning your levels out. Also, enemy pathfinding might bug out if the player teleports into the void and they only chase you by position, so you might want to use instance activation to keep stuff that's offscreen in a deactivated state (which basically means they don't exist, so they won't run code - this is also an excellent way to have huge maps without slowdown) or potentially write your own pathfinding system that consider teleporter-doors to be directly connected when trying to find the path to the player (allowing them to chase you into buildings).


Here's another idea, though. You make the interiors using half as big objects (16x16 if your main objects are 32x32) and have a "indoors" variable which is toggled when you pass through a door. While indoors, all indoors objects draw themselves using the normal 32x32 sprites at 2x their position relative to the building you entered, and all outdoors objects (enemies, player, etc) move at half speed. So basically when you enter a ½-scale interior, the player shrinks to half their normal size, but everything is drawn at full size. So you basically expand the interiors to full size when you're inside them. This lets you put interiors inside buildings and have a seamless transition (including enemies going inside) but still have them be bigger on the inside.
 
H

Homunculus

Guest
Since you can make rooms essentially infinitely big, I'd say the easiest way to solve this is to put your house interiors out in the void and have doors teleport the player around the map on touch. The drawback is that whichever direction you put your interiors, that's going to limit how far you can extend the map in that direction layer, so you need to keep that in mind when planning your levels out.
A common solution to this problem is to place all the interiors in a single but different room, instead of the main world map. You can still apply the deactivation of off-screen interiors in that room as well.
 
Something I'm doing myself but haven't got round to yet due to a major set back with designing and drawing all my assets...

Have your main map on one layer and all your interiors on a layer beneath.

When entering house or building or area that's internal, code it so the top layer (external map) is hidden, thus revealing the layer beneath (internal map) and then when leaving the place, the top layer is unhidden again.

You'd have to ensure the map that isn't accessed is frozen and there's a bunch of code needed depending on what each room is for, to ensure memory is saved for each room entered so your player cant spam how many of one item they want by exiting and rentering over and over like the original Metal Gear Solid on the NES.

There's many ways to do this, so consider this another way.
 

Yal

🐧 *penguin noises*
GMC Elder
A common solution to this problem is to place all the interiors in a single but different room, instead of the main world map. You can still apply the deactivation of off-screen interiors in that room as well.
OP is aware of that solution and would rather avoid it because of the extra upkeep involved:
I was first thinking of just creating a new room upon entering a house but then I will have to deal with saving instance positions etc etc.
 
H

Homunculus

Guest
True, I thought the goal was to avoid having one room per interior, but reading it again that's not the case. Wouldn't making the room persistent solve this though?
 

Yal

🐧 *penguin noises*
GMC Elder
True, I thought the goal was to avoid having one room per interior, but reading it again that's not the case. Wouldn't making the room persistent solve this though?
It depends. Persistency works pretty well if you're only having one entrance/exit to each building (then you don't even need to store coordinates, when returning to the map the player can just keep being right next to the door they interacted with to enter the building) and if you can't save/load the game anywhere (there's some quirks with persistent rooms, like loading a newer version of the game not updating the rooms to match since it just saves a list of what's in the room). Also I don't think there's a way to turn off persistency from a different room, so if you want to e.g. go back to the menu, you need to change rooms to the persistent rooms and un-persistence them first.
 

Niels

Member
Maybe it's a idea to just make the walls + doorway of a house. and draw the roof as a object that gets turned invisible when it collides with the player?
 
Top