Archived

This topic is now archived and is closed to further replies.

Loading maps...Please Read!! :)

This topic is 5588 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 am making a small isometric tile engine in OpenGL. Would it speed up the framerate if I were to load my maps from files, instead of looping and placing a 50x50 map each time it draws the scene? If so, could you please get me started on how to load the file. I want the map file in this format: X: 10 Y: 10 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 I know how to get the X and Y information, but I need help on how to extract the numbers. Each number represents an image from the tileset. Example, 0 = grass and 1 = rocks. Thanks, Matt Utley AOL IM™ : MeBeMrMkay E-mail: trifaze_matt@lycos.com If thispost = 0 Then GoBack() Else Read() End If

Share this post


Link to post
Share on other sites
It would slow down the frame rate if you were to load the map from a file each frame. It is a better idea to have the map (or parts of it if the map is very large) in memory so that you can access the data more quickly.



The hackers must have gotten into the system through the hyperlink!!

Invader''s Realm

Share this post


Link to post
Share on other sites
"instead of looping and placing" - I''m not sure what you mean. Do you mean you''re creating the map every frame?

Anyways, if your tiles are stored into an array, saving and loading them is just as easy as saving or loading single variables. Are you using fstream, or something simular? A variable is something like "file.write(&var,sizeof(int))". To save an array, it would be like so: "file.write(var,sizeof(int)*number_of_array_entries)"

"I know how to get the X and Y information, but I need help on how to extract the numbers. Each number represents an image from the tileset. Example, 0 = grass and 1 = rocks

It all depends on the method you use to store your tiles. If it''s a single array, just "*(tileptr + x + (y * map_width))".

Share this post


Link to post
Share on other sites