12-02-2024, 06:36 PM
Since you guys are all having fun with this, here's a Steve Simple version of screen scrolling at work. Just use the mouse and watch what happens!
Note: The closer your mouse gets to the edge, the faster the scrolling. Advance your pointer slowly towards the edge and watch as the scroll speed increases and decreases as you approach the edge more.
Code: (Select All)
Screen _NewImage(800, 600, 32) 'the screen that the user is going to see
Background = _NewImage(800 * 3, 600 * 3, 32) 'my background which is 3 times larger than my screen
_Dest Background
_PrintMode _KeepBackground
'Create a background which we can scroll and view via the mouse
For x = 0 To 2
For y = 0 To 2
Line (x * 800, y * 600)-Step(800, 600), _RGB(x * 127.5, y * 127.5, Rnd * 256), BF 'draw each quadrent a different color
For i = 0 To 37
text$ = "QUADRENT" + Str$(y * 3 + x + 1) + ": LINE #" + Str$(i)
_PrintString (x * 800, y * 600 + i * _FontHeight), text$
Next
Next
Next
StartX = 800: StartY = 600
_MouseMove 400, 300 'center the mouse before we start scrolling like crazy
_Delay .2 'give the mouse time to move to the proper position for starting
Do
While _MouseInput: Wend
'If the mouse is near an edge, then change the starting points to reflect the scrolling
If _MouseX < 20 Then StartX = StartX - (20 - _MouseX): If StartX < 0 Then StartX = 0
If _MouseX > 779 Then StartX = StartX + (_MouseX - 779): If StartX > 1600 Then StartX = 1600
If _MouseY < 20 Then StartY = StartY - (20 - _MouseY): If StartY < 0 Then StartY = 0
If _MouseY > 579 Then StartY = StartY + (_MouseY - 579): If StartY > 1200 Then StartY = 1200
_PutImage (0, 0)-Step(800, 600), Background, 0, (StartX, StartY)-Step(800, 600)
_Display
_Limit 60
Loop Until _MouseButton(1) Or _MouseButton(2) 'press a mouse button to end
System
Note: The closer your mouse gets to the edge, the faster the scrolling. Advance your pointer slowly towards the edge and watch as the scroll speed increases and decreases as you approach the edge more.