Jump to content
  • Advertisement
Sign in to follow this  
Ralphzehunter

Tiles

This topic is 5129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!