(03-30-2024, 11:16 PM)Petr Wrote: To the question above - motion of the stars - here is the solution in the form of a hardware image - it shows how to get the motion into the hardware image.I was able to modify your code to scroll the background vertically in pseudo 3d, and overlay the foreground over it.
The only problem is everything displays too low on the screen - how would you make it top aligned?
Code: (Select All)
Dim Image As Long
Dim ifg&
Dim ibg&
Dim xs As Long
Dim ys As Long
Dim h1 As Long
Dim w1 As Long
Image = _LoadImage("bg2.png", 32)
ibg& = _CopyImage(Image, 33)
'Image = _LoadImage("si3.png", 32)
'ifg& = _CopyImage(Image, 33)
ifg& = _LoadImage("si3.png", 32)
'Screen _NewImage(1000, 1000, 32)
'h1 = 479
'w1 = 639
h1 = 999
w1 = 999
_Dest Image
'Cls
'For s = 1 To 100
' PSet (Rnd * 640, Rnd * 480)
'Next
'Virtual = _NewImage(640, 480, 32)
Virtual = _NewImage(1000, 2000, 32)
'Screen _NewImage(640, 480, 32)
Screen _NewImage(1000, 1000, 32)
Do Until _KeyHit = 27
ys = ys + 1
If ys > h1 Then ys = 0
'_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]][, _SMOOTH]
_PutImage (0, ys), Image, Virtual, (0, 0)-(w1, h1)
_PutImage (0, -h1 + ys), Image, Virtual, (0, 0)-(w1, h1)
_PutImage (0, 0), ifg&, Virtual, (0, 0)-(w1, h1)
'newhandle& = _COPYIMAGE(imageHandle&[, mode%])
'Mode 33 images are hardware accelerated in version 1.000 and up, and are created using _LOADIMAGE or _COPYIMAGE.
ibg& = _CopyImage(Virtual, 33)
_MapTriangle (0, 0)-(0, h1)-(w1, h1), ibg& To(-2, 2, -3)-(-2, -2, -1)-(2, -2, -1), 0
_MapTriangle (0, 0)-(w1, h1)-(w1, 0), ibg& To(-2, 2, -3)-(2, -2, -1)-(2, 2, -3), 0
_Display
'_FreeImage ifg&
_FreeImage ibg&
_Limit 20
Loop