a few questions about a tilemap and a camera

BlitzMax Forums/BlitzMax Beginners Area/a few questions about a tilemap and a camera

Hello Again.

Well I have been working on my scrolling map for some time now and have made progress and have come to this problem. I added an OffSetY to my map and have my player at the bottom of the map where I want him to be so I will move up the map decreasing my Y and my OffSetY as I move along. I have the up movement down good except messing with the scroll speed which is no problem. My problem occurs when I want to move down the map which increases my Y and my OffSetY. I have tried it many different ways using an if statement along with the direction variable to either increase or decrease my OffSetY depending on my direction. If my direction is > 90 but < 270 I need it to increase OffSetY , or if my direction is >270 but < 90 I need my OffSetY to decrease to scroll the other way. It works fine by my first line of code in the if statement but when I rotate my player to go the other way the map still scrolls in the original direction( if I am making any sense ). For the life of me I can't understand why its doing it either, if I rem out the second line of my if statement it still does the same thing. I suspect that somehow I have my if statement wrong and it isn't reading the parameters of the Direction Variable or something that is probably easy or obvious such as that .

If anyone has any insight as to what I am doing wrong or what needs to be done to get the scrolling correct with using my Direction variable I would really appreciate the advice/help. Thanks in advance.

Here is a copy of my players type and the input with the if statement in the up arrow key is the part I am refering to.


Type TPlayers Extends TGameObjects
           
    Global List:TList
    Global Image:TImage
  
	Field Direction = 0 
	
		    
	Function Create()
	    
	    Local player1:TPlayers = New TPlayers
	    If List = Null List = CreateList()
	    List.AddLast player1 
	
	    If Not Image 
	      Image = LoadImage("gfx/player1.bmp")
	    End If			
		 
	EndFunction
	
	
	Method New()
	    
	    X=350
	    Y=550
	
	End Method
	
	Rem
	    
		
	End Function
    End Rem

    Method Draw()
		SetScale .4,.4
		SetRotation(Direction)
		DrawImage(Image,X,Y)
		SetScale 1,1
		SetRotation 0
		DrawText " Direction is .." +Direction,0,56
		DrawText " X is ..." +X,0,70
		DrawText " Y is ..." +Y,0,84
		MidHandleImage (Image)
		
    EndMethod
		
    Method Update()
		   Draw()
		
        Local movespeed# = 1.5
        Local turnspeed# = 1.0

          
	
	        If KeyDown(KEY_LEFT)&KeyDown(KEY_MOUSERIGHT)
		      
		      X:-Sin(Direction-90*movespeed)
		      Y:+Cos(Direction-90*movespeed)
		
		      	 
	        Else If KeyDown(KEY_LEFT)
		      Direction:- turnspeed
		      If Direction<0 Then Direction:+360 
	        End If
		
            If KeyDown(KEY_RIGHT)&KeyDown(KEY_MOUSERIGHT)
		      
		      X:-Sin(Direction+90*movespeed)
		      Y:+Cos(Direction+90*movespeed)
			
			  
	        ElseIf KeyDown(KEY_RIGHT)
		      direction:+ turnspeed
		      If Direction>360 Then Direction=0
	        End If
	
	        If KeyDown(KEY_UP)
		      
		      X:+ Sin(Direction)*movespeed
		      Y:- Cos(Direction)*movespeed
		
		         If Direction>270 & Direction<90 Then  OffSetY:-1 
		         Else If  Direction > 90 & Direction < 270 Then OffSetY:+1
		        		 		    
	        End If
            
            If KeyDown(Key_Down)
              
		      X:- Sin(Direction)*movespeed
		      Y:+ Cos(Direction)*movespeed
		
            End If
            
            If  KeyHit(KEY_MOUSELEFT)
              TFire.Fire( X, Y, Direction, XSpeed, YSpeed ) 
	        End If 
	         
	        		
	        If OffsetY > MapHeight-ScreenH Then
			OffsetY = MapHeight-ScreenH
		    End If
     
            If OffsetY <= 0 Then
			OffsetY = 0
		    End If
            
            If X>ScreenW Then X=ScreenW-4

            If X<0 Then X=4

            If Y<0 Then Y=4
    
            If Y>ScreenH Then Y=ScreenH-4

    End Method

    Function UpdateAll()
       Local player1:TPlayers
       For player1:TPlayers = EachIn List
           player1.Update()
       Next
       
    End Function

	Method Destroy()
	
	End Method
	
 End Type

Type TMaps Extends TGameObjects
    
        Global Image:TImage
        Global List:TList 
         

        

        
        
        
        
Function Create()
                
        Local TileMap:TMaps = New TMaps
	    If List = Null List = CreateList()
	    List.AddLast TileMap 
	    
	    If Not Image 
			Image = LoadAnimImage("gfx/tilestrip.bmp",TileSize,TileSize,0,1,FILTEREDIMAGE)
		EndIf
		

EndFunction


Method New()
        X=0
        Y=97*TileSize

End Method


Method Draw()

End Method

Method Update()

        Local i%,j%
        Local MyMap%[32,100]

        For i =0 To 31
		  For j =0 To 99
			X = i * TileSize  
			Y = j * TileSize - OffSetY
			TileMap = MyMap[i,j]
			SetRotation 0
            DrawImage Image,X,Y,TileMap
      	
		  Next
	    Next
       
End Method

Function UpdateAll()

        Local TileMap:TMaps

        For TileMap:TMaps = EachIn List
            TileMap.Update()
        Next
       
End Function

Method Destroy()

End Method

End Type





Edited : forgot to add my Tmaps type in the code box.