# Tiles

## Recommended Posts

I'm making a tile-based RPG, and I was wondering, should I make a structure for the tiles, or should I use many arrays. For example(In VB, I haven't learned the equivalence of structures in C++): Structure: Structure tile pictouse as integer 'an integer telling me which tile to put down walkable as boolean 'whether or not is boolean event as integer 'integer containing if an event is there, and which one it is End Structure Arrays: Dim tilepic(10,10) as integer Dim tilewalkable(10,10) as boolean Dim tileevent(10,10) as integer All of my tiles will be of the same size, so I won't have to worry about the x, y, width, and height of my tiles. So which would be faster? Or are they both around the same thing. Btw, how do you do structures in C++?

##### Share on other sites
They should both compile to virtually the same code, so neither will be faster. I would use structures as it keeps the related elements together.

In C++ you could implement this as:

struct{    int   pictouse;    bool  walkable;    int   event;};

Also, please delete your double posted thread. Just click edit on your post and theres a checkbox right at the top to delete it.

Alan

##### Share on other sites
Thanks Alan, that's what I was looking for. I'll use structures because they seem more organized and easier to work with than many arrays. Thanks for the C++ part, too.

Thanks a lot!

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628298
• Total Posts
2981890

• 9
• 9
• 11
• 10
• 10