Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 472
» Latest member: JonnyWi
» Forum threads: 2,755
» Forum posts: 26,114

Full Statistics

Latest Threads
Flying
Forum: SierraKen
Last Post: SierraKen
4 hours ago
» Replies: 0
» Views: 10
Pinball
Forum: Works in Progress
Last Post: NakedApe
9 hours ago
» Replies: 3
» Views: 43
Anyone with free time wan...
Forum: Help Me!
Last Post: bplus
Yesterday, 04:06 PM
» Replies: 19
» Views: 392
Need some help getting ch...
Forum: Help Me!
Last Post: Cobalt
Yesterday, 01:19 AM
» Replies: 6
» Views: 94
It might be useful for so...
Forum: Programs
Last Post: madscijr
11-21-2024, 10:29 PM
» Replies: 6
» Views: 319
New QBJS Samples Site
Forum: QBJS, BAM, and Other BASICs
Last Post: DANILIN
11-21-2024, 09:36 PM
» Replies: 23
» Views: 611
Ascii Christmas Tree
Forum: Christmas Code
Last Post: Pete
11-21-2024, 09:03 PM
» Replies: 1
» Views: 35
request for printing patt...
Forum: Learning Resources and Archives
Last Post: bplus
11-21-2024, 03:45 PM
» Replies: 13
» Views: 151
Literature about QuickBas...
Forum: General Discussion
Last Post: quickbasic
11-21-2024, 12:34 PM
» Replies: 17
» Views: 1,007
QB64-PE v3.14.1 is now re...
Forum: Announcements
Last Post: bplus
11-21-2024, 01:48 AM
» Replies: 13
» Views: 1,073

 
  Ok, sound experts need a couple of answers
Posted by: doppler - 11-02-2024, 04:13 PM - Forum: General Discussion - Replies (3)

First off _sndplayfile doesn't wait for completion before moving on to next program line.  Or did I miss something ? ie: two plays directs only plays the second sound.
Must use open, play handle, do/loop until sndplaying isn't.

