

Still, this method seems clunky and slow. I could use those offsets to help in the world coordinate calculation. One way around this is the blit the whole map to a temporary surface, and then using an SDL_Rect (I am using SDL) I could blit the appropriate part of the map on to the screen, yet I wouldn't lose the coordinates I need because the current x and y offsets would be stored in the rect. For example, if you move far enough to the right, the screen would end up scrolling right, and then you would lose the calculation. Reason is because if the map is any larger than the screen, once you move over far enough on the map you would lose the correct world coordinate. The resulting two numbers is the world coordinate.Īt first glance this would work, and this is the method I used 3 years ago in my very early RTS game, however, when looked deeper into, it would not work at all. Use the same method to calculate how many tiles down the character is. Knowing the width of a tile, use division to calculate how many tiles over from the left of the screen the character is. The very first option that comes to mind is this: His world coordinate will need constant updating according to where he is on the screen. Let's say I have a swordsman walking across the map, for example. So I need a fast, efficient, low-cost way to convert from screen coordinates to world coordinates. Therefore, if it is any help in the end, essentially they can be cut into 4 right triangles. In essence, tiles look like diamonds when sitting alone and not with any other tiles. I am also using an isometric tile system. That hot spot will be used in all calculations for finding the world coordinate of that tree. For example, if I have a tree, I have a hot spot for that tree sitting at the bottom of its trunk. I have, however, learned much over the past 3 years and feel I can do much more with the RTS environment than I was able to do 3 years ago.ģ years ago I created a hacked up way of converting from screen to world coordinates, but it was messy, and sometimes got wrong answers, so I decided to come here before plunging into it. I started out making an RTS using DirectX 3 years ago, then I scrapped it to work on a 2d side scrolling game, then I scrapped that to work on a 3d mech game, and then I scrapped that to work once again on an RTS.
Opengl coords full#
It seems my game projects have finally gone full circle. Sometimes I managed to get a hacked up version of it working, but this time I wanted to consult the cboard and see if I could gain any wisdom in the process. It's always been a hastle trying to get it to work in my previous game projects. Eh.this seems to be a fun thing every programmer goes nverting screen to world coordinates.
