Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D-ized 2D, a sort of challenge or a how to question...
#13
(04-01-2024, 03:57 PM)TerryRitchie Wrote: Here's a little proof of concept. You'll need the si3.png image I included below. I had to resize it to 960x960 and convert to 32bit color.
Play around with the x,y coordinates in the secondary x,y,z coordinates of _MAPTRIANGLE to fit the image.
Thanks... I tried playing around with the x,y coordinates in the secondary x,y,z of _MAPTRIANGLE but it seems that whatever I try, it just mangles the screen. 
I'm at my wits end with that part of things... 

Here's the latest code along with the latest images (tweaked the background image so it wraps around smoothly, and changed scrolling direction to down). 

Code: (Select All)
' 3D-ized 2D
' https://qb64phoenix.com/forum/showthread.php?tid=2556

Dim fg As Long '         foreground image (sprites, text)
Dim bg As Long '         background image (for scrolling)
Dim by As Integer '      background y
Dim GameScreen As Long ' software screen to update
Dim HWScreen As Long '   hardware screen to display

_ScreenMove 0, 0
'_SCREENMOVE _MIDDLE

fg = _LoadImage("fg6.png", 32)
bg = _LoadImage("bg6.png", 32)
GameScreen = _NewImage(960, 960, 32)

'newhandle& = _COPYIMAGE(imageHandle&[, mode%])
'Mode 33 images are hardware accelerated in version 1.000 and up, and are created using _LOADIMAGE or _COPYIMAGE.
HWScreen = _CopyImage(GameScreen, 33)

Screen _NewImage(960, 960, 32)

by = -2000
Do
    _Limit 60
    _Dest GameScreen
    Cls

    '_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]][, _SMOOTH]
    _PutImage (0, by), bg
    _PutImage (0, 0), fg

    _Dest 0
    _FreeImage HWScreen
    HWScreen = _CopyImage(GameScreen, 33)

    '2D drawing
    '_MAPTRIANGLE [{_SEAMLESS}] (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& TO (dx1, dy1)-(dx2, dy2)-(dx3, dy3)[, destination&][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]]

    '3D drawing (hardware images only)
    '_MAPTRIANGLE [{_CLOCKWISE|_ANTICLOCKWISE}] [{_SEAMLESS}] (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& TO (dx1, dy1, dz1)-(dx2, dy2, dz2)-(dx3, dy3, dz3)[, destination&][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]]

    '_MapTriangle (0, 0)-(0, 959)-(959, 959), HWScreen To(-1, 1, -3)-(-1, -1, -1)-(1, -1, -1), 0
    '_MapTriangle (0, 0)-(959, 959)-(959, 0), HWScreen To(-1, 1, -3)-(1, -1, -1)-(1, 1, -3), 0

    '>>The only problem is everything displays too low on the screen - how would you make it top aligned?
    '>Play around with the x,y coordinates in the secondary x,y,z coordinates of _MAPTRIANGLE to fit the image.
    'Not working, any ideas?:
    _MapTriangle (0, 0)-(0, 959)-(959, 959), HWScreen To(-1, 1, -3)-(-1, -1, -1)-(1, -1, -1), 0
    _MapTriangle (0, 0)-(959, 959)-(959, 0), HWScreen To(-1, 1, -3)-(1, -1, -1)-(1, 1, -3), 0

    _Display

    by = by + 1: If by = 0 Then by = -2000 ' SCROLL FORWARDS

Loop Until _KeyHit = 27
System


Attached Files Image(s)
       
Reply


Messages In This Thread
RE: 3D-ized 2D, a sort of challenge or a how to question... - by madscijr - 04-01-2024, 07:28 PM



Users browsing this thread: 2 Guest(s)