Second with all the sound bugs fixed and a flurry of forum message about it.  (didn't follow all the threads)  Is there a way to compile sound (wav) files into the program EXE result?  Much like ICON ico files can being included inside exe.

Third is it possible to pre-load wav files into a memory array (different files at different indexes) and run from the array instead of playing files on disk?

Four  converting all the wav files to mp3 would make them smaller.  But would than be better for playing them ?  IMHO no difference.

Thanks
There is a method and purpose to my madness.

Print this item

  Should I torment Pete this weekend?
Posted by: Cobalt - 11-01-2024, 10:47 PM - Forum: General Discussion - Replies (4)

I'm going to make that "left turn at Albuquerque" and head his way, any one want to join me to torment him with "Eh, What's up doc?"


[Image: Bugs-vs-Yosemite.jpg]

Print this item

  Cross Platform Audio Book Manager
Posted by: ahenry3068 - 11-01-2024, 10:27 PM - Forum: Programs - No Replies

POSTED VOLUME CONTROL RC3 on the Commander X16 Forum  

   https://cx16forum.com/forum/viewtopic.php?p=34516#p34516  


    This is a Cross Platform Audio Book Manager Player program I've been working on.
The program started on the Commander X16 8-bit platform by David Murray 
(AKA The 8-bit Guy on Youtube).

    The Commander X16 portion of the program is 99.9% complete and the
"Cross Platform" port is underway.   Developed of course in QB64PE.

    Currently on the 64 bit side of the house I have a functional Audio
Book Player & a few utilities that help me create the book dealing
with Audio file & Graphics file conversions.   They are included with
the above file archive.     There are screen shot's and  more
in depth information on the Commander X16 forum post.    As well
the program archive does contain 2 README files and all the source
code for the program and utilities.


[Image: VCONTROL3.png]

Print this item

  SquarePrint
Posted by: SMcNeill - 11-01-2024, 03:23 AM - Forum: SMcNeill - No Replies

A simple routine to print a square text of any size font to the screen, as per Phil's request here: https://qb64phoenix.com/forum/showthread.php?tid=3182

Code: (Select All)
$Color:32
Screen _NewImage(640, 480, 32)
Color Orange, Blue
SquarePrint 0, 0, 8, "Hello World"
Color Red, Green
Sleep
SquarePrint 8, 8, 32, "Hello World"
Color Blue, Yellow
Sleep
SquarePrint 100, 100, 32, "Testing the code!"
Sleep
System


Sub SquarePrint (x, y, size As Single, text$)
    Dim As _Unsigned Long dc, bg
    If size < 4 Or size > 256 Then Exit Sub
    sz = size / 8
    tempscreen = _NewImage(_Width / size * 8, _Height / size * 8, 32)
    d = _Dest: dc = _DefaultColor: bg = _BackgroundColor
    _Dest tempscreen
    Color dc, bg: _Font 8
    _PrintString (x * 8 / size, y * 8 / size), text$
    _Dest d
    _PutImage , tempscreen
    _FreeImage tempscreen
End Sub

Print this item

  Is there a square monospace font
Posted by: PhilOfPerth - 10-31-2024, 11:28 PM - Forum: Help Me! - Replies (8)

I'm looking for a font that's monospace, and occupies the same horizontal as vertical space.
for example:
FOX
FOX
FOX
will ocucupy a square space on screen.
All the Wide fonts I've found still take extra vertical space.

Print this item

  QB64.org
Posted by: bplus - 10-31-2024, 11:44 AM - Forum: General Discussion - Replies (35)

Someone bought the old QB64.org link!
https://qb64.org

Print this item

  Pongy by SierraKen - A Different Type of Game
Posted by: SierraKen - 10-31-2024, 03:06 AM - Forum: SierraKen - Replies (7)

I named this game because of it's Pong-like characteristics, like the ball bouncing around. But it's also very different. 
The object of this game is to move the green paddle around with your mouse to hit the white ball and make it go into the moving goal above. At the same time, don't let the white ball hit the red ball or it will explode. You get 5 balls. The red ball bounces around like the white ball but you don't hit it. Enjoy!

This game has no connection whatsoever with any other game or app named Pongy. 

Here is a video of me playing it. The code is below that. To see the goal area above more clearly, expand the video. 



Code: (Select All)

'Pongy - by SierraKen
'Made on October 30, 2024

'Thanks to the QB64 Phoenix Forum for the inspiration and past help.
'Thanks also to Chat GPT for the math code.

'How to play: Use Mouse to bounce the white ball and try to aim it toward the moving goal slot above without having the white ball hit the red ball.
'You start out with 5 balls. Feel free to change the variable ball number below to your needs.


begin:
score = 0
ball = 5

' Set box boundaries
boxLeft = 25
boxRight = 775
boxTop = 25
boxBottom = 575


Cls
Screen _NewImage(800, 600, 32)
' Ball properties
Dim As Integer ballX, ballY, ballx2, bally2
Dim As Single angle, angle2
Dim As Integer speedX, speedY, speedx2, speedy2
ballX = (boxRight + boxLeft) / 2 ' Start in the center
ballY = (boxTop + boxBottom) / 2
angle = 45 ' Starting angle in degrees

ballx2 = (boxRight + boxLeft) / 2 ' Start in the center
bally2 = (boxTop + boxBottom) / 2 + 100
angle2 = 45 ' Starting angle in degrees


' Convert angle to radians
Dim As Single radAngle
radAngle = angle * 3.14159265 / 180

Dim As Single radAngle2
radAngle2 = angle2 * 3.14159265 / 180



' Set speed based on angle
speedX = Cos(radAngle) * 5
speedY = Sin(radAngle) * 5

speedx2 = Cos(radAngle2) * 5
speedy2 = Sin(radAngle2) * 5

goalx = 325: goaly = 20
goaldir = 1
redballout = 5


_Title "Pongy - by SierraKen"

Randomize Timer

Do
    Cls
    a$ = InKey$
    If a$ = Chr$(27) Then End
    ' Draw box boundaries
    Line (boxLeft - 5, boxTop - 5)-(boxRight + 5, boxBottom + 5), _RGB32(255, 255, 255), B
    Line (goalx, goaly)-(goalx + 100, goaly), _RGB32(1, 1, 1)
    goalx = goalx + goaldir
    If goalx = 680 And goaldir = 1 Then goaldir = -1
    If goalx = 20 And goaldir = -1 Then goaldir = 1
    ' Draw the ball
    fillCircle ballX, ballY, 10, _RGB32(255, 255, 255)
    If redballout = 0 Then fillCircle ballx2, bally2, 20, _RGB32(255, 0, 0)

    While _MouseInput: Wend
    mouseX = _MouseX
    mouseY = _MouseY
    fillCircle mouseX, mouseY, 20, _RGB32(0, 255, 0)

    ' Update ball position
    ballX = ballX + speedX
    ballY = ballY + speedY
    If redballout = 0 Then
        ballx2 = ballx2 + speedx2
        bally2 = bally2 + speedy2
    End If
    If ballX > goalx And ballX < goalx + 100 And ballY < 26 Then
        score = score + 1: ballX = 375: ballY = 275: speedY = -speedY
        For snd = 300 To 900 Step 50
            Sound snd, .5
        Next snd
    End If

    Locate 1, 20: Print "Score: "; score
    Locate 1, 70: Print "Balls: "; ball

    ' Check for collision with box boundaries
    If ballX <= boxLeft Or ballX >= boxRight Then
        speedX = -speedX ' Reflect on the X axis
        If redballout > 0 Then redballout = redballout - 1
        Sound 600, .5
    End If
    If ballY <= boxTop Or ballY >= boxBottom Then
        speedY = -speedY ' Reflect on the Y axis
        If redballout > 0 Then redballout = redballout - 1
        Sound 600, .5
    End If
    If ballY > boxBottom + .4 Then ballY = boxBottom - 7
    If ballY < boxTop - .4 Then ballY = boxTop + 7
    If ballX > boxRight + .4 Then ballX = boxRight - 7
    If ballX < boxLeft - .4 Then ballX = boxLeft + 7
    If redballout > 0 Then GoTo skip:
    If ballx2 <= boxLeft Or ballx2 >= boxRight Then
        speedx2 = -speedx2 ' Reflect on the X axis
        Sound 600, .5
    End If
    If bally2 <= boxTop Or bally2 >= boxBottom Then
        speedy2 = -speedy2 ' Reflect on the Y axis
        Sound 600, .5
    End If
    If bally2 > boxBottom + .4 Then bally2 = boxBottom - 7
    If bally2 < boxTop - .4 Then bally2 = boxTop + 7
    If ballx2 > boxRight + .4 Then ballx2 = boxRight - 7
    If ballx2 < boxLeft - .4 Then ballx2 = boxLeft + 7
    skip:

    ' Check for collision with mouse position
    If Sqr((mouseX - ballX) ^ 2 + (mouseY - ballY) ^ 2) < 40 Then
        ' Calculate deflection angle
        radAngle = _Atan2(ballY - mouseY, ballX - mouseX) ' * 180 / 3.14159265
        'radAngle = angle * 3.14159265 / 180
        speedX = Cos(radAngle) * 5
        speedY = Sin(radAngle) * 5
        ballX = ballX + speedX
        ballY = ballY + speedY
        Sound 600, .5
    End If

    ' Check for collision between red ball and white ball.
    If redballout > 0 Then GoTo skip2:
    If Sqr((ballx2 - ballX) ^ 2 + (bally2 - ballY) ^ 2) < 50 Then
        fillCircle ballX, ballY, 20, _RGB32(0, 0, 0)
        snd = 300
        _AutoDisplay
        starx = ballX: stary = ballY
        For t = 1 To 25
            fillCircle starx, stary, t * 5, _RGB32(255, 255, 255)
            Sound snd - t, .5
        Next t
        redballout = 5
        Locate 1, 70: ball = ball - 1: Print "Balls: "; ball
        If ball = 0 Then
            _AutoDisplay
            Locate 20, 40: Print "G A M E  O V E R":
            Locate 25, 40
            Print "Again (Y/N)?"
            ask:
            ag$ = InKey$
            If ag$ = "y" Or ag$ = "Y" Then GoTo begin:
            If ag$ = "n" Or ag$ = "N" Then End
            GoTo ask:
        End If
        Sound 600, .5
    End If
    skip2:

    _Display
    _Limit 60 ' Limit the speed of the loop to 60 FPS
Loop Until InKey$ <> ""


'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

Print this item

  Replace routine
Posted by: Pete - 10-31-2024, 12:11 AM - Forum: Help Me! - Replies (3)

Have you guys noticed that "wrap" on searches like Notepad only work when a line-break in not encountered? That makes sense, I guess, but what if you wanted to ignore those line-breaks and find what you are looking for, anyway?

Pete is
tremendous but
Steve is just amazing.

So search that for Pete is tremendous. No go in most html editors or Notepad. I don't Word or OpenOffice, anymore, so I don't know if they would find the search or not.

Anyway, I got a little burned out with trying a strict math model to accomplish this, so I combined a math and string replacement method to get the job done. It's super fast, but it has a drawback in that the file being searched cannot contain 3 substitute string characters I used to handle the line-break situation. Chr$(1), Chr$(3), and Chr$(4). Us SCREEN 0 card programmers are screwed for diamonds and hearts!

So I'm curious if anyone has coded this and figured out a pure math method? 

Now the routine itself is actually very useful for html files, which often contain text broken up on different lines. I coded it to preserve line-breaks. I have not, and may not go to the extent of perfect line-break mirroring, as that would require checking the for the nearest space in the replacement term instead of stacking the line-breaks onto the end. Yes, it can handle search and replace over multiple line-breaks. For instance...

Pete is
tremendous but

Steve is just amazing.

Search for: Pete is tremendous
Replace with: Pete is TREMENDOUS

The results with my routine would be...

Pete is TREMENDOUS

but
Steve is just amazing.

instead of...

Pete is
TREMENDOUS but

Steve is just amazing.
----------------------------------------
So not an exact mirror, but it does get the job, essentially, done.

Here's the code. It won't change any of your files, or make any new ones. It just loads the edited content to your clipboard and opens Notepad. You can paste it in to view it. Just pick a text file (.bas, .txt, .html, etc.), or make a test file, to try it out.

Code: (Select All)
Width 80, 25: _Font 16: _ScreenMove _Middle
Print "Opening file dialog..."
target$ = _OpenFileDialog$("Open a file to to be searched:", "", "*.*", "", 0)
If target$ = "" Then System
Print: Print "This routine copies the contents of the file to your clipboard.": Print
search:
If _FileExists(target$) Then Else Print "Error, file not found: " + target$: End
Dim As Integer seed, q, j, k, i1, i3, i4
Open target$ For Binary As #1
a$ = Space$(LOF(1))
Get #1, , a$
Close #1
Line Input "Search for:  ", find$: Print
Line Input "Replace with: ", replace$: Print
If find$ <> replace$ Then
    a2$ = a$: c = 0
    Do ' Strip out line-breaks and substitute space for a single line-break.
        q = InStr(seed, a$, Chr$(13) + Chr$(10))
        If q Then
            If Mid$(a$, q + 2, 2) = Chr$(13) + Chr$(10) Or Mid$(a$, q + 2) = "" Then
                sp$ = "": sp2$ = ""
                For j = 0 To Len(a2$) Step 2
                    If Mid$(a2$, q + j, 2) <> Chr$(13) + Chr$(10) Then Exit For
                Next
                If j Then lb = lb + 1: ReDim _Preserve line_break(lb) As Integer: line_break(lb) = j / 2
            Else
                sp$ = " ": sp2$ = Chr$(1): If j Then sp2$ = Chr$(3)
                j = 0
            End If
            a$ = Mid$(a$, 1, q - 1) + sp$ + Mid$(a$, q + 2)
            a2$ = Mid$(a2$, 1, q - 1) + sp2$ + Mid$(a2$, q + 2)
            seed = q
        Else
            Exit Do
        End If
        c = c + 1: If c > 1000 Then Print "Oops. We went over 1000 loops without completing the routine.": End ' For beta version this prevents an endless loop for any unhandled condition.
    Loop
    seed = 1
    Do ' Find and Replace.
        q = InStr(seed, LCase$(a$), LCase$(find$))
        If q And Len(find$) <> 0 Then
            Mid$(a2$, q, 1) = Chr$(4)
            seed = q + Len(find$)
        Else
            Exit Do
        End If
    Loop
    j = 0: a$ = "" ' Reconstruct.
    Do
        i1 = InStr(a2$, Chr$(1))
        i3 = InStr(a2$, Chr$(3))
        i4 = InStr(a2$, Chr$(4))
        While -1
            If i1 Then
                If i1 < i3 Or i3 = 0 Then
                    If i1 < i4 Or i4 = 0 Then
                        q = i1
                        x$ = Chr$(13) + Chr$(10)
                        GoSub assemble
                        Exit While
                    End If
                End If
            End If
            If i3 Then
                If i3 < i1 Or i1 = 0 Then
                    If i3 < i4 Or i4 = 0 Then
                        q = i3
                        j = j + 1: x$ = ""
                        For k = 1 To line_break(j): x$ = x$ + Chr$(13) + Chr$(10): Next
                        GoSub assemble
                        Exit While
                    End If
                End If
            End If
            If i4 Then
                If i4 < i1 Or i1 = 0 Then
                    If i4 < i3 Or i3 = 0 Then
                        x$ = replace$
                        q = i4
                        GoSub assemble
                        x$ = Mid$(a2$, 1, Len(find$))
                        For i = 1 To Len(find$)
                            Select Case Mid$(a2$, i, 1)
                                Case Chr$(1)
                                    lb$ = Chr$(13) + Chr$(10)
                                Case Chr$(3)
                                    j = j + 1: x$ = ""
                                    For k = 1 To line_break(j): lb$ = lb$ + Chr$(13) + Chr$(10): Next
                            End Select
                        Next
                        a$ = a$ + lb$: lb$ = ""
                        q = Len(find$)
                        If Mid$(a2$, q, 1) = " " And Right$(a$, 2) = Chr$(13) + Chr$(10) Then q = q + 1 ' Remove leading space.
                        a2$ = Mid$(a2$, q)
                        Exit While
                    End If
                End If
            End If
            a$ = a$ + a2$: a2$ = "": Exit Do ' End of file.
            Exit While
        Wend
    Loop
End If
Print "Finished. Do a Notepad paste to view results. (Opening Notepad...)": Print
Print: Print "[Enter] Run  [Tab] Search this file again.  [Esc] Quit"
Shell _DontWait _Hide "start notepad"
_Clipboard$ = a$
Sleep
Select Case InKey$
    Case Chr$(13): Cls: _Delay .5: Run
    Case Chr$(27): System
    Case Chr$(9): Cls: GoTo search
End Select
System

assemble:
a$ = a$ + Mid$(a2$, 1, q - 1) + x$
a2$ = Mid$(a2$, q + 1)
Return

Basically I'm just curious about my approach, different approaches, and use. If you can think of another use, different output, or different build approach, I'd enjoy reading the comments and engaging in the conversation.

Pete

Print this item

  Pongy - A Different Type of Game
Posted by: SierraKen - 10-30-2024, 10:13 PM - Forum: Games - Replies (6)

You move the big green paddle anywhere you want hitting the white ball to try and aim for the moving goal up above. At the same time try not to have the white ball hit the larger moving red ball. When the red ball hits the white ball, you lose a white ball. You start out with 5. I don't know if anyone has made this yet, but I think it's fun. My high score so far is 17. 
I used Chat GPT for some of the math code because I've always been terrible with math. But tell me what you think, thanks. 

Code: (Select All)

'Pongy - by SierraKen
'Made on October 30, 2024

'Thanks to the QB64 Phoenix Forum for the inspiration and past help.
'Thanks also to Chat GPT for the math code.

'How to play: Use Mouse to bounce the white ball and try to aim it toward the moving goal slot above without having the white ball hit the red ball.
'You start out with 5 balls. Feel free to change the variable ball number below to your needs.

begin:
score = 0
ball = 5

' Set box boundaries
boxLeft = 25
boxRight = 775
boxTop = 25
boxBottom = 575

Cls
Screen _NewImage(800, 600, 32)
' Ball properties
Dim As Integer ballX, ballY, ballx2, bally2
Dim As Single angle, angle2
Dim As Integer speedX, speedY, speedx2, speedy2
ballX = (boxRight + boxLeft) / 2 ' Start in the center
ballY = (boxTop + boxBottom) / 2
angle = 45 ' Starting angle in degrees

ballx2 = (boxRight + boxLeft) / 2 ' Start in the center
bally2 = (boxTop + boxBottom) / 2 + 100
angle2 = 45 ' Starting angle in degrees

' Convert angle to radians
Dim As Single radAngle
radAngle = angle * 3.14159265 / 180

Dim As Single radAngle2
radAngle2 = angle2 * 3.14159265 / 180

' Set speed based on angle
speedX = Cos(radAngle) * 5
speedY = Sin(radAngle) * 5

speedx2 = Cos(radAngle2) * 5
speedy2 = Sin(radAngle2) * 5

goalx = 325: goaly = 20
goaldir = 1
redballout = 5


_Title "Pongy - by SierraKen"

Randomize Timer

Do
    Cls
    a$ = InKey$
    If a$ = Chr$(27) Then End
    ' Draw box boundaries
    Line (boxLeft - 5, boxTop - 5)-(boxRight + 5, boxBottom + 5), _RGB32(255, 255, 255), B
    Line (goalx, goaly)-(goalx + 100, goaly), _RGB32(1, 1, 1)
    goalx = goalx + goaldir
    If goalx = 680 And goaldir = 1 Then goaldir = -1
    If goalx = 20 And goaldir = -1 Then goaldir = 1
    ' Draw the ball
    'Circle (ballX, ballY), 5, 14
    fillCircle ballX, ballY, 10, _RGB32(255, 255, 255)
    If redballout = 0 Then fillCircle ballx2, bally2, 20, _RGB32(255, 0, 0)

    While _MouseInput: Wend
    mouseX = _MouseX
    mouseY = _MouseY
    fillCircle mouseX, mouseY, 20, _RGB32(0, 255, 0)

    ' Update ball position
    ballX = ballX + speedX
    ballY = ballY + speedY
    If redballout = 0 Then
        ballx2 = ballx2 + speedx2
        bally2 = bally2 + speedy2
    End If
    If ballX > goalx And ballX < goalx + 100 And ballY < 26 Then
        score = score + 1: ballX = 375: ballY = 275: speedY = -speedY
        For snd = 300 To 900 Step 50
            Sound snd, .5
        Next snd
    End If

    Locate 1, 20: Print "Score: "; score
    Locate 1, 70: Print "Balls: "; ball

    ' Check for collision with box boundaries
    If ballX <= boxLeft Or ballX >= boxRight Then
        speedX = -speedX ' Reflect on the X axis
        If redballout > 0 Then redballout = redballout - 1
        Sound 600, .5
    End If
    If ballY <= boxTop Or ballY >= boxBottom Then
        speedY = -speedY ' Reflect on the Y axis
        If redballout > 0 Then redballout = redballout - 1
        Sound 600, .5
    End If
    If ballY > boxBottom + 3 Then ballY = boxBottom - 5
    If ballY < boxTop - 3 Then ballY = boxTop + 5
    If ballX > boxRight + 3 Then ballX = boxRight - 5
    If ballX < boxLeft - 3 Then ballX = boxLeft + 5
    If redballout > 0 Then GoTo skip:
    If ballx2 <= boxLeft Or ballx2 >= boxRight Then
        speedx2 = -speedx2 ' Reflect on the X axis
        Sound 600, .5
    End If
    If bally2 <= boxTop Or bally2 >= boxBottom Then
        speedy2 = -speedy2 ' Reflect on the Y axis
        Sound 600, .5
    End If
    If bally2 > boxBottom + 3 Then bally2 = boxBottom - 5
    If bally2 < boxTop - 3 Then bally2 = boxTop + 5
    If ballx2 > boxRight + 3 Then ballx2 = boxRight - 5
    If ballx2 < boxLeft - 3 Then ballx2 = boxLeft + 5
    skip:

    ' Check for collision with mouse position
    If Sqr((mouseX - ballX) ^ 2 + (mouseY - ballY) ^ 2) < 40 Then
        ' Calculate deflection angle
        angle = _Atan2(ballY - mouseY, ballX - mouseX) * 180 / 3.14159265
        radAngle = angle * 3.14159265 / 180
        speedX = Cos(radAngle) * 5
        speedY = Sin(radAngle) * 5
        ballX = ballX + speedX
        ballY = ballY + speedY
        Sound 600, .5
    End If

    ' Check for collision between red ball and white ball.
    If redballout > 0 Then GoTo skip2:
    If Sqr((ballx2 - ballX) ^ 2 + (bally2 - ballY) ^ 2) < 50 Then
        fillCircle ballX, ballY, 20, _RGB32(0, 0, 0)
        snd = 300
        _AutoDisplay
        starx = ballX: stary = ballY
        For t = 1 To 25
            fillCircle starx, stary, t * 5, _RGB32(255, 255, 255)
            Sound snd - t, .5
        Next t
        redballout = 5
        Locate 1, 70: ball = ball - 1: Print "Balls: "; ball
        If ball = 0 Then
            _AutoDisplay
            Locate 20, 40: Print "G A M E  O V E R":
            Locate 25, 40
            Print "Again (Y/N)?"
            ask:
            ag$ = InKey$
            If ag$ = "y" Or ag$ = "Y" Then GoTo begin:
            If ag$ = "n" Or ag$ = "N" Then End
            GoTo ask:
        End If
        Sound 600, .5
    End If
    skip2:

    _Display
    _Limit 60 ' Limit the speed of the loop to 60 FPS
Loop Until InKey$ <> ""


'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

Print this item

  The House of Many Doors
Posted by: rickclark58 - 10-29-2024, 08:43 PM - Forum: Games - Replies (2)

I made a short text adventure game. I put it on my Google Drive so I hope I set it up correctly. When you run it, you will get the Windows Popup. It is safe to run. I included the source code in case you want to look at it or compile it yourself.
https://drive.google.com/file/d/1qQR_HQ-...sp=sharing

Print this item