Jump to content
  • Advertisement

Archived

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

Ironmax

Tile-problem

This topic is 5864 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

Hello, I was wondering if I could get some help with this tile-thingy Im building.. Look at the picture here: http://www16.brinkster.com/ironmax/tilegralle.gif The picture shows 3 simple test-tiles which seems to end up the wrong way from my 10*10 array: char map[MAP_SIZEY][MAP_SIZEX] = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 2, 2, 2, 2, 2, 2, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 2, 0, 0, 2, 0, 0, 1}, {1, 0, 0, 0, 2, 2, 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}, }; If you can see, the tiles seems to be drawn the wrong way in the y-axis, still they are accurately turned to the camera.. I am lost. Here''s the draw function: for(int y = 0; y < MAP_SIZEY; y++) { for(int x = 0; x < MAP_SIZEX; x++) { tile = map[y][x]; glBindTexture(GL_TEXTURE_2D, texture[tile]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(float(x), float(y), 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(float(x + 1), float(y), 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(float(x + 1), float(y + 1.0f), 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(float(x), float(y + 1.0f), 0.0f); glEnd(); } } Im sure there is some minor typo I''ve put down, but I don''t know what, this is my first experiment with tiles, sorry for the messed up code.

Share this post


Link to post
Share on other sites
Advertisement
To me it looks like you have the way your ortho mode is set up not the way you wanted...looks like your orgin 0,0 is bottom left and you probably want it top left try
glOrtho(0.0f,width, height, 0.0f, -1.0f, 1.0f);
and see if that helps you.

Share this post


Link to post
Share on other sites
Thanks, didn''t think about that, I was using perspective followed by gluLookAt from my last project

But now another problem occured.. all the tiles end up in one tiny heep in the top left corner :/

Share this post


Link to post
Share on other sites
ahhh, forget it, due to lack of sleep my mind isn''t working as supposed.
I simply have to increase x and y by 64 each tilechange, instead of 1..
Thanks anyways

Share this post


Link to post
Share on other sites

  • 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!