Game Mechanics (solved) Floor problems: tiles or objects or what?



Hi there.

So I'm making this game that will take place in randomly generated houses, but I'm fairly sure I can add the random generation aspect to it later. I'm just trying to make a house that will have all the features the game has to offer first, adding random generation last. All I have so far is a little avatar dude who runs around and a scrolling camera for him.

I'm trying to get floors done first, but I have a problem. Each section of floor should have properties and code, but tiles won't store code and that many objects isn't good. I also have to keep it open to random generation later, so it can't just be a one-time solution. What would be the best way to go about making a floor like this?

Thanks in advance, this is my first time here.


You could use a ds_grid to denote the sections and their appropriate value that corresponds to the type of floor ect.
Get the type of floor the player is in contact with from the ds_grid, then use a switch to execute the appropriate code.

Grids are also very handy in general when generating levels/areas.

Hope that helps!



Forum Staff
In situations like this, I like to use data structures like grids to provide a basic grid layout to hold tiles in and JSON files that I decode into maps (or lists, if you don't mind sacrificing a bit of flexibility and ease of access for slightly higher performance), which are then referenced in each grid cell, to store tile-specific information. Maps and lists don't store code, either, but you could have them store information like the background the tile's graphic is stored on, the exact location of the tile graphic on the background, the solidity of the tile... etc. etc. in them, then parse them and react accordingly from within other objects.

That's just because I like the systems I work with to be as flexible and easy to use/adapt as possible from the get-go, though. For now, I suggest to go with what you're most comfortable with. If you do end up running into performance issues, you can always go back and try out more efficient methods.


Thank you both, grids are exactly the type of thing I was looking for. I had no clue they existed. This should help with wayyyy more than the floors as well. Thanks!