Drawing Problems...

BlitzMax Forums/BlitzMax Beginners Area/Drawing Problems...

po(Posted 2007) [#1]
I've got a basic RTS map with different minerals, fog, and a minimap. I have it set up as a 100x100 grid of 32x32 tiles. The only tiles drawn are the minerals and the fog, the 'grass' is not drawn as a tile but just as a big rectangle in the background. I originally used Plot() for my minimap, but with 100 tiles this was too slow so I sorted the minerals into clusters. Basically the top-left mineral tile in each cluster is recorded as 'clustx' and 'clusty', and depending how many tiles are in the cluster, it's width and height are set to 'clustwidth' and 'clustheight'. I then draw at the top left of the screen all the clusters, where one tile is one pixel. Ignore the fact that all minerals are drawn from the start even though they havn't been found yet.
My problem is: As you move to the right of the map, it appears that the minerals clusters on the minimap are disappearing, but that are actually being drawn underneath the minerals and fog. This doesn't make sense as not all the clusters disappear, most of the ones on the right do not. Also, I am drawing the clusters in the minimap [b]after[b] drawing the minerals and fog. Why is this happening and how do I fix it?
Sorry for the lack of comments, I tried to simplify it from the version I originally had.



-Thanks


Jesse(Posted 2007) [#2]
you are giving the answer to your problem. What you need to do is draw the minimap separate after everything else is drawn not while drawing other parts of the maze. I modified your draw routine to draw the map first then the minimap:
	Method Draw()
	
		SetColor(0,100,0)
		DrawRect(0,0,GraphicsWidth(),GraphicsHeight())				
	
		For Local x:Int=0 To width-1
			For Local y:Int=0 To height-1
				If x>=offx/tilesize And x<=(offx+GraphicsWidth())/tilesize Then
					If y>=offy/tilesize And y<=(offy+GraphicsHeight())/tilesize Then
						If x<width And y<height Then Tiles[x,y].Draw(x,y,tilesize)
					EndIf
				EndIf	
											
			Next							
		Next
		For Local x:Int = 0 To width-1
			For Local y:Int=0 To height-1
				tiles[x,y].drawcluster(x,y)
			Next 
		Next
		If offx<0 Then offx=0
		If offx>width*tilesize-GraphicsWidth() Then offx=(width*tilesize)-GraphicsWidth()
		If offy<0 Then offy=0
		If offy>height*tilesize-GraphicsHeight() Then offy=(height*tilesize)-GraphicsHeight()
	
	End Method



po(Posted 2007) [#3]
Ahhh... That was dumb of me. That's how I originally had it but I thought it was too slow.. But I'm getting mixed up.
Thanks :)