Jump to content
  • Advertisement
Sign in to follow this  
game of thought

Using tiles for more than just maps?

This topic is 2300 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 wanted to see what you thought of my idea for a tile engine. Would it be possible to make the individual tiles instances of a worldwide tile class?

Eg say you have a map with walls and floor, these both inherit from the base tile class and do certain things like load their picture and run a separate collision sub routine within the class to check if the characters Or enemies etc have hit it and then perhaps have collision logic within the class ( so like you hit a wall the collision logic would be not to allow you to move through the wall).

Would this put to much strain on system resources or would it be difficult to implement. If there is also an already made engine with something like this already implemented please let me know.

Thank you for your time

Share this post

Link to post
Share on other sites
its not a good idea to keep a copy of the sprite that each tile represent instead you want to keep just a index of the tiles, what you should do its create a class that works like an atlas and load all the sprites once so you keep just 1 copy of the img, also its not a good idea to test collision against all the currents tiles in the map.

for example if you are going to make the map SIZEX and SIZEY and lets say that you have N tiles images stored in an class call obj.

the class obj could load all the imgs and keep them in a vector or an array for example.

vector<obj> images;

the map is an array of for example short map[SIZEX*SIZEY];

each slot of the array will represent an index to the atlas images array,

lets say that the first tile is grass ID 0 second dirt ID 1 and stone ID 2

the map should be {0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,2,2,2,1,1,1,0,0...

at the moment of rendering the map you will just get the current index in the map and get the image from the atlas with that index.

regarding collision as a said not a good idea to test all the map

read this topic, i alrdy posted something related to collision


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!