Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

139 Neutral

About Lucky808

  • Rank
  1. Hi all,   I'm currently working on an isometric tile based game and got stuck on collision detection with impassable tiles. The map is built with Tiled editor by using a collision layer marking all the impassable tiles (i.e. wall, tree...), and at the beginning of each level the map is processed and the collision tiles get parsed into a 2D array holding the X,Y tile coordinate from the map. My player character is free to roam around the map, his movement is pixel based not tile based. In my other orthogonal tilemap games, I've been using a bounding box on my player to check for collision against collideable tiles by converting the 4 corners of his bounding box to X,Y tile coordinates and check them against the 2D collision array. This has been working great in orthogonal maps but not at all in isometric maps. I dont want to have to check player's bounding box against each collideable tile's bounding box due to the complexity of the map. I rather leave that method to player vs moving objects type of collision detection. Is there any way to tweak the code or coordinates system and still be able to use my existing method (it doesn't need to be pixel perfect)? Is there a better way to do this?   Thanks for any advise!      
  2. Hi all,   I'm using Tiled qt map editor for making my isometric maps and i have a question for those who is more experienced. how can i create elevation effects on map? for example if the tile set is consisted of 64x32 tiles. how can i stack wall tiles to make them look really tall? i tried using layers but it didn't work. do i need to use multiple tile sets which contain "tall" tiles?   thanks for any insight!
  3. i got it to work. it turned out that i had assigned the wrong z-values to tiles. how stupid of me. thanks for the help though.
  4. i got it to work. it turned out that i had assigned the wrong z-values to tiles. how stupid of me. thanks for the tips though.
  5. Hi,   I've been trying to create an isometric tilemap based game and got stuck for several days on sprite rendering. Just want to check with guys if my approach is even viable. Can I render everything in flat 2D quads (using x,y,z-axis) and still be able to use openGL's depth buffer to automatically sort objects based on their z-value? or must I render everything in cubes?   So far I've got the isometric maps to render correctly (in glOrthf() projection ). Each tile is rendered using a quad (x,y,z for each vertex). For each object on map,  I'm using a formula to calculate its z-value: z = -(map_width + map_height )+ (mapX + mapY), z-value is calculated based on the tile the object is sitting on. The player's z-value is updated as he moves around the map.  However, my player sprite and objects are not overlapping correctly. whenever he is standing is front of an object, the top half of the player sprite gets overlapped by the object. on the other hand, when he is behind objects the image is rendered correctly.    What could be the problem? Do I need to render everything in cubes?   Thanks for any input!          
  6. I tried glGetError() and got an error code 1280, which is GL_INVALID_ENUM. my understanding is that this code can be ignored, right?
  7. Yes I have.   here is how I initialized openGL. do you see any issues with them:     if (!depthRenderbuffer){ glGenRenderbuffersOES(1, &depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, framebufferWidth, framebufferHeight); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); }     glViewport(0, 0, rect.size.width , rect.size.height);        glMatrixMode(GL_PROJECTION); glLoadIdentity();   glOrthof(0, rect.size.width, 0, rect.size.height, -1024, 1024);   glMatrixMode(GL_MODELVIEW); glLoadIdentity();     glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepthf(1.0f); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);   glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0);   glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_BLEND);   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   Thanks.
  8. Hi all,   I'm having trouble to get z-buffer to work properly on my isometric tile map. (using glOrthof() projection) I've created and bound a depth buffer and enabled it. however during rendering, it only seems to work properly when my player character is walking behind other objects on the map. however, whenever the character gets in front of an object, the overlapping part between character and object does show up, meaning the entire object gets rendered and my character gets cut off from where the overlapping starts. I'm stuck with this problem for 3 days and couldn't figure out why. any help is much appreciated!    
  9. You were absolutely right! i forgot to update my aMatrix array to [16]. Thank-you! Now that the app would run ok, but the z-buffer doesn't seem to work properly. Half of my player character's image got overlapped by other objects even when it has less z-values than the other objects. any idea why? (overlapping only happens when player is placed in the front. player hides himself properly when placed behind objects).   Thanks in advance!
  10. Thanks for the tips. I've recreated it in 4x4 matrix but it causes my app to crash every time I run it. did I do it right? please take a look:   4X4 matrix:       aMatrix[0] =  1.0f; aMatrix[1] =  0.0f; aMatrix[2] =  0.0f;  aMatrix[3] =  0.0f;     aMatrix[4] =  0.0f; aMatrix[5] =  1.0f; aMatrix[6] =  0.0f;  aMatrix[7] =  0.0f;     aMatrix[8] =  0.0f; aMatrix[9] =  0.0f; aMatrix[10] = 1.0f;  aMatrix[11] = 0.0f;     aMatrix[12] = 0.0f; aMatrix[13] = 0.0f; aMatrix[14] = 0.0f;  aMatrix[15] = 1.0f;   Translation:       aMatrix[12] = aPoint.x * aMatrix[0] + aPoint.y * aMatrix[4] + aPoint.z * aMatrix[8] + aMatrix[12];     aMatrix[13] = aPoint.x * aMatrix[1] + aPoint.y * aMatrix[5] + aPoint.z * aMatrix[9] + aMatrix[13];     aMatrix[14] = aPoint.x * aMatrix[2] + aPoint.y * aMatrix[6] + aPoint.z * aMatrix[10] + aMatrix[14];    transform the vertices:   aTransformedQuad->vertex1.geometryVertex.x = aQuad->vertex1.geometryVertex.x * aMatrix[0] + aQuad->vertex1.geometryVertex.y * aMatrix[4] + aQuad->vertex1.geometryVertex.z * aMatrix[8] + aMatrix[12];     aTransformedQuad->vertex1.geometryVertex.y = aQuad->vertex1.geometryVertex.x * aMatrix[1] + aQuad->vertex1.geometryVertex.y * aMatrix[5] + aQuad->vertex1.geometryVertex.z * aMatrix[9] + aMatrix[13];     aTransformedQuad->vertex1.geometryVertex.z = aQuad->vertex1.geometryVertex.x * aMatrix[2] + aQuad->vertex1.geometryVertex.y * aMatrix[6] + aQuad->vertex1.geometryVertex.z * aMatrix[10]+ aMatrix[14];           aTransformedQuad->vertex2.geometryVertex.x = aQuad->vertex2.geometryVertex.x * aMatrix[0] + aQuad->vertex2.geometryVertex.y * aMatrix[4] + aQuad->vertex2.geometryVertex.z * aMatrix[8] + aMatrix[12];     aTransformedQuad->vertex2.geometryVertex.y = aQuad->vertex2.geometryVertex.x * aMatrix[1] + aQuad->vertex2.geometryVertex.y * aMatrix[5] + aQuad->vertex2.geometryVertex.z * aMatrix[9] + aMatrix[13];     aTransformedQuad->vertex2.geometryVertex.z = aQuad->vertex2.geometryVertex.x * aMatrix[2] + aQuad->vertex2.geometryVertex.y * aMatrix[6] + aQuad->vertex2.geometryVertex.z * aMatrix[10]+ aMatrix[14];           aTransformedQuad->vertex3.geometryVertex.x = aQuad->vertex3.geometryVertex.x * aMatrix[0] + aQuad->vertex3.geometryVertex.y * aMatrix[4] + aQuad->vertex3.geometryVertex.z * aMatrix[8] + aMatrix[12];     aTransformedQuad->vertex3.geometryVertex.y = aQuad->vertex3.geometryVertex.x * aMatrix[1] + aQuad->vertex3.geometryVertex.y * aMatrix[5] + aQuad->vertex3.geometryVertex.z * aMatrix[9] + aMatrix[13];     aTransformedQuad->vertex3.geometryVertex.z = aQuad->vertex3.geometryVertex.x * aMatrix[2] + aQuad->vertex3.geometryVertex.y * aMatrix[6] + aQuad->vertex3.geometryVertex.z * aMatrix[10]+ aMatrix[14];           aTransformedQuad->vertex4.geometryVertex.x = aQuad->vertex4.geometryVertex.x * aMatrix[0] + aQuad->vertex4.geometryVertex.y * aMatrix[4] + aQuad->vertex4.geometryVertex.z * aMatrix[8] + aMatrix[12];     aTransformedQuad->vertex4.geometryVertex.y = aQuad->vertex4.geometryVertex.x * aMatrix[1] + aQuad->vertex4.geometryVertex.y * aMatrix[5] + aQuad->vertex4.geometryVertex.z * aMatrix[9] + aMatrix[13];     aTransformedQuad->vertex4.geometryVertex.z = aQuad->vertex4.geometryVertex.x * aMatrix[2] + aQuad->vertex4.geometryVertex.y * aMatrix[6] + aQuad->vertex4.geometryVertex.z * aMatrix[10]+ aMatrix[14];    Thanks for any comments!
  11. Hi,   I need help figuring out how matrix works in this example the custom defined identity matrix as follows:       aMatrix[0] = 1.0f; aMatrix[1] = 0.0f; aMatrix[2] = 0.0f;     aMatrix[3] = 0.0f; aMatrix[4] = 1.0f; aMatrix[5] = 0.0f;     aMatrix[6] = 0.0f; aMatrix[7] = 0.0f; aMatrix[8] = 1.0f;     then here is the translation transformation:         aMatrix[6] = aPoint.x * aMatrix[0] + aPoint.y * aMatrix[3] + aMatrix[6];     aMatrix[7] = aPoint.x * aMatrix[1] + aPoint.y * aMatrix[4] + aMatrix[7];     the last piece to transform the vertices:       aTransformedQuad->vertex1.geometryVertex.x = aQuad->vertex1.geometryVertex.x * aMatrix[0] + aQuad->vertex1.geometryVertex.y * aMatrix[3] + aMatrix[6];     aTransformedQuad->vertex1.geometryVertex.y = aQuad->vertex1.geometryVertex.x * aMatrix[1] + aQuad->vertex1.geometryVertex.y * aMatrix[4] + aMatrix[7];          aTransformedQuad->vertex2.geometryVertex.x = aQuad->vertex2.geometryVertex.x * aMatrix[0] + aQuad->vertex2.geometryVertex.y * aMatrix[3] + aMatrix[6];     aTransformedQuad->vertex2.geometryVertex.y = aQuad->vertex2.geometryVertex.x * aMatrix[1] + aQuad->vertex2.geometryVertex.y * aMatrix[4] + aMatrix[7];          aTransformedQuad->vertex3.geometryVertex.x = aQuad->vertex3.geometryVertex.x * aMatrix[0] + aQuad->vertex3.geometryVertex.y * aMatrix[3] + aMatrix[6];     aTransformedQuad->vertex3.geometryVertex.y = aQuad->vertex3.geometryVertex.x * aMatrix[1] + aQuad->vertex3.geometryVertex.y * aMatrix[4] + aMatrix[7];          aTransformedQuad->vertex4.geometryVertex.x = aQuad->vertex4.geometryVertex.x * aMatrix[0] + aQuad->vertex4.geometryVertex.y * aMatrix[3] + aMatrix[6];     aTransformedQuad->vertex4.geometryVertex.y = aQuad->vertex4.geometryVertex.x * aMatrix[1] + aQuad->vertex4.geometryVertex.y * aMatrix[4] + aMatrix[7];   Now, I understand so far they only apply to X-axis and Y-axis. Can someone please tell me how I can implement Z-axis into this code.   Thanks in advance for any input!  
  12. Lucky808

    Isometric tilemap rendering

    Ok, think I will go with placing my scene in a 3D space. In that case, how do I set up the z value for each tile on an Isometric tilemap. x and y position are determined by their index from an 2D array.(X increases towards southeast, Y increases towards northeast) something like:             vertex1.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);               vertex1.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);               vertex2.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);               vertex2.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);               vertex3.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);               vertex3.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);               vertex4.geometryVertex.x += (aTileCoord.x + aTileCoord.y) * (aTileSize.width/2);               vertex4.geometryVertex.y += (aTileCoord.x - aTileCoord.y) * -(aTileSize.height/2);   what should I put in for z?
  13. Lucky808

    Isometric tilemap rendering

    Yes, the objects were loaded without z-axis values. do they need z values for rendering in an isometric tilemap? also, i tried implementing glTranslatef() into my rendering routine but made no difference. the moment i changed the 2nd last parameter to 1 in glOrtho() the screen went blank again :(
  14. Lucky808

    Isometric tilemap rendering

    Thanks for the tips. however as soon as I adjust the second last parameter to 1.0,  the screen becomes blank. i don't see anything being rendered.
  15. Hi all,   Has anyone read the book "Learning IOS Game Programming"? I'm current using the rendering method (for Orthogonal maps) taught in the book in my new game. I've successfully converted some of the code to work with Isometric tilemap. However, I hit a road block when it comes to rendering objects on the map in the right order. I'm using 3 map layers. (1.ground, 2.grass, 3.wall and trees). I render the first 2 layers, then the player object, then the 3rd layer. However I could not get it to render objects in correct orders. i.e. a player standing in front of a tree should show up as such, meaning the tree should be rendered 1st then the player. I've implemented a depth buffer and set up the following:             glOrthof(0.0f, rect.size.width, 0.0f, rect.size.height, 0.0f, 100.0f);             glEnable(GL_DEPTH_TEST);         glDepthMask(GL_TRUE);         glDepthFunc(GL_LEQUAL);         glDepthRangef(0.0f, 1.0f);           glClearDepthf(1.0f);         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   But objects are still not being rendered in the correct order. If someone who is familiar with the rendering method in that book can you please point me to the right direction. Any input will be appreciated!   Thanks in advance.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!