Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bubble Universe by Samuel Gomes
#1


Attached Files Thumbnail(s)
   

.zip   BubbleUniverse.zip (Size: 114.78 KB / Downloads: 4)
Reply
#2
(01-25-2026, 11:08 AM)Magdha Wrote: Use the TrackBars to alter the graphical effects.



The program uses the following InForm objects:
Form
PictureBox
Label
Frame
TrackBar

Unzip the file and extract the folder into your PEQB64 directory.  In the IDE make sure that you have the Run Option “Save EXE in source folder” checked.


Code: (Select All)
': This a port of Paul Dunn's (ZXDunny) "Bubble Universe" demo by a740g
': https://github.com/ZXDunny/SpecBAS-Demos...e_universe
':
': This program uses
': InForm GUI engine for QB64-PE - v1.5.4
': Fellippe Heitor, (2016 - 2022) - @FellippeHeitor
': Samuel Gomes, (2023 - 2024) - @a740g
': https://github.com/QB64-Phoenix-Edition/InForm-PE
'-----------------------------------------------------------

OPTION _EXPLICIT

': Controls' IDs: ------------------------------------------------------------------
DIM SHARED iTB AS LONG
DIM SHARED cTB AS LONG
DIM SHARED tTB AS LONG
DIM SHARED bTB AS LONG
DIM SHARED ILB AS LONG
DIM SHARED CLB AS LONG
DIM SHARED TLB AS LONG
DIM SHARED BLB AS LONG
DIM SHARED Options AS LONG
DIM SHARED Frame1 AS LONG
DIM SHARED BubbleUniverse AS LONG
DIM SHARED Canvas AS LONG

DIM SHARED t AS SINGLE

': External modules: ---------------------------------------------------------------
'$INCLUDE:'InForm\InForm.bi'
'$INCLUDE:'InForm\xp.uitheme'
'$INCLUDE:'Bubble-Universe.frm'

': Event procedures: ---------------------------------------------------------------
SUB __UI_BeforeInit

END SUB

SUB __UI_OnLoad

END SUB

SUB __UI_BeforeUpdateDisplay
    CONST TAU! = _PI(2!)
    CONST SCALE! = 0.48!
    CONST DIVISOR! = 1000!

    'This event occurs at approximately 60 frames per second.
    'You can change the update frequency by calling SetFrameRate DesiredRate%

    BeginDraw Canvas

    DIM hW AS SINGLE: hW = _WIDTH / 2!
    DIM hH AS SINGLE: hH = _HEIGHT / 2!
    DIM a AS SINGLE: a = TAU / (Control(cTB).Value / DIVISOR!)
    DIM tI AS SINGLE: tI = Control(tTB).Value / DIVISOR!
    DIM n AS SINGLE: n = Control(iTB).Value
    DIM b AS SINGLE: b = Control(bTB).Value

    CLS

    DIM AS SINGLE i, j, u, v, x

    FOR i = 0! TO n
        FOR j = 0! TO n

            u = SIN(i + v) + SIN(a * i + x)
            v = COS(i + v) + COS(a * i + x)
            x = u + t

            PSET (hW + u * hW * SCALE, hH + v * hH * SCALE), _RGB32(i, j, b - t)
        NEXT
    NEXT

    t = t + tI

    EndDraw Canvas

END SUB

SUB __UI_BeforeUnload
    'If you set __UI_UnloadSignal = False here you can
    'cancel the user's request to close.

END SUB

