Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a little tutorial STEP by STEP on scrolling in 2D graphic mode
#7
I use a different solution. If the screen resolution is, for example, 800x600 and the displayed object has coordinates 9000, 320, then it does not meet the conditions and is not displayed. Anything that is in the range 0 - 800 and 0 - 600 meets them and is therefore visible.

Here is an example. Let's say you need to display a higher resolution image on an 800x600 screen. Just use what _PutImage can do by itself and take advantage of the fact that things outside the visible area are not rendered.
In the program, use the left, right, up, down arrows and the mouse wheel to zoom.
Also try inserting any other image instead of _ScreenImage. It will work the same.

Code: (Select All)

Dim As Long MX, MY, LB, RB, Imag

Imag = _ScreenImage
Screen _NewImage(800, 600, 32)
Z = 799
RatioY = _Height / _Width

Do Until k& = 27
    k& = _KeyHit
    GetMouse MX, MY, LB, RB, MWH
    Select Case k&
        Case 18432: Y = Y - 10
        Case 20480: Y = Y + 10
        Case 19200: X = X - 10
        Case 19712: X = X + 10
    End Select
    Z = Z + MWH
    Cls
    _PutImage (0, 0)-(799, 599), Imag, 0, (X, Y)-(X + Z, Y + Z * RatioY)
    _Display
    _Limit 30
Loop

Sub GetMouse (MX As Long, MY As Long, LB As Long, RB As Long, MWH As Single)
    omwh = MWH
    Do While _MouseInput
        MWH = MWH + 10 * _MouseWheel
    Loop
    If omwh - MWH = 0 Then MWH = 0
    MX = _MouseX
    MY = _MouseY
    LB = _MouseButton(1)
    RB = _MouseButton(2)
End Sub


Reply


Messages In This Thread
RE: a little tutorial STEP by STEP on scrolling in 2D graphic mode - by Petr - 12-02-2024, 02:32 PM



Users browsing this thread: 19 Guest(s)