Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_MAPTRIANGLE EXAMPLES
#10
Ok.    I stole MAPTRIANGLE code from Petr and combined it with my Video library (In one hit wonders !) 

 

REQUIRES THE SPV-VIDS LIBRARY !
Code: (Select All)

$Resize:On
Option _Explicit
$Embed:'./ba.jpg','applebg'

Dim Shared IM As Long
Dim Shared IMG As Long
Dim Shared e As Long
Dim Shared V As Long
Dim Shared SX0, SY0, SX1, SY1, SX2, SX3, SY2, SY3
Dim Shared tt, t, DX0, DY0, DX1, DY1, DX2, DY2, DX3, DY3, StredX, RR, SS, R, s, vx, vy, Mxx, Myy, W, H, d
Dim Shared Mx As Long
Dim Shared My As Long

Dim Shared APPLE As Long
APPLE = _LoadImage(_Embedded$("applebg"), 32, "MEMORY")

Screen _NewImage(1024, 768, 32)
IM& = _ScreenImage
IMG& = _CopyImage(IM&, 33)
_FreeImage IM&
SX0 = 0: SY0 = 0: SX1 = 0: SY1 = _Height: SX2 = _Width: SY2 = 0: SX3 = _Width: SY3 = _Height
DX0 = -2: DY0 = 2: DX1 = -2: DY1 = -2: DX2 = 2: DY2 = 2: DX3 = 2: DY3 = -2

'    SX0            SX2                                                                    y
'    dx0                                  X left = -  right = +                - x      -z      +x
'                                          Y dole = -  nahore = +                        -y
'                                          Z vzadu = max - 10, normalne ale -1
'    SX1            SX3
tt = .01: t = .1


' IF FRAME_CALLBACK IS ON THEN THE SUB
' FRAME_CALLBACK WILL BE CALLED FOR EACH FRAME OF THE VIDEO
' REMOVING THE DEFINE FOR FRAME_CALLBACK TURNS THIS OFF
' THE SUB FRAME_CALLBACK Is defined by the end Developer
$Let FRAME_CALLBACK = "ON"



' If this DEFINE is used then a User function
' V_Custom_Controller& that should return type LONG is used instead of
' _keyhit for video playback.    Should return the same as _keyhit control
' _key_spc - Pause
' _key_esc - End (and bookmark if bookmarking is on)
' _key_left - Seek back four seconds
' _key_right - Seek forward four seconds
' _key_up, _key_down PCM volume control
' M key Mutes Audio
' L key pops up the Key control Legend
' T key toggles Video Countdown Timer display
' If you do not want the Popup Messages on the Video Image then
' Set VID_LEGENDS_OFF to _True


' $Include: './SPV-VIDS.BI'

Dim BG As Long
Dim Shared XWid As Long
Dim Shared YHei As Long
Dim Shared XInc As Integer
Dim Shared YInc As Integer
Dim Shared XBounce As Integer
Dim Shared YBounce As Integer
Dim Shared AppleImg As Long


Randomize Timer
XWid = 1024
YHei = 768
XInc = Int(Rnd * 6) + 1
YInc = Int(Rnd * 6) + 1

GETVIDEO:

' With this on Video will Bookmark current Frame to a .MARK
' File.  When next played (if Bookmarking ON) Play will resume at
' The Bookmark.  If BookMarking is OFF then Video plays from beginning
' and no bookmark is saved when ESC is pressed.
TURNON_BOOKMARKING


_Title "SPV Video Selection"
VIDEO_FILE$ = _OpenFileDialog$("SIMPLE X16 MOVIE PLAYER - Select SPV Video File(s) to Play", "", "*.SPV|*.spv", "X16 Movie Files", 0)
If BG <> 0 Then
    Screen 0
    _FreeImage BG
    _Display
End If

' Video_XOrigin = XOrg
' Video_YOrigin = YOrg

' VIDEO_WINDOW_WIDTH = VWidth

' VIDEO_WINDOW_HEIGHT = INT(VWidth * .75)


' This player selects proper resolution and background for Widescreen and 4:3 Videos
' In the Call to WINDOWED_VIDEO only the Width is specified, Height is calculated properly
' For the Video ASPECT Ration
If OpenVideo(VIDEO_FILE$) Then
    PlayTheVideo
    CLEAN_UP_VIDEO
    GoTo GETVIDEO
End If
System


' The below sub & funtion are for the Custom Callbacks.
' Simple implemenation to show the principle.


' Very simple CUSTOM Control that just duplicates
' The Normal Keyboard Control functionality.
Function V_Custom_Controller&
    Static C As Long
    C = _KeyHit
    If C = Asc("U") Or C = Asc("u") Then
        If VIDEO_FPS < 60 Then
            Change_VideoFPS VIDEO_FPS + .25
        End If
    End If
    If C = Asc("D") Or C = Asc("d") Then
        If VIDEO_FPS > .5 Then
            Change_VideoFPS VIDEO_FPS - .25
        End If
    End If

    If C = Asc("r") Or C = Asc("R") Then
        ' Restore Orignal Encoded FPS
        Change_VideoFPS 0
    End If
    V_Custom_Controller = C
