View Full Version : RTS Game Example viewable area

Casey Abernathey
03-18-2013, 01:03 AM
I am trying to expand upon the RTS Game example. I am trying to figure out how to make the "camera" show a subset of the map. Instead of compressing or stretching the map background to the current window, I want to pan around the map only showing a subarea. See the image below:


So if you imagine that the blue highlight area is the only visible portion of the background. Then I want to add logic that if the cursor hits the edge of the screen, I will move the viewable area.

Casey Abernathey
03-19-2013, 03:09 AM
I think I understand enough about textures to fill up a "map" and I am experimenting with one large texture that is much larger than my viewable area. However, I'm not sure how I would change the "view port" or area of the texture that I can see.


The closest thing that I have come up with is translating the CL_GraphicsContext. The immediate downside I see is that the cursor position isn't translated for clicking on sprites.


Resolved the cursor position by doing some translations from screen to "world" positioning. I seem to have issues with the "fog of war affect" I must be failing to push or pop the matrix at the right time.

03-21-2013, 06:59 PM
Hi there, you need a camera class I believe. Take a look at mine and see if you can make some sense of it. Good luck!