Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Determining Inside<->Outside House

This topic is 5813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want the two walls nearest to the player to open when someone enters a house, but how do I determine when someone is inside or outside a room?

Share this post

Link to post
Share on other sites
if you have a tile class/struct or similar you could assign each a unique identifier to determine if it is part of a building or not.

if the user is within the parameters of said tiles

set to transparent/dither next layer up of tiles on map which are within said co-ordinates(ie the wall). if you have a roof just kill of the next layer up too.

you might want to decide if you want to be able to see into adjoining rooms as well, or just the room you are in.

Im sure theres a better way, but thats the first method that springs to mind. hope it goes well.

Share this post

Link to post
Share on other sites
You can try giving every room an ID and all the tiles within that room are assigned that ID, with the outside world being 0. When a player moves over a tile, they are assigned that tile''s room ID. When rendering, only render the walls that are not on the tiles that are assigned the same room ID that the player currently has.

It works really nice and is easy to implement. Writing a map editor is a bit trickier for this type of thing because you will need a way to mark a tile as belonging to a certain room.

You could also get away with using a single byte (or less) since chances are you''re not going to have 255 rooms on the screen at the same time. The IDs do not have to be unique in the entire world, just unique so that no sets of rooms that can be seen at the same time will have the same one.

For example, a house may have 5 rooms (IDs 1, 2, 3, 4, 5). Another house elsewhere on the map can use the same IDs since you''ll never render the rooms in the first house the same time you render the rooms in the second house.

Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!