RTS screen scrolling

BlitzMax Forums/BlitzMax Programming/RTS screen scrolling

BugZilla(Posted 2006) [#1]
I am having trouble programming a screen that scrolls using the standard RTS method of moving the mouse to the edges of the screen. I had code for BlitzBasic that worked, but that used the Origin command that doesn't seem to exist in BlitzPlus. I did some searches on the forums but strangely could not find anything.

Any ideas? I also need to be able to select objects in the gameworld so some type of offset would need to be added to the cursor to make it match up to the world coordinates.


Curtastic(Posted 2006) [#2]
Keep trying and you'll probably figure it out.
Heres the basic idea from drawing the map with smooth scrolling. 11x11 is the amount of tiles in view at any given time, not the size of the array.
For fory=1 To 11
	For forx=1 To 11
		
		mapx = forx + screenx / tilesizex
		mapy = fory + screeny / tilesizey
		
		tile = array[mapx,mapy]
		
		drawx = forx * tilesizex - screenx Mod tilesizex
		drawy = fory * tilesizey - screeny Mod tilesizey
		
		DrawImage tile.image,drawx,drawy
	Next
Next