Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Valentine's Beating Heart
#21
Code: (Select All)
Do
    Sound 60, .1, .5, 1, 4 '  4? 3 better than 2 better than 1 last para
    _Delay 3 / 18
    Sound 35, .12, .7, -1, 4 ' 6 nice  5 is for a clock, 7 too loud  8?
    _Delay 13 / 18
    Print Time$
Loop Until _KeyDown(27)


Testing sound and new graphics:
Code: (Select All)
Screen _NewImage(800, 600, 32): _ScreenMove 270, 60
_Title "bplus mod of Steves Code Inspired by bplus #2"

Const TWO_PI = 6.283185307
Const max = 50
Dim Shared Particles(1 To 300) As Particle
Dim Shared cN, pR, pG, pB ' color palette

Type Particle
    x As Single
    y As Single
    dx As Single
    dy As Single
    life As Single
    sz As Single
    col As _Unsigned Long
End Type

'-----------------------------------------
' Main loop
'-----------------------------------------
Dim t As Single, beat As Integer
Dim scale As Single
Do
    Line (0, 0)-(_Width, _Height), &H11000000, BF
    t = t + .05
    UpdateParticles 1, max / 2

    scale = 8 + Sin(t) * 1.5
    DrawHeartFill 400, 300, scale, _RGB32(255, 0, 0)

    ' Beat detection
    If Sin(t) > .95 And beat = 0 Then
        DrawHeartFill 400, 300, 5, _RGB32(255, 0, 0)
        _Display
        Sound 60, .1, .5, 1, 4
        _Delay 4 / 18
        scale = .75 * scale
        DrawHeartFill 400, 300, scale, _RGB32(255, 0, 0)
        Sound 35, .12, .7, -1, 4
        _Display
        '_Delay 15 / 18
        ResetPal
        Burst 400, 300
        beat = 1
    End If
    If Sin(t) < .5 Then beat = 0

    UpdateParticles max / 2 + 1, max

    _Display
    _Limit 120
Loop

'-----------------------------------------
' Draw a parametric heart at scale S
'-----------------------------------------
Sub DrawHeart (cx As Single, cy As Single, s As Single, col As _Unsigned Long)
    Dim t As Single, x As Single, y As Single
    For t = 0 To TWO_PI Step .01
        x = 16 * Sin(t) ^ 3
        y = -(13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t))
        PSet (cx + x * s, cy + y * s), col
    Next
End Sub

Sub DrawHeartFill (cx As Single, cy As Single, s As Single, col As _Unsigned Long)
    Dim t As Single, x As Single, y As Single
    For t = 0 To TWO_PI Step .01
        x = 16 * Sin(t) ^ 3
        y = -(13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t))
        If t <> 0 Then Line (cx + x * s, cy + y * s)-(cx + lx * s, cy + s * ly), col
        lx = x: ly = y
    Next
    Paint (cx, cy), col, col
End Sub

'-----------------------------------------
' Spawn particle burst
'-----------------------------------------
Sub Burst (cx As Single, cy As Single)
    Dim i As Integer
    For i = 1 To 150
        Particles(i).x = cx
        Particles(i).y = cy
        Dim a As Single
        a = Rnd * TWO_PI
        r = Rnd * 7 + 2
        Particles(i).dx = r * Cos(a)
        Particles(i).dy = r * Sin(a)
        Particles(i).life = 1
        Particles(i).col = Pal~&
        Particles(i).sz = Rnd * 3 + .5
    Next
End Sub

'-----------------------------------------
' Update and draw particles
'-----------------------------------------
Sub UpdateParticles (istart, iend)
    Dim i As Integer
    For i = istart To iend
        If Particles(i).life > 0 Then
            Particles(i).x = Particles(i).x + Particles(i).dx
            Particles(i).y = Particles(i).y + Particles(i).dy
            Particles(i).life = Particles(i).life - .01
            Particles(i).sz = Abs(Particles(i).sz - .02)
            Dim a As Integer
            a = 255 * Particles(i).life
            DrawHeartFill Particles(i).x, Particles(i).y, Rnd * Particles(i).sz, Particles(i).col
        End If
    Next
End Sub

Function Pal~& ()
    cN = cN + .369 ''Dim Shared cN, pR, pG, pB, pA ' no pA
    Pal~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
End Function

Sub ResetPal ()
    ''Dim Shared CN, PR, PG, PB, PA ' no PA
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2: cN = 0
End Sub

https://discord.com/channels/97506559292...1675819160
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#22
Quote:But this reminds me of that thing Unseen posted that was written by AI awhile ago with nice added feature that I meant to play with...
@BPlus Huh? Do remind me as i use it everyday! (Not that i cant code though!)

John
Reply
#23
(02-17-2026, 02:18 AM)Unseen Machine Wrote:
Quote:But this reminds me of that thing Unseen posted that was written by AI awhile ago with nice added feature that I meant to play with...
@BPlus Huh? Do remind me as i use it everyday! (Not that i cant code though!)

John

You posted some code awhile back written by prompting AI for classic basic programming exercise, maybe it was a Pong code??? It was standard stuff except it has this nice feature when ball or something missed it exploded. I thought that was clever feature. Damned if I can remember what it was or find it searching your posts.

I did comment and +1 the AI for it, I remember that!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#24
@BPlus It was my opinion of using InForm to make a game i think (and i stand by that premise of GUIs are for GUI's!)

Love ya

John
Reply
#25
(02-17-2026, 03:00 AM)Unseen Machine Wrote: @BPlus It was my opinion of using InForm to make a game i think (and i stand by that premise of GUIs are for GUI's!)

Love ya

John

No it was THIS! I found it Neon Pong! 
https://qb64phoenix.com/forum/showthread...8#pid39728

Notice when the ball hits the paddles or misses, Explosion! That was a nice touch!

I said so here:
https://qb64phoenix.com/forum/showthread...1#pid39741

So thats where Steve got idea for exploding hearts ??? LOL it's where I got mine.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#26
(02-17-2026, 03:02 AM)bplus Wrote:
(02-17-2026, 03:00 AM)Unseen Machine Wrote: @BPlus It was my opinion of using InForm to make a game i think (and i stand by that premise of GUIs are for GUI's!)

Love ya

John

No it was THIS! I found it Neon Pong! 
https://qb64phoenix.com/forum/showthread...8#pid39728

Notice when the ball hits the paddles or misses, Explosion! That was a nice touch!

I said so here:
https://qb64phoenix.com/forum/showthread...1#pid39741

So thats where Steve got idea for exploding hearts ??? LOL it's where I got mine.
So AI in at least this case is A OK!
Reply
#27
Didn't you see I am consulting AI more, I WAS impressed by that. I was consulting AI for building Pete's OS did you see that?

Yeah it B OK B+LOL
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#28
I stole my idea directly from bplus for the exploding hearts.  Big Grin
Reply
#29
I LOVE IT!
Reply
#30
Great way to end this thread but I wonder how this sounds to you guys:
https://qb64phoenix.com/forum/showthread...4#pid39964
  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)