I've been playing around with viewports for an idea for a new game, and have hit a bit of a problem. the code does exactly what i want it to do, but what would be the best way of stopping the viewport from going past the edges? what i have tried so far hasn't been successful. what would you guys suggest?
also, i know that there is an issue with viewports on some low end machines. this is not an issue in this case.
cheers
Charlie
also, i know that there is an issue with viewports on some low end machines. this is not an issue in this case.
SuperStrict Graphics 800, 600, 0, 60 Local p1:player = New player.Create() p1.x = 1000;p1.y = 900 While Not KeyHit(KEY_ESCAPE) SetOrigin 400 - p1.x, 300 - p1.y SetViewport 400 - p1.x, 300 - p1.y, 1600, 1200 For Local i:Int = 0 To 11 For Local o:Int = 0 To 12 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 Next Next 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