End Function


Sub Frame_CallBack
    e& = ell&
    Mx = _MouseX: My = _MouseY
    StredX = Mx
    t = t + tt: If t > _Pi(2) Or t < -_Pi(2) Then tt = tt * -1
    RR = Sin(t) - 4
    SS = Cos(t) - 10
    R = -Sin(t) * -2
    s = -Cos(t) * 2
    _Dest LEGEND_DESTINATION
    Line (0, 0)-(_Width - 1, _Height - 1), _RGB32(50, 50, 90, 255), BF
    _MapTriangle (SX0, SY0)-(SX3, SY3)-(SX1, SY1), e& To(DX0 * R, DY0 * s, RR)-(DX3 * R, DY3 * s, SS)-(DX1 * R, DY1 * s, RR), 0, _Smooth
    _MapTriangle (SX0, SY0)-(SX3, SY3)-(SX2, SY2), e& To(DX0 * R, DY0 * s, RR)-(DX3 * R, DY3 * s, SS)-(DX2 * R, DY2 * s, SS), 0, _Smooth
    _Dest 0
End Sub

Function ell&
    V& = _NewImage(1024, 768, 32)
    _Dest V&
    W = 1024: H = 768
    If Mxx = 0 Then Mxx = 10: Myy = 10
    vx = vx + Mxx: If vx > W Or vx < 0 Then Mxx = Mxx * -1
    vy = vy + Myy: If vy > H Or vy < 0 Then Myy = Myy * -1
    Cls , _RGB32(1, 55, 132)
    _PutImage , FRAME_IMAGE
    _Dest 0
    ell& = _CopyImage(V&, 33)
    _FreeImage V&
End Function



' $Include: './SPV-VIDS.BM'
Reply


Messages In This Thread
_MAPTRIANGLE EXAMPLES - by NakedApe - 01-23-2026, 02:45 AM
RE: _MAPTRIANGLE EXAMPLES - by Unseen Machine - 01-23-2026, 03:18 AM
RE: _MAPTRIANGLE EXAMPLES - by Unseen Machine - 01-23-2026, 04:37 AM
RE: _MAPTRIANGLE EXAMPLES - by SMcNeill - 01-23-2026, 05:29 AM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-23-2026, 07:12 AM
RE: _MAPTRIANGLE EXAMPLES - by Magdha - 01-23-2026, 11:24 AM
RE: _MAPTRIANGLE EXAMPLES - by NakedApe - 01-23-2026, 02:35 PM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-23-2026, 03:14 PM
RE: _MAPTRIANGLE EXAMPLES - by Petr - 01-23-2026, 08:13 PM
RE: _MAPTRIANGLE EXAMPLES - by ahenry3068 - 01-23-2026, 09:49 PM
RE: _MAPTRIANGLE EXAMPLES - by Unseen Machine - 01-23-2026, 10:05 PM
RE: _MAPTRIANGLE EXAMPLES - by ahenry3068 - 01-24-2026, 12:04 AM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-24-2026, 12:57 AM
RE: _MAPTRIANGLE EXAMPLES - by ahenry3068 - 01-24-2026, 01:31 AM
RE: _MAPTRIANGLE EXAMPLES - by ahenry3068 - 01-25-2026, 10:30 AM
RE: _MAPTRIANGLE EXAMPLES - by NakedApe - 01-23-2026, 11:58 PM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-24-2026, 03:06 AM
RE: _MAPTRIANGLE EXAMPLES - by Unseen Machine - 01-24-2026, 03:47 AM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-24-2026, 03:52 AM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-24-2026, 04:09 PM
RE: _MAPTRIANGLE EXAMPLES - by NakedApe - 01-24-2026, 05:00 PM
RE: _MAPTRIANGLE EXAMPLES - by bplus - 01-25-2026, 10:40 AM
RE: _MAPTRIANGLE EXAMPLES - by ahenry3068 - 01-25-2026, 05:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A Question About _MAPTRIANGLE Magdha 2 390 11-02-2025, 11:37 AM
Last Post: Magdha
  Using _MapTriangle in Small Virtual Screens NakedApe 7 869 07-05-2025, 11:54 AM
Last Post: SMcNeill
  Does _MapTriangle work in a user defined Window? bplus 12 2,283 02-16-2024, 01:40 AM
Last Post: bplus
  _MAPTRIANGLE face culling RokCoder 0 464 01-10-2023, 07:29 PM
Last Post: RokCoder
Music does anyone have any examples of a simple MIDI recorder or digital audio overdubber? madscijr 9 2,041 07-29-2022, 05:13 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)