Sign in to follow this  
Ralphzehunter

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 this post


Link to post
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 this post


Link to post
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.
Sorry about my double posted thread. I thought that a moderator had to delete it.

Thanks a lot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this