Phoenix rising...
#1
Just a little fun program.  See if the Phoenix rises for you.

- Dav

Code: (Select All)
'===============
'PHOENIXTEST.BAS
'===============
'Are you using QB64 Phoenix, or the Bee?
'Run this code to see...
'Coded by Dav, JUL/2023

_ICON

dh = _DESKTOPHEIGHT * .85
SCREEN _NEWIMAGE(dh, dh, 32)

'safety test...
IF _WIDTH(-11) <> 32 OR _HEIGHT(-11) <> 32 THEN END

bird& = _NEWIMAGE(dh, dh, 32): _DEST bird&
_PUTIMAGE (0, 0)-(dh, dh), -11: _DEST 0

row = 15: col = 15
xsize = _WIDTH / row
ysize = _HEIGHT / col
rise = _HEIGHT

DIM SHARED piece&(row * col), piecex(row * col), piecey(row * col)
DIM risespeed(row * col)

bc = 1
FOR c = 1 TO col
    FOR r = 1 TO row
        x1 = (r * xsize) - xsize: x2 = x1 + xsize
        y1 = (c * ysize) - ysize: y2 = y1 + ysize
        piecex(bc) = x1: piecey(bc) = y1
        piece&(bc) = _NEWIMAGE(ABS(x2 - x1) + 1, ABS(y2 - y1) + 1, 32)
        _PUTIMAGE (0, 0), bird&, piece&(bc), (x1, y1)-(x2, y2)
        risespeed(bc) = RND * 2 + 1
        bc = bc + 1
    NEXT
NEXT

_DEST 0

DO
    LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, 55), BF

    FOR t = 1 TO row * col
        tx = piecex(t): tx2 = piecex(t) + xsize
        ty = piecey(t): ty2 = piecey(t) + ysize
        RotoZoom3 piecex(t) + (xsize / 2), piecey(t) + (ysize / 2) + (rise * risespeed(t)), piece&(t), 1, 1, 0
        rise = rise - .025
        _LIMIT 3000
    NEXT
    _DISPLAY

LOOP WHILE rise > 0

FOR t = 1 TO row * col
    RotoZoom3 piecex(t) + (xsize / 2), piecey(t) + (ysize / 2), piece&(t), 1, 1, 0
    _DISPLAY
NEXT

SLEEP

SUB RotoZoom3 (X AS LONG, Y AS LONG, Image AS LONG, xScale AS SINGLE, yScale AS SINGLE, radianRotation AS SINGLE)
    DIM px(3) AS SINGLE: DIM py(3) AS SINGLE ' simple arrays for x, y to hold the 4 corners of image
    DIM W&, H&, sinr!, cosr!, i&, x2&, y2& '  variables for image manipulation
    W& = _WIDTH(Image&): H& = _HEIGHT(Image&)
    px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
    px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
    px(2) = W& / 2: py(2) = H& / 2 '  right bottom
    px(3) = W& / 2: py(3) = -H& / 2 ' right top
    sinr! = SIN(-radianRotation): cosr! = COS(-radianRotation) ' rotation helpers
    FOR i& = 0 TO 3 ' calc new point locations with rotation and zoom
        x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
        px(i&) = x2&: py(i&) = y2&
    NEXT
    _MAPTRIANGLE _SEAMLESS(0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MAPTRIANGLE _SEAMLESS(0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB

Find my programs here in Dav's QB64 Corner
Reply
#2
Looks like the last version that that works is QB64pe v3.4.1. It is a cool effect when it does! Smile
b = b + ...
Reply
#3
(07-09-2023, 10:26 PM)Dav Wrote: Just a little fun program.  See if the Phoenix rises for you.

- Dav

'===============
'PHOENIXTEST.BAS
'===============
'Are you using QB64 Phoenix, or the Bee?
'Run this code to see...
'Coded by Dav, JUL/2023

dh = _DESKTOPHEIGHT * .85
SCREEN _NEWIMAGE(dh, dh, 32)

'safety test...
IF _WIDTH(-11) <> 32 OR _HEIGHT(-11) <> 32 THEN END
I can not get pass 'safety test... The IF / THEN statement - error: invalid handle. I am running QB64PE 3.8.0 in Linux.
Reply
#4
Thumbs Up 
No bee in the other forum's v 2.1 just this:
   
b = b + ...
Reply
#5
Hmm, I guess the built-in icon number has changed.  Sorry.  Serves me right for still relying on it.  I'll have to test it the current version.  -11 use to always be the icon number.  I haven't downloaded the new Phoenix version yet.  Will do that now.

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#6
(07-09-2023, 11:53 PM)Dav Wrote: Hmm, I guess the built-in icon number has changed.  Sorry.  Serves me right for still relying on it.  I'll have to test it the current version.  -11 use to always be the icon number.  I haven't downloaded the new Phoenix version yet.  Will do that now.

- Dav

I get this in Linux:

Quote:gjmcginn@optiplex990:/media/gjmcginn/Development/SourceCode/basic/Blackjack$ ./test
freeglut (./test):
I'm using v3.4 of Phoenix version (been away due to medical reasons for last months), so I don't know if it needs a newer version of QB64pe, or it's Linux, or the issue you mentioned.
—————————————————————————————
George McGinn
Theoretical/Applied Computer Science Specialist
Member: IEEE, IEEE Computer Society
               Technical Council on Software Engineering       
               IEEE Standards Association
               Society of American Baseball Research
Reply
#7
Here's all you were missing, @Dav:

Code: (Select All)
'===============
'PHOENIXTEST.BAS
'===============
'Are you using QB64 Phoenix, or the Bee?
'Run this code to see...
'Coded by Dav, JUL/2023


_Icon 'Single line added by Steve to add an icon which will become image handle #11



dh = _DesktopHeight * .85
Screen _NewImage(dh, dh, 32)

'safety test...
If _Width(-11) <> 32 Or _Height(-11) <> 32 Then End

bird& = _NewImage(dh, dh, 32): _Dest bird&
_PutImage (0, 0)-(dh, dh), -11: _Dest 0

row = 15: col = 15
xsize = _Width / row
ysize = _Height / col
rise = _Height

Dim Shared piece&(row * col), piecex(row * col), piecey(row * col)
Dim risespeed(row * col)

bc = 1
For c = 1 To col
    For r = 1 To row
        x1 = (r * xsize) - xsize: x2 = x1 + xsize
        y1 = (c * ysize) - ysize: y2 = y1 + ysize
        piecex(bc) = x1: piecey(bc) = y1
        piece&(bc) = _NewImage(Abs(x2 - x1) + 1, Abs(y2 - y1) + 1, 32)
        _PutImage (0, 0), bird&, piece&(bc), (x1, y1)-(x2, y2)
        risespeed(bc) = Rnd * 2 + 1
        bc = bc + 1
    Next
Next

_Dest 0

Do
    Line (0, 0)-(_Width, _Height), _RGBA(0, 0, 0, 55), BF

    For t = 1 To row * col
        tx = piecex(t): tx2 = piecex(t) + xsize
        ty = piecey(t): ty2 = piecey(t) + ysize
        RotoZoom3 piecex(t) + (xsize / 2), piecey(t) + (ysize / 2) + (rise * risespeed(t)), piece&(t), 1, 1, 0
        rise = rise - .025
        _Limit 3000
    Next
    _Display

Loop While rise > 0

For t = 1 To row * col
    RotoZoom3 piecex(t) + (xsize / 2), piecey(t) + (ysize / 2), piece&(t), 1, 1, 0
    _Display
Next

Sleep

Sub RotoZoom3 (X As Long, Y As Long, Image As Long, xScale As Single, yScale As Single, radianRotation As Single)
    Dim px(3) As Single: Dim py(3) As Single ' simple arrays for x, y to hold the 4 corners of image
    Dim W&, H&, sinr!, cosr!, i&, x2&, y2& '  variables for image manipulation
    W& = _Width(Image&): H& = _Height(Image&)
    px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
    px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
    px(2) = W& / 2: py(2) = H& / 2 '  right bottom
    px(3) = W& / 2: py(3) = -H& / 2 ' right top
    sinr! = Sin(-radianRotation): cosr! = Cos(-radianRotation) ' rotation helpers
    For i& = 0 To 3 ' calc new point locations with rotation and zoom
        x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle _Seamless(0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle _Seamless(0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
Reply
#8
(07-10-2023, 04:12 PM)SMcNeill Wrote: Here's all you were missing, @Dav:
...

Thanks Steve. That works on Linux, QB64pe v3.4!
—————————————————————————————
George McGinn
Theoretical/Applied Computer Science Specialist
Member: IEEE, IEEE Computer Society
               Technical Council on Software Engineering       
               IEEE Standards Association
               Society of American Baseball Research
Reply
#9
SMcNeill, It works for me, Thanks!
Reply
#10
Dav, The Phoenix rises! That one line that SMcNeill added did the trick. Without it treated the IDE like it was not genuine PE. More than that trying to get something it didn't know what? Thanks for putting this together. Beautifully done.
Reply




Users browsing this thread: 4 Guest(s)