Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

tile mapping

This topic is 4609 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 have a template map that i load into my program. I have a 2 dimensional array of numbers that represent the number tile to be used in the BIG map. how would i create a "CreateMap()" function that iterates through the array and draws each tile onto a surface (or other thing), then when rendering comes, draw just the one surface onto a quad and use that as the BIG map?

Share this post


Link to post
Share on other sites
Advertisement
Please look at the articles section and try to find the answer there first. If you don't find it, please let me know as I'm considering writing article about tile-based games.

Sorry, I've misread your post (thanks Drew_benton for letting me know[smile]).
It is not a good idea to do that in OpenGL as the texture is probably going to be huge. Instead, use many quads and setup your texture to contain unique tiles.
Use the texture coordinates to select the actual tiles.

Cheers,
Pat.

Share this post


Link to post
Share on other sites
i used to do that, but when my engine calls for a rotation and scaling feature for a layer, it would be extremely hard to calculate every quad and rotate and scale them appropriately... so i just figured if i can draw them onto one quad and just draw that one quad i would be good.

Share this post


Link to post
Share on other sites
You could just use glRotatef() and glScalef() for rotating and scaling the quads, I don't see how that's complicated at all [smile].

Share this post


Link to post
Share on other sites
well, for my layer class, i have of course the 2-dimensional short array. each specify the number tile to use for the layer. i use only one vector specifying the top left corner of the entire layer. when this is rotated about a certain point within the layer, i need to recalculate where the top-left corner would be so when it is to be rendered again and the camera is somwhere in the middle of the layer, it would look like the camera is spinning in place (when actually the layer is rotating in relation to where the center of the screen is.

i can do all that with only one coordinate, but when i need to recalculate EVER quad... that's just overwhelming...

Share this post


Link to post
Share on other sites
Quote:
Original post by EvilKnuckles666
well, for my layer class, i have of course the 2-dimensional short array. each specify the number tile to use for the layer. i use only one vector specifying the top left corner of the entire layer. when this is rotated about a certain point within the layer, i need to recalculate where the top-left corner would be so when it is to be rendered again and the camera is somwhere in the middle of the layer, it would look like the camera is spinning in place (when actually the layer is rotating in relation to where the center of the screen is.

i can do all that with only one coordinate, but when i need to recalculate EVER quad... that's just overwhelming...


This is what the modelview matrix is for. Every vertex you draw gets translated by it. How exactly you do this is dependant on how you currently specify your quads' coordinates, but most likely (your quads are in absolute or "world" coordinates) you'll want to push the matrix, translate to the reference point of the layer, scale, rotate, and translate back to the origin (the negative of your reference point) prior to your usual drawing code (prior to the drawing of the entire layer, NOT every quad). Then at the end of the drawing, you would want to pop the matrix, to restore it for future layers.

Share this post


Link to post
Share on other sites
wow.. i never thought of that.. i really need to get used to OpenGL. i'm still a little used to how DirectX works.

so wait, all i need to do is draw my quads as if they start from 0,0 and make it soom like they're even with the screen and untranslated except push a matrix with the correct rotation, scaling, and translation and OGL will do it all for me?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!