ok, i've kind of got this working now, but it's a little clunky when you move into the corners. anyone know why?
cheers
Charlie
SuperStrict Graphics 800, 600, 32, 60 Local p1:player = New player.Create() p1.x = 1000;p1.y = 900 While Not KeyHit(KEY_ESCAPE) 'top left If p1.x - p1.dx <= 400 And p1.y - p1.dy <= 300 SetOrigin 0, 0 SetViewport 0 - p1.x, 0 - p1.y, 1600, 1200 'bottom Right Else If p1.x - p1.dx <= 400 And p1.y + p1.dy >= 900 SetOrigin 0, 600 - (1200 - p1.y) - p1.y SetViewport 0 - p1.x, 600 - p1.y, 1600, 1200 'bottom left ElseIf p1.x + p1.dx >= 1200 And p1.y + p1.dy >= 900 SetOrigin 800 - (1600 - p1.x) - p1.x, 600 - (1200 - p1.y) - p1.y SetViewport 800 - p1.x, 600 - p1.y, 1600, 1200 'top right Else If p1.x + p1.dx >= 1200 And p1.y - p1.dy <= 300 SetOrigin 800 - (1600 - p1.x) - p1.x, 0 SetViewport 800 - p1.x, 0 - p1.y, 1600, 1200 'right edge ElseIf p1.x + p1.dx >= 1200 SetOrigin 800 - (1600 - p1.x) - p1.x, 300 - p1.y SetViewport 800 - p1.x, 300 - p1.y, 1600, 1200 'bottom edge Else If p1.y + p1.dy >= 900 SetOrigin 400 - p1.x, 600 - (1200 - p1.y) - p1.y SetViewport 400 - p1.x, 600 - p1.y, 1600, 1200 'Left edge ElseIf p1.x - p1.dx <= 400 SetOrigin 0, 300 - p1.y SetViewport 0 - p1.x, 300 - p1.y, 1600, 1200 'top edge Else If p1.y - p1.dy <= 300 SetOrigin 400 - p1.x, 0 SetViewport 400 - p1.x, 0 - p1.y, 1600, 1200 Else 'middle SetOrigin 400 - p1.x, 300 - p1.y SetViewport 400 - p1.x, 300 - p1.y, 1600, 1200 End If 'draw background For Local i:Int = 0 To 5 For Local o:Int = 0 To 7 If i Mod 2 = 0 If o Mod 2 = 0 SetColor 0, 0, 0 Else SetColor 255, 255, 255 End If Else If o Mod 2 = 0 SetColor 255, 255, 255 Else SetColor 0, 0, 0 End If End If DrawRect (o * 200) , (i * 200), 200, 200 'SetColor 255, 255, 255 'DrawText ((o * 200) + " " + (i * 200)), (o * 200) , (i * 200) Next Next 'draw player p1.update() p1.draw() Flip Cls Wend Type player Field easing:Float = 0.10; Field dx:Float; Field dy:Float; Field x:Float Field y:Float Function Create:player() Local n:player = New player; Return n; End Function Method update() Local mx:Int = MouseX() * 2 Local my:Int = MouseY() * 2 dx = mx - x; dy = my - y; dx:*easing:Float; dy:*easing; x:+dx; y:+dy; End Method Method draw() SetColor 0, 0, 255 DrawRect x, y, 10, 10 End Method End Type
cheers
Charlie