Jump to content

  • Log In with Google      Sign In   
  • Create Account


Using tiles for more than just maps?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 game of thought   Members   -  Reputation: 212

Like
0Likes
Like

Posted 29 August 2012 - 04:12 AM

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

Sponsor:

#2 Exessuz   Members   -  Reputation: 141

Like
0Likes
Like

Posted 29 August 2012 - 07:35 AM

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

http://www.gamedev.net/topic/630073-map-coordinates/

#3 game of thought   Members   -  Reputation: 212

Like
0Likes
Like

Posted 29 August 2012 - 10:07 AM

Thanks




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS