Friday, 15 March 2013

tile - C++ 2D Array Map for Tiling Output Inverted -


I created a 2D array that displays the map for my tiles:

 < Code> int esap [12] [20] = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1}, {1, 0, 1, 0, 1, 0 0, 0, 0, 0, 0, 0, 0, 1, 0 , 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, , 1, 1, 1, 0, 0, 1}, {1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 1}, {1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1}, {0 , 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 0, 1}, {1, 1, 1, 2, 2, 1 , 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0 , 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1} };   

Once my tiles have been loaded, I do this by using the function () to do the tiles:

 For  (int y = 0; y and lt; 12; y ++) for {// (int y = 11; y> gt; = 0; y -) {for (int x = 0; X {20 for x ++} {// (int x = 19; x> = 0; x -) {if (sMap [y] [x] == 1) GlobbeltTextings (GL_Edit DD, brick 1 ); Otherwise if (asmap [or] [x] == 2) globinated (GL_TEXTURE_2D, brick 2); Second globinated (GL_TEXTURE_2D, wall); GlBegin (GL_QUADS); GlTexCoord2f (0.0 f, 0.0f); GlVertex3f (float (x), float (y), 0.0 f); GlTexCoord2f (1.0f, 0.0f); GlVertex3f (float (x + 1), float (y), 0.0 f); GlTexCoord2f (1.0f, 1.0f); GlVertex3f (float (x + 1), float (y + 1), 0.0 f); GlTexCoord2f (0.0f, 1.0f); GlVertex3f (float (x), float (y + 1), 0.0 f); GlEnd (); }}   

For some reason, my map is inverted ... (hence the top map is the line below the digits screen But the top line of the tile and the second line on map is the second line of tile on the screen).

Its my understanding, you repeat by selecting each digit and specifying the correct tile I have tried to change the x / y but it will rotate the map on the screen So that its <12> x is 12 tiles and y .

I want my tile on the screen to represent the map above. Any way to fix it? Thank you. The fact is that the OpenGL is actually in the coordinate system that is in the point (0, 0). It is in the lower-left part of the viewport, so if you want to draw the matrix in the same way it should attract it, then you should & lt; Viewpoint height & gt; As for drawing, y coordination must be calculated. - (calculated) How to achieve that height - it is up to you, perhaps you have defined it in the code first. For example, float (y + 1 + offsety) will be float (HEIGHT - (y + 1 + offsety)) .

Edit

for (int y = 11; y> gt; y = ); Y -) {

Instead of the external beginning of the loop and this is the same. But, anyway, it is good to know that this is not inverted by mistake as you thought - it's just for synchronizing the system.

No comments:

Post a Comment