Legacy GM In Game Object Building Rooms

R

Raven The Comic

Guest
Im trying to make a tycoon game and i made the building system and i want to know
Is there a way in game to make if obj_wall make a Square and there filled out by obj_floor and there a at least one obj_door to create crate obj_room fill out the Square?

pls help
 

Attachments

A

arirish

Guest
There totally must be. It seems like it would be something like a series of checks, checking if each wall is connected to the next (and then back to the first), looking for a door colliding with one of those walls, and then if so drawing a rectangle from x,y of the upper wall to x2,y2 of the lower wall.
 
I

icuurd12b42

Guest
you can code your room start and perform analysis of the layout I guess. but really a lot of work to save 15 seconds in the room editor
 
A

arirish

Guest
I think he's trying to set it up so the player can draw the walls wherever they like, and if they form a closed square, fill it in and have the game recognize it as a building.
 

Rob

Member
The method I used was click and drag, and the player placed the doors themselves afterwards (on valid tiles).

When the player clicks, starting x/y is saved and then when mouse is released, end x/y is saved and floors are placed down in that rectangle. Walls are then tiles automatically around the floors. It seems the easiest way to me. I'm sure you can come up with something if you mess around.

You don't need to place tiles as objects either. If you're using a grid you can just change the value in the grid (or array) and have the grid draw everything.
 

NightFrost

Member
To detect encolsed spaces you'd need to write a flood-fill style detection, using Djikstra for example. Even then if tile placement is completely freeform you'd face the problem of intelligently choosing a spot where to start the detection. If player places wall tiles in some random shape, it would be difficult to tell where is the inside and where is the outside, to start checking for enclosed space. Giving a rectangle draw tool as suggested above to shape buildings is a much more straightforward option, and you can always allow expanding them with the same tool by overlapping rectangles. Also, unless the size of the building affects their functionality, you'd be better off avoiding this headache by giving the players a list of buildings with predefined footprints.

Edit - have you ever played Dward Fortress? I just recalled it has a different approach to defining buildings / workspaces / areas. You can build walls and dig caves and set doors, but if you don't go further than that they're just partitioned spaces with no special functionality. When you want to define a use for an area, you go to another menu and tell the game "I want to place A THING at A SPOT!" and it gives you a selector you point at wherever. You can expand the selection area (initially just a single tile) vertically and horizontally, and it intelligently detects walls and doors and won't expand beyond them. When you ok the selection, those tiles will be marked as whatever thing you wanted. You can also use the tool in inverse, to chip away pieces from an existing definition. By separating building and definition phases the game doesn't need to work with any complex mechanisms.
 
Last edited:
Top