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,754
» Forum posts: 26,111

Full Statistics

Latest Threads
Literature about QuickBas...
Forum: General Discussion
Last Post: quickbasic
17 minutes ago
» Replies: 17
» Views: 943
request for printing patt...
Forum: Learning Resources and Archives
Last Post: SMcNeill
10 hours ago
» Replies: 10
» Views: 89
QB64-PE v3.14.1 is now re...
Forum: Announcements
Last Post: bplus
11 hours ago
» Replies: 13
» Views: 1,016
Pool
Forum: Games
Last Post: JRace
Yesterday, 11:34 PM
» Replies: 49
» Views: 2,773
Detect point in triangle ...
Forum: Petr
Last Post: Petr
Yesterday, 07:31 PM
» Replies: 2
» Views: 50
Bally 1088 Slot Machine
Forum: Works in Progress
Last Post: Trial And Terror
11-19-2024, 10:08 PM
» Replies: 0
» Views: 45
It might be useful for so...
Forum: Programs
Last Post: madscijr
11-19-2024, 01:41 PM
» Replies: 3
» Views: 275
Pipes Puzzle - Maze conne...
Forum: Dav
Last Post: Dav
11-19-2024, 01:30 PM
» Replies: 10
» Views: 756
Anyone with free time wan...
Forum: Help Me!
Last Post: Kernelpanic
11-19-2024, 12:50 PM
» Replies: 17
» Views: 306
Bite operations with ShL ...
Forum: Petr
Last Post: Pete
11-19-2024, 01:03 AM
» Replies: 7
» Views: 142

 
  random numbers
Posted by: badger - 11-06-2024, 11:15 PM - Forum: General Discussion - Replies (8)

Hello

can someone tell me why this little program will not work i dont really understand why.

badger

thanks in advance

Code: (Select All)
DECLARE SUB GenerateUniqueNumbers()

DIM numbers(5) AS INTEGER
DIM count AS INTEGER
DIM i AS INTEGER
DIM newNumber AS INTEGER
DIM isDuplicate AS INTEGER

SUB GenerateUniqueNumbers
    count = 0
    DO
        ' Generate a random number between -1 and 71
        newNumber = INT(RND * 73) - 1
        isDuplicate = 0

        ' Check if the number is already in the array
        FOR i = 1 TO count
            IF numbers(i) = newNumber THEN
                isDuplicate = 1
                EXIT FOR
            END IF
        NEXT i

        ' If it's not a duplicate, add it to the array
        IF isDuplicate = 0 THEN
            count = count + 1
            numbers(count) = newNumber
        END IF
    LOOP UNTIL count = 5

    ' Print the selected numbers
    PRINT "The 5 unique numbers are:"
    FOR i = 1 TO 5
        PRINT numbers(i)
    NEXT i
END SUB

' Seed the random number generator
RANDOMIZE TIMER

' Call the subroutine to generate and display the numbers
GenerateUniqueNumbers

Print this item

  Cursor is showing low in graphics screen
Posted by: PhilOfPerth - 11-06-2024, 02:06 AM - Forum: Help Me! - Replies (2)

I'm trying to use mouse functions to identify points on the screen, but noticed the corsor is displaying about 5 pixels below its actual point. Is this something unique to my system? I know I can compensate with my zone positions, but just curious. Try this:

Code: (Select All)
Screen _NewImage(1040, 768, 32)

PSet (175, 175)
For a = 1 To 7: Draw "d28r26u28l26r26": Next

GetMouse:
While _MouseInput
    X = _MouseX: Y = _MouseY
    Locate 2, 2: Print X, Y
Wend
GoTo GetMouse
 I want to select each cell accurately by mouse pointer, but the pointer is about 5 pixels low.

Print this item

  The greatest common divisor of two numbers
Posted by: Petr - 11-04-2024, 07:16 PM - Forum: Petr - Replies (3)

Hi. I think this might be a useful feature for someone.

inspired by: https://demonstrations.wolfram.com/Findi...Factoring/

Code: (Select All)

NumA = 1000
NumB = 552
E = GreatestCommonDivisor(NumA, NumB)
Print "Greatest Common Divisor for"; NumA; "and"; NumB; " is:"; E
End


Function GreatestCommonDivisor& (A As Long, B As Long)
    If A = 0 And Abs(B) > 0 Then GreatestCommonDivisor& = B: Exit Function
    If B = 0 And Abs(A) > 0 Then GreatestCommonDivisor& = A: Exit Function
    If A = 0 And B = 0 Then GreatestCommonDivisor& = 0: Exit Function
    Dim As Long NrA(0)
    Dim As Long NrB(0)
    Dim As Long i, NrAI, NrBI, NumA, NumB

    NumA = A
    i = 1
    Do Until i >= NumA
        i = i + 1
        If NumA Mod i = 0 Then
            NumA = NumA \ i
            NrA(NrAI) = i
            NrAI = NrAI + 1
            ReDim _Preserve NrA(NrAI) As Long
            i = 1
        End If
    Loop

    NumB = B
    i = 1
    Do Until i >= NumB
        i = i + 1
        If NumB Mod i = 0 Then
            NumB = NumB \ i
            NrB(NrBI) = i
            NrBI = NrBI + 1
            ReDim _Preserve NrB(NrBI) As Long
            i = 1
        End If
    Loop

    Dim Outs(0) As Long
    Do Until ArrA = UBound(NrA) 
        If ArrA > UBound(NrA) Then Exit Do
        NumA = NrA(ArrA)
        ArrB = 0
        Do Until ArrB = UBound(NrB) 
            If ArrB > UBound(NrB) Then Exit Do
            NumB = NrB(ArrB)
            If NumA > 0 And NumB > 0 Then
                If NumA = NumB Then
                    Pass = 1
                    Outs(outI) = NumA
                    outI = outI + 1
                    ReDim _Preserve Outs(outI) As Long
                    NrA(ArrA) = -1 'just rewrite used numbers to wrong values (so the same valid is not used twice)
                    NrB(ArrB) = -1
                    Exit Do
                End If
            End If
            ArrB = ArrB + 1
        Loop
        ArrA = ArrA + 1
    Loop

    If UBound(Outs) > 0 Then
        ReDim _Preserve Outs(UBound(Outs) - 1) As Long
    End If
    Erase NrA
    Erase NrB
    If Pass = 0 Then
        GreatestCommonDivisor& = 1
        Erase Outs
        Exit Function
    End If
    'calculate greatest common divisor
    GCD& = Outs(0)
    For o = 1 To UBound(Outs)
        GCD& = GCD& * Outs(o)
    Next
    Erase Outs
    GreatestCommonDivisor& = GCD&
End Function

Print this item

  Galleon - New Member?
Posted by: Dimster - 11-04-2024, 03:48 PM - Forum: General Discussion - Replies (5)

Hello Galleon - heard so much about you. All good!

Print this item

  Setting Line _RGB colours
Posted by: PhilOfPerth - 11-03-2024, 12:46 AM - Forum: Help Me! - Replies (10)

How can I convert this line:

Line (H, V)-(H+ 37, V+ 38), _RGB(200, 200, 200), BF

to set the _RGB colour to a colour in a sub, instead of this fixed colour?  (I'm using a _NewImage 32-bit screen)
Sub Red might contain Color: _RGB(255,0,0)

Print this item

Question Memory full when loading multiple images
Posted by: Ikerkaz - 11-02-2024, 10:52 PM - Forum: Help Me! - Replies (7)

Hi to all !!!

I will try to explain myself with my limited english ?

I am making a space shooting/strategy game that loads multiple images. I have a main image (ship) and when it is attacked I load two different images in other two layers (shields impact, damages made to the ship). Last thing I do is _PUTIMAGE of these three layers. During the game I use _LOADIMAGE to change the images of these layers, and there are several ships in the game with the same three layers.

I noticed that when I start my game, the Windows task manager shows some RAM used, and as I am playing it this RAM is increasing.

I know the _FREEIMAGE command, but my code is very large and I find very difficult to check when to use it...

Also I noticed that when I execute a _LOADIMAGE command, and some time later I execute this command over the same variable the memory is still increasing. I thought that when using the same variable the RAM occupied was the same... obviously I was wrong Sad

Is there any way to re-use some LONG variable to load several images without having to _FREEIMAGE between every load? I thought to make a SUB that makes a _FREEIMAGE in the variable just before load an image, but it goes wrong a lot of times Sad

Anybody can help me? Thank you !!! Smile

Print this item

  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