SUB __UI_Click (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

        CASE ILB

        CASE CLB

        CASE TLB

        CASE BLB

        CASE Options

        CASE Frame1

        CASE BubbleUniverse

        CASE Canvas

    END SELECT
END SUB

SUB __UI_MouseEnter (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

        CASE ILB

        CASE CLB

        CASE TLB

        CASE BLB

        CASE Options

        CASE Frame1

        CASE BubbleUniverse

        CASE Canvas

    END SELECT
END SUB

SUB __UI_MouseLeave (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

        CASE ILB

        CASE CLB

        CASE TLB

        CASE BLB

        CASE Options

        CASE Frame1

        CASE BubbleUniverse

        CASE Canvas

    END SELECT
END SUB

SUB __UI_FocusIn (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

    END SELECT
END SUB

SUB __UI_FocusOut (id AS LONG)
    'This event occurs right before a control loses focus.
    'To prevent a control from losing focus, set __UI_KeepFocus = True below.
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

    END SELECT
END SUB

SUB __UI_MouseDown (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

        CASE ILB

        CASE CLB

        CASE TLB

        CASE BLB

        CASE Options

        CASE Frame1

        CASE BubbleUniverse

        CASE Canvas

    END SELECT
END SUB

SUB __UI_MouseUp (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

        CASE ILB

        CASE CLB

        CASE TLB

        CASE BLB

        CASE Options

        CASE Frame1

        CASE BubbleUniverse

        CASE Canvas

    END SELECT
END SUB

SUB __UI_KeyPress (id AS LONG)
    'When this event is fired, __UI_KeyHit will contain the code of the key hit.
    'You can change it and even cancel it by making it = 0
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB

    END SELECT
END SUB

SUB __UI_TextChanged (id AS LONG)
    SELECT CASE id

        CASE ELSE

    END SELECT
END SUB

SUB __UI_ValueChanged (id AS LONG)
    SELECT CASE id
        CASE iTB

        CASE cTB

        CASE tTB

        CASE bTB
            t = 0!

    END SELECT
END SUB

SUB __UI_FormResized

END SUB

'$INCLUDE:'InForm\InForm.ui'

   Missing HMap64.bi from the archive !
Reply
#3
Zip file replaced.  It should work now.  Apologies.
Reply
#4
OK Bubble worked straight out-of-the box but how to fit all those sliders on my little latop screen with an effective height of 760 pixels max after sutracting room for title bar. I can work 2 sliders, the 2nd is half visible but enough to move pointer.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#5
(01-26-2026, 05:20 PM)bplus Wrote: OK Bubble worked straight out-of-the box but how to fit all those sliders on my little latop screen with an effective height of 760 pixels max after sutracting room for title bar. I can work 2 sliders, the 2nd is half visible but enough to move pointer.

Add a $RESIZE:STRETCH or $RESIZE:SMOOTH and then resize to your little screen size.  

Or broadcast to your TV for better resolution.  

Or use a screen scale to downscale a program to your screen.  (Most modern machines with ultra high resolution programs need a 200% scale or so to work and display properly.  Set yours to 50% scale.)
Reply
#6
For all the InForm projects that I'm copying from the github to put here, I'm not changing any code to fit non-HD screens.  Just making sure that the code is PE compatible.  When folk realise that their project is on the forum, they are welcome, of course, to make edits if necessary.
Now that I am using the correct file structure, I'll do all the others.
Reply
#7
(01-26-2026, 06:25 PM)SMcNeill Wrote:
(01-26-2026, 05:20 PM)bplus Wrote: OK Bubble worked straight out-of-the box but how to fit all those sliders on my little latop screen with an effective height of 760 pixels max after sutracting room for title bar. I can work 2 sliders, the 2nd is half visible but enough to move pointer.

Add a $RESIZE:STRETCH or $RESIZE:SMOOTH and then resize to your little screen size.  

Or broadcast to your TV for better resolution.  

Or use a screen scale to downscale a program to your screen.  (Most modern machines with ultra high resolution programs need a 200% scale or so to work and display properly.  Set yours to 50% scale.)

$Resize: Stretch worked beautifully first time I ever used it. 
   

I think I might put that automatically in all graphics programs.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#8
I’ve been promoting it for *years*.  Have no clue why people avoid it so.
Reply
#9
Some of us, like me, don't learn until we are ready and ripe for it!

That Bubble code is so interesting to watch! I think the only mod I would try is to allow it to run even slower. It runs too fast with the slider over even a fraction to right.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)