• ### What is your GameDev Story?

#### Archived

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

# Tile-problem

This topic is 6051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 38
• 16
• ### Forum Statistics

• Total Topics
634128
• Total Posts
3015693
×