NeilRoy

Members
  • Content count

    10
  • Joined

  • Last visited

Community Reputation

102 Neutral

About NeilRoy

  • Rank
    Member
  1. Isometric tile selection

    Another idea I had was to do your normal tile check, but start at the top most layer. You do a check like you would on the base layer of your map. Only for each layer above that you obviously take into account the offset of the tiles in the Y direction. So, you start at the top most layer your map supports, and check the tile at your mouse position on that layer, if there is no tile on that layer, than you check the next layer down and continue this until you run into a tile at that position. This seems to make the most sense to me. You could even have a variable that keeps track of the highest layer that a tile exists on so you wouldn't have to check all the possible layers, only the one starting at the highest layer that is being used and working your way down. You could even further optimize this by dividing your map into zones, keeping track of the highest layer used in that zone.
  2. Isometric tile selection

    Ray casting, yeah, that's actually how I came up with the solution. I was thinking along the lines of raycasting, only I had Wolfenstein style games in mind, so I started to think of how I could apply that idea to Isometrics, and that was when I came up with this. It's not exactly ray casting, but... close enough. My original idea was to start at the bottom of a map and walk one tile at a time "up" until you reached the right position, al-la-ray casting, that's when it hit me, why not just compare the drawn tile for the detected position with the mouse pointer... I do like it when there's a good programming problem like this. Edit: Hmmm, I think my "ray casting" from the bottom of the screen may still be the best bet... I still haven't started to program this, I'm too scared to. ;D I probably should though. Edit2: Ahh, I just checked out that link and I see what you mean about wave surfing. I was just thinking about doing just that when I checked that link out and it was similar. I guess I need to learn to check links sooner .
  3. Isometric tile selection

    One idea I have played with was to do a normal detection, then check the tile's position on screen with the position of the mouse pointer and then just "walk" towards the pointer. If the tile is north of where the pointer is located, than check the tile south, then repeat this until you have a match. I figure you wouldn't have to do much more than a couple tests. And of course, if where you're clicking is a valley instead of a mountain, than the mouse pointer would mostly likely be north of the tile detected on the first pass and you would then walk 1 tile at a time north. I haven't implemented this yet, but it seems like it might just be the best bet.
  4. Isometric tile selection

    I've been working on creating an Isometric editor, mainly just to teach myself how to program Isometrics. So far it's been pretty good, I have a workable editor running and am finally done all the code I needed to get basic editor working, I can add in hills, roads etc... like in SimCity 2000. But now that I am ready to start programming it for layers, like being able to create large hills like in SimCity 2000. in the SC2000 editor you can raise the land up so you have really high hills and it automatically adjusts the terrain around it until you have some pretty large hills. I have no problem doing that, but, once they are created, how then would you select the tile at the top of the hill? I have code to select tiles on a normal map consisting of one layer, but once the hills get too high, you're pointing in an area that would be mistaken for a normal tile at the base layer under it with my current code. Here's a screenshot to demonstrate... [img]http://home.cogeco.ca/%7Eno.spam2/SC2000.png[/img] Now how would I know that the tile on the top of this hill was for a location closer to the viewer than the tile that exists behind it at a lower level? I've seen lots of tutorials online but none that cover this subject. Thanks in advance.
  5. LoadGLTextures() crash

    Just to update, I compiled my program and this crash ONLY happens under Windows 7 64bit. When I run the same program under Windows XP 32bit it runs fine.
  6. LoadGLTextures() crash

    Than you better talk to NeHe because that is straight out of his code, not mine. That is his comments, and this code compiled up fine on Windows XP. It still does if I don't try freeing memory all the textures show up just fine proving something IS being loaded (or I wouldn't see the textures, now would I?). Like i said, I didn't write that code or comment, that was from NeHe's code.
  7. I recommend Taking your project that worked, and deleting some of the code so you have just some basic stuff in there you will use for most any project. Then save it as a template so you can use it to create new projects in the future that are already set up to work properly.
  8. Dev-c++ examples don't work in Windows 7

    I used to use Dev-C++, I highly recommend switching to Code::Blocks. It has an option to import Dev-C++ projects and it looks and feels much the same, only with some features you'll probably like better. Also, Dev-C++ hasn't been worked on in many years. Like Dev-C++, Code::Blocks also uses (or can use) MinGW. With that aside, I have gotten many projects compiled with Dev-C++ and NeHe code with no problems.
  9. LoadGLTextures() crash

    I just got into programming again after a bit of a break from it. My operating system has changed and I moved from using WindowsXP to Windows 7 64bit. I loaded up some old code I had worked on and it now crashes in the following code: If I comment out the code that attempts to free TextureImage it crashes, but runs fine if I comment that out (but obviously that then creates a leak). The textures load and display just fine, no problems so long as I comment that out. It never used to crash before. OS: Windows 7 64bit Compiler: Code::Blocks with MinGW 4.5.2 It used to work when I used Windows XP and compiled this with Dev-C++ (MinGW 3.4.2 I think it was). The code itself was never changed by me between then and now. Any ideas? [code] int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator int i; AUX_RGBImageRec *TextureImage[7]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*7); // Set The Pointer To NULL // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit TextureImage[0]=LoadBMP("Data/grass.bmp"); TextureImage[1]=LoadBMP("Data/FlatRoadNS.bmp"); TextureImage[2]=LoadBMP("Data/FlatRoadEW.bmp"); TextureImage[3]=LoadBMP("Data/FlatRoadSE.bmp"); TextureImage[4]=LoadBMP("Data/FlatRoadSW.bmp"); TextureImage[5]=LoadBMP("Data/FlatRoadNW.bmp"); TextureImage[6]=LoadBMP("Data/FlatRoadNE.bmp"); Status=TRUE; glGenTextures(7, &texture[0]); // Create The Texture for(i=0; i<7; i++) { glBindTexture(GL_TEXTURE_2D, texture[i]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data); } // It crashes when it tries to free memory here, if I comment this out, it runs just fine. for (i=0; i<7; i++) { if (TextureImage[i]) { if (TextureImage[i]->data) free(TextureImage[i]->data); free(TextureImage[i]); } } return Status; // Return The Status } [/code]
  10. I'm curious if you ever solved this? I realize this was quite a while ago but I am having similar problems. It's in the section of code that frees up the memory alocated to hold the textures. The code is slightly different than yours but I think it's probably the same cause whatever that may be. I commented out the section that frees up the memory allocated and it works just fine (all textures loaded and displayed fine). This used to work on Windows XP, but crashes if you try and free memory now on Windows 7. The code never changed, just the operating system. (windows 7 64bit). [code] int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator int i; AUX_RGBImageRec *TextureImage[7]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*7); // Set The Pointer To NULL // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit TextureImage[0]=LoadBMP("Data/grass.bmp"); TextureImage[1]=LoadBMP("Data/FlatRoadNS.bmp"); TextureImage[2]=LoadBMP("Data/FlatRoadEW.bmp"); TextureImage[3]=LoadBMP("Data/FlatRoadSE.bmp"); TextureImage[4]=LoadBMP("Data/FlatRoadSW.bmp"); TextureImage[5]=LoadBMP("Data/FlatRoadNW.bmp"); TextureImage[6]=LoadBMP("Data/FlatRoadNE.bmp"); Status=TRUE; glGenTextures(7, &texture[0]); // Create The Texture for (i=0; i<7; i++) { glBindTexture(GL_TEXTURE_2D, texture[i]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data); } /* for (i=0; i<7; i++) { if (TextureImage[i]) { if (TextureImage[i]->data) free(TextureImage[i]->data); free(TextureImage[i]); } } */ return Status; // Return The Status } [/code]