07-07-2025, 11:51 PM
I'm still messing around with tilting images and parallax and trying to use _PutImage to display a couple hardware screens so both are visible, but they overlap and, naturally, the second one put to screen blocks the first one. I believe the way to do it would be to make the second image transparent by using _ClearColor while it's still a software image, but I can't get it to work...
How do you make a hardware image transparent? I guess I could snip out the parts I want with _PutImage, but figured I should know how to do this too...
Thanks.
P.S. I did sniff around the forum and wiki for answers, but no luck so far.
How do you make a hardware image transparent? I guess I could snip out the parts I want with _PutImage, but figured I should know how to do this too...
Thanks.
P.S. I did sniff around the forum and wiki for answers, but no luck so far.
Code: (Select All)
Option _Explicit
Dim As Long image, virt, label, font, a
Dim As Integer w, h: w = 260: h = 400
Screen _NewImage(1920, 1080, 32): _FullScreen
$Color:32
font = _LoadFont("futura.ttc", 20)
virt = _NewImage(w, h, 32) ' small virtual screen
image = _CopyImage(virt, 32) ' a copy of virt
label = _CopyImage(image, 33) ' a hardware version
' -----------------------------------------
' print to small "virt" software screen ** GENERATE TILTED SHIP & TARGET LABELS **
_Dest virt: _Font font: Color Yellow
_PrintString (_Width(virt) \ 2 - _PrintWidth("SHIP: ") \ 2, _Height(virt) \ 2 - 10), "SHIP: " '
Color Red
_PrintString (_Width(virt) \ 2 - _PrintWidth("TARG: ") \ 2, _Height(virt) \ 2 + 20), "TARG: " ' adding virt as dest at EOL fails, must use _Dest virt instead
' convert virt to hardware "image"
image = _CopyImage(virt, 33) '
' tweak "image" with _MapTriangle to "label" hardware screen
_MapTriangle (0, 0)-(0, h - 1)-(w - 1, h - 1), image To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), label '
_MapTriangle (0, 0)-(w - 1, h - 1)-(w - 1, 0), image To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), label '
' -----------------------------------------
font = _LoadFont("futura.ttc", 26) ' ** GENERATE TILTED SHIP ANGLE NUMBERS **
Dim As Long virt2, image2, shipCard(359)
Dim As _Unsigned Long col
virt2 = _NewImage(w, h, 32) '
' -------------------
_Source (virt2): col = Point(0, 0) ' <<<< THIS ISN'T WORKING <<<<
_ClearColor col, virt2
' -------------------
image2 = _CopyImage(virt2, 32) '
For a = 0 To 359: shipCard(a) = _CopyImage(image2, 33): Next '
_Dest virt2 '
w = 260: h = 500
Cls: _Font font: Color Yellow
For a = 0 To 359
_PrintString (_Width(virt2) \ 2, _Height(virt2) \ 2 - 10), Str$(a) + " " '
image2 = _CopyImage(virt2, 33) '
_MapTriangle (0, 0)-(0, h - 1)-(w - 1, h - 1), image2 To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), shipCard(a) '
_MapTriangle (0, 0)-(w - 1, h - 1)-(w - 1, 0), image2 To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), shipCard(a) '
Next
' -----------------------------------------
font = _LoadFont("futura.ttc", 21) ' ** GENERATE TILTED TARGET ANGLE NUMBERS **
Dim As Long virt3, image3, targCard(359)
virt3 = _NewImage(w, h, 32) '
'_Source (virt3): col = Point(0, 0) '
'_ClearColor col, virt3
image3 = _CopyImage(virt3, 32) '
For a = 0 To 359: targCard(a) = _CopyImage(image3, 33): Next '
_Dest virt3 '
w = 260: h = 500
Cls: _Font font: Color Red
For a = 0 To 359
_PrintString (_Width(virt3) \ 2, _Height(virt3) \ 2 - 10), Str$(a) + " " '
image3 = _CopyImage(virt3, 33) '
_MapTriangle (0, 0)-(0, h - 1)-(w - 1, h - 1), image3 To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), targCard(a) '
_MapTriangle (0, 0)-(w - 1, h - 1)-(w - 1, 0), image3 To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), targCard(a) '
Next
_Dest 0
For a = 0 To 359 ' ** PUT TO SCREEN **
If a < 10 Then
_PutImage (_Width \ 2 - _Width(label) \ 2 - 10, _Height \ 2 - _Height(label) \ 2 + 34), shipCard(a), 0 '
_PutImage (_Width \ 2 - _Width(label) \ 2 - 10, _Height \ 2 - _Height(label) \ 2 - 18), targCard(a), 0 ' <<<< TARGET NUMBERS BLOCK SHIP NUMBERS
End If
If a > 9 _AndAlso a < 100 Then
_PutImage (_Width \ 2 - _Width(label) \ 2 - 30, _Height \ 2 - _Height(label) \ 2 + 34), shipCard(a), 0 '
_PutImage (_Width \ 2 - _Width(label) \ 2 - 30, _Height \ 2 - _Height(label) \ 2 - 18), targCard(a), 0 '
End If
If a >= 100 Then
_PutImage (_Width \ 2 - _Width(label) \ 2 - 50, _Height \ 2 - _Height(label) \ 2 + 34), shipCard(a), 0 '
_PutImage (_Width \ 2 - _Width(label) \ 2 - 45, _Height \ 2 - _Height(label) \ 2 - 18), targCard(a), 0 '
End If
_PutImage (_Width \ 2 - _Width(label) \ 2 - 100, _Height \ 2 - _Height(label) \ 2), label, 0 ' add label last
_Display '
_Delay .025 '
If _KeyHit = 27 Then Exit For
Next
_Delay .5
_FreeImage virt: _FreeImage image: _FreeImage label
_FreeImage virt2: _FreeImage image2
_FreeImage virt3: _FreeImage image3
For a = 0 To 359: _FreeImage shipCard(a): _FreeImage targCard(a): Next
System




)
Thnx!