Array tile map and tiles properties

Subscribe to Array tile map and tiles properties 4 posts

avatar for tonikovacic tonikovacic 13 posts
Flag Post

Hello community.
I am in process of making prototype for a new game. I am using tile based map system, so i have array 20×15 which represent map, 0 is floor, 1 is wall, 2 is laser, 3 are doors, etc..
My question is how can i edit parameter of each tile in a way that they are represented in array map. Should I use object for tile properties or there is better way?
I want to achieve that my tiles are customizable so that i can have some lasers thar can rotate and some that cant, etc…

 
avatar for feartehstickman feartehstickman 521 posts
Flag Post

You could give each type of tile its own custom class. Not sure how resource intensive that would be though.

 
avatar for DrYoshiyahu DrYoshiyahu 678 posts
Flag Post

If one laser can rotate and another can’t, I would give them the same class, and just make a boolean to define whether it can or can’t rotate. You’ll need a different number in your array for each type though. (3 for stationary laser, 4 for rotating laser)

 
avatar for Drakim Drakim 1146 posts
Flag Post

If you want each tile to be able to hold a bunch of information, you’ll need to make each tile an object yes, since if you save the tile as an Int you wouldn’t be able to stuff anymore information in there (unless you use some trick like having a second array for tiledata).