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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 492
» Latest member: Feederumn
» Forum threads: 2,833
» Forum posts: 26,550

Full Statistics

Latest Threads
sleep command in compiler...
Forum: General Discussion
Last Post: doppler
3 hours ago
» Replies: 2
» Views: 60
which day of the week
Forum: Programs
Last Post: Stuart
3 hours ago
» Replies: 30
» Views: 655
Another Dir/File compare ...
Forum: Utilities
Last Post: eoredson
10 hours ago
» Replies: 0
» Views: 34
Problems with QBJS
Forum: Help Me!
Last Post: hsiangch_ong
Today, 02:31 AM
» Replies: 3
» Views: 75
another variation of "10 ...
Forum: Programs
Last Post: hsiangch_ong
Today, 02:26 AM
» Replies: 2
» Views: 95
Aloha from Maui guys.
Forum: General Discussion
Last Post: madscijr
Yesterday, 04:33 PM
» Replies: 8
» Views: 147
Playing sound files in QB...
Forum: Programs
Last Post: ahenry3068
Yesterday, 05:37 AM
» Replies: 9
» Views: 1,189
Rock Jockey 2.0 is ready ...
Forum: Games
Last Post: NakedApe
01-09-2025, 09:02 PM
» Replies: 20
» Views: 623
Button rack or hotkey fun...
Forum: Utilities
Last Post: Jack002
01-09-2025, 08:20 PM
» Replies: 6
» Views: 406
ANSIPrint
Forum: a740g
Last Post: bplus
01-09-2025, 05:36 PM
» Replies: 11
» Views: 226

 
  BAM: starting to use railroad diagrams to document syntax
Posted by: CharlieJV - 06-20-2023, 02:19 AM - Forum: QBJS, BAM, and Other BASICs - No Replies

For example, the MAX function.

Print this item

  Fisher Yates Shuffle for cards or any number of items
Posted by: bplus - 06-19-2023, 11:19 PM - Forum: Utilities - Replies (4)

As discussed in Ranking Poker Hands:

Code: (Select All)
TopN = 52
ReDim n(1 To TopN) 'repeatable for ref
For i = 1 To TopN
    n(i) = i
Next
For i = TopN To 2 Step -1 ' Fisher Yates Shuffle of N Items
    Swap n(i), n(Int(Rnd * (i) + 1))
Next
For i = 1 To TopN
    Print "  "; i; "-"; n(i); Chr$(9);
Next
Print

At maximum you need only swap n-1 items!

Print this item

  Drawcards
Posted by: James D Jarvis - 06-19-2023, 08:49 PM - Forum: Programs - Replies (8)

Ascii card drawing routine and a simple deck shuffling routine. I'm using the 8x8 font set but it's in "amazing" RGB32 graphics!

Code: (Select All)
'drawcards v1
'ascii playing cards but for 32 bit graphics
'by James D. Jarvis
'use as you wish
Screen _NewImage(480, 288, 32)
_Font 8
_FullScreen
Color _RGB32(5, 5, 5), _RGB32(250, 250, 250)
_ControlChr Off
Dim Shared card$(0 To 52)
_Title "DRAWCARDS v1.0"
buildcards 'got to build the deck
Do
    shuffledeck 'shuffle the whole deck
    'just a demo of the first 21 cards laid out  after shuffling hte deck
    drawcard 0, 10, card$(1)
    drawcard 50, 10, card$(2)
    drawcard 100, 10, card$(3)
    drawcard 150, 10, card$(4)
    drawcard 200, 10, card$(5)
    drawcard 250, 10, card$(6)
    drawcard 300, 10, card$(7)

    drawcard 50, 110, card$(8)
    drawcard 80, 115, card$(9)
    drawcard 110, 120, card$(10)
    drawcard 140, 125, card$(11)
    drawcard 170, 120, card$(12)
    drawcard 200, 115, card$(13)
    drawcard 230, 110, card$(14)

    drawcard 300, 90, card$(15)
    drawcard 320, 105, card$(16)
    drawcard 340, 120, card$(17)
    drawcard 360, 135, card$(18)
    drawcard 380, 150, card$(19)
    drawcard 400, 165, card$(20)
    drawcard 420, 180, card$(21)

    _PrintString (10, 250), "Press any key to reshuffle, <esc> to quit"
    Do
        _Limit 60
        kk$ = InKey$
    Loop Until kk$ <> ""
Loop Until kk$ = Chr$(27)
Sub buildcards
    'build a deck of cards
    Dim cc$(13)
    Dim st$(4)
    cc$(1) = "A": cc$(10) = "T": cc$(11) = "J": cc$(12) = "Q": cc$(13) = "K"
    cc$(2) = "2": cc$(3) = "3": cc$(4) = "4": cc$(5) = "5": cc$(6) = "6": cc$(7) = "7": cc$(8) = "8": cc$(9) = "9"
    st$(1) = "H": st$(2) = "C": st$(3) = "S": st$(4) = "D"
    c = 0
    For ss = 1 To 4
        For rr = 1 To 13
            c = c + 1
            card$(c) = cc$(rr) + st$(ss)
        Next rr
    Next ss
End Sub

Sub shuffledeck
    'shuffle the whole deck by randomly swapping pairs of cards
    For x = 1 To 676 'this should sort the deck enoguh
        a = Int(1 + Rnd * 52)
        Do
            b = Int(1 + Rnd * 52)
        Loop Until a <> b
        Swap card$(a), card$(b)
    Next x
End Sub

Sub drawcard (cx, cy, card$)
    'draws a ascii graphics card using the 8x8 fonts
    Dim klr As _Unsigned Long
    suit$ = Mid$(card$, 2, 1)
    rank$ = Mid$(card$, 1, 1)
    st = 0
    _PrintString (cx, cy), Chr$(201) + Chr$(205) + Chr$(205) + Chr$(205) + Chr$(187)
    _PrintString (cx, cy + 8), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 16), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 24), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 32), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 40), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 48), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 56), Chr$(186) + Chr$(32) + Chr$(32) + Chr$(32) + Chr$(186)
    _PrintString (cx, cy + 64), Chr$(200) + Chr$(205) + Chr$(205) + Chr$(205) + Chr$(188)
    Select Case suit$
        Case "H"
            st = 3
            klr = _RGB32(250, 0, 0)
        Case "C"
            st = 5
            klr = _RGB32(50, 50, 50)
        Case "S"
            st = 6
            klr = _RGB32(50, 50, 50)
        Case "D"
            st = 4
            klr = _RGB32(250, 0, 0)
    End Select
    Color klr, _RGB32(250, 250, 250)
    Select EveryCase rank$
        Case "2", "3"
            _PrintString (cx + 8, cy + 8), Chr$(Asc(rank$))
            _PrintString (cx + 8, cy + 48), Chr$(st)
            _PrintString (cx + 24, cy + 16), Chr$(st)
            _PrintString (cx + 24, cy + 56), Chr$(Asc(rank$))
        Case "4", "5"
            _PrintString (cx + 8, cy + 16), Chr$(st)
            _PrintString (cx + 8, cy + 48), Chr$(st)
            _PrintString (cx + 24, cy + 16), Chr$(st)
            _PrintString (cx + 24, cy + 48), Chr$(st)
        Case "6", "7"
            _PrintString (cx + 8, cy + 16), Chr$(st)
            _PrintString (cx + 8, cy + 32), Chr$(st)
            _PrintString (cx + 8, cy + 48), Chr$(st)
            _PrintString (cx + 24, cy + 16), Chr$(st)
            _PrintString (cx + 24, cy + 32), Chr$(st)
            _PrintString (cx + 24, cy + 48), Chr$(st)
        Case "8", "9"
            _PrintString (cx + 8, cy + 16), Chr$(st)
            _PrintString (cx + 8, cy + 24), Chr$(st)
            _PrintString (cx + 8, cy + 40), Chr$(st)
            _PrintString (cx + 8, cy + 48), Chr$(st)
            _PrintString (cx + 24, cy + 16), Chr$(st)
            _PrintString (cx + 24, cy + 24), Chr$(st)
            _PrintString (cx + 24, cy + 40), Chr$(st)
            _PrintString (cx + 24, cy + 48), Chr$(st)
        Case "T"
            _PrintString (cx + 8, cy + 8), "10"
            _PrintString (cx + 8, cy + 16), Chr$(st)
            _PrintString (cx + 8, cy + 24), Chr$(st)
            _PrintString (cx + 8, cy + 32), Chr$(st)
            _PrintString (cx + 8, cy + 40), Chr$(st)
            _PrintString (cx + 8, cy + 48), Chr$(st)
            _PrintString (cx + 24, cy + 16), Chr$(st)
            _PrintString (cx + 24, cy + 24), Chr$(st)
            _PrintString (cx + 24, cy + 32), Chr$(st)
            _PrintString (cx + 24, cy + 40), Chr$(st)
            _PrintString (cx + 24, cy + 48), Chr$(st)
            _PrintString (cx + 16, cy + 56), "10"

        Case "A", "3", "5", "7", "9"
            _PrintString (cx + 16, cy + 32), Chr$(st)
        Case "J"
            _PrintString (cx + 12, cy + 26), Chr$(192) + Chr$(217)
            _PrintString (cx + 16, cy + 26), Chr$(193)

        Case "Q"
            _PrintString (cx + 8, cy + 26), Chr$(192) + Chr$(st) + Chr$(217)
            _PrintString (cx + 10, cy + 32), Chr$(40)
            _PrintString (cx + 24, cy + 32), Chr$(41)
        Case "K"
            _PrintString (cx + 16, cy + 18), Chr$(215)
            _PrintString (cx + 8, cy + 26), Chr$(200) + Chr$(202) + Chr$(188)
            _PrintString (cx + 16, cy + 38), Chr$(31)
        Case "J", "Q", "K"
            _PrintString (cx + 8, cy + 8), Chr$(Asc(rank$)) + Chr$(st)
            _PrintString (cx + 16, cy + 32), Chr$(1)
        Case "2", "3", "4", "5", "6", "7", "8", "9", "A", "J", "Q", "K"
            _PrintString (cx + 8, cy + 8), Chr$(Asc(rank$))
            _PrintString (cx + 24, cy + 56), Chr$(Asc(rank$))
    End Select
    Color _RGB32(5, 5, 5), _RGB32(250, 250, 250)
End Sub

Print this item

  Audio Presentation of Number
Posted by: bplus - 06-18-2023, 11:06 PM - Forum: Programs - No Replies

Using a Sound for Lowest Prime Divisor:

Code: (Select All)
' Audio presentation of numbers.bas for QB64 fork (B+=MGA) 2017-09-20
' Using Owens 2X Deluxe Mod
_Title "Audio Presentation of Numbers as Primes = 0 or First Factor"
_Define A-Z As _INTEGER64
Option Base 1
Common Shared ff(), topN
topN = 1000000
testlimitN = Sqr(topN)
Dim ff(topN + 30)
For i = 0 To topN Step 30
    ff(i + 2) = 2: ff(i + 3) = 3: ff(i + 4) = 2: ff(i + 5) = 5: ff(i + 6) = 2: ff(i + 8) = 2: ff(i + 9) = 3
    ff(i + 10) = 2: ff(i + 12) = 2: ff(i + 14) = 2: ff(i + 15) = 3: ff(i + 16) = 2: ff(i + 18) = 2
    ff(i + 20) = 2: ff(i + 21) = 3: ff(i + 22) = 2: ff(i + 24) = 2: ff(i + 25) = 5
    ff(i + 26) = 2: ff(i + 27) = 3: ff(i + 28) = 2: ff(i + 30) = 2
Next
ff(2) = 0: ff(3) = 0: ff(5) = 0
pattern(1) = 4: pattern(2) = 2: pattern(3) = 4: pattern(4) = 2
pattern(5) = 4: pattern(6) = 6: pattern(7) = 2: pattern(8) = 6
pcand = 7: patternI = 0
While pcand < testlimitN
    If ff(pcand) = 0 Then
        i = pcand * pcand
        patternI2 = patternI
        Do
            If ff(i) = 0 Then ff(i) = pcand
            patternI2 = patternI2 + 1
            If patternI2 = 9 Then patternI2 = 1
            i = i + pattern(patternI2) * pcand
            If i > topN Then Exit Do
        Loop

    End If
    patternI = patternI + 1
    If patternI = 9 Then patternI = 1
    pcand = pcand + pattern(patternI)
Wend
For i = 2 To topN
    Cls
    Print i, ff(i)
    If ff(i) = 0 Then Sound 137, 2 Else Sound 137 + (ff(i) Mod 30) * 10, 2 - ff(i) * .001
    _Limit 60
Next

Print this item

Music PLAY musak!
Posted by: mnrvovrfc - 06-18-2023, 08:51 PM - Forum: Works in Progress - Replies (25)

Well here it is, musak! But this is just one example. If allowed it plays five songs at a time, each song is about a minute long. Press [ESC] key to leave.

Code: (Select All)
'by mnrvovrfc 18-June-2023
'requires QB64 Phoenix Edition v3.8 or later
OPTION _EXPLICIT

REDIM scales(1 TO 1) AS STRING
DIM sequ(1 TO 2, 1 TO 20) AS INTEGER
DIM SHARED thiscale(1 TO 5) AS INTEGER, altscale(1 TO 5) AS INTEGER
DIM AS INTEGER i, lscales, song, si, so, u, basenote, numnote, athird
DIM AS INTEGER down
DIM e$

RANDOMIZE TIMER

RESTORE scaleslist
READ e$
DO UNTIL e$ = "END"
lscales = lscales + 1
IF lscales > 1 THEN
REDIM _PRESERVE scales(1 TO lscales) AS STRING
END IF
scales(lscales) = e$
READ e$
LOOP

PRINT "Now if only we have some animation!"
_TITLE "Press [ESC] to quit, [SPACE] for next song."

FOR song = 1 TO 5
PRINT: PRINT "Song"; song
u = Rand(18, 24) * 2
basenote = u
down = 0
si = Random1(lscales)
DO
so = Random1(lscales)
LOOP WHILE si = so
thiscale(1) = basenote
FOR i = 1 TO 4
basenote = basenote + VAL(MID$(scales(si), i, 1))
if basenote > 84 then down = 12
thiscale(i + 1) = basenote
NEXT
for i = 1 to 5
thiscale(i) = thiscale(i) - down
next
basenote = u
down = 0
altscale(1) = basenote
FOR i = 1 TO 4
basenote = basenote + VAL(MID$(scales(so), i, 1))
if basenote > 84 then down = 12
altscale(i + 1) = basenote
NEXT
for i = 1 to 5
altscale(i) = altscale(i) - down
next

e$ = "MB"
IF Random1(3) = 1 THEN e$ = e$ + "MS" ELSE e$ = e$ + "MN"
e$ = e$ + "T" + _TRIM$(STR$(Rand(9, 16) * 10))
e$ = e$ + "@" + _TRIM$(STR$(Random1(3)))
e$ = e$ + "Q10V50"

numnote = Rand(50, 150) * 4
athird = numnote \ 3
DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + en$(2) + en$(5) + en$(2) + en$(5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + en$(1) + en$(5) + en$(2) + en$(5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + en$(5) + en$(5) + "L16" + en$(5)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + en$(5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + en$(5) + en$(5) + "L8" + en$(5)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + en$(5) + "L16" + en$(5) + en$(5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + en$(5) + en$(5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + enft$(1, 2) + en$(5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + en$(2) + "V25" + en$(5) + en$(2) + "V50" + en$(5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + en$(1) + "V25" + en$(5) + "V50" + en$(2) + en$(5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + en$(5) + "V25" + en$(5) + "V50L16" + en$(5)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + "V25" + en$(5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + en$(5) + "V25" + en$(5) + "V50L8" + en$(5)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + en$(5) + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > athird * 2

DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + anft$(1, 2) + anft$(1, 5) + anft$(1, 2) + anft$(1, 5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + anft$(1, 2) + anft$(1, 5) + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + anft$(1, 2) + anft$(3, 5) + "L16" + anft$(1, 2)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + anft$(1, 2) + "L32" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + anft$(1, 5) + anft$(1, 5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + anft$(1, 2) + anft$(3, 5) + "L8" + anft$(1, 2)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + anft$(1, 2) + "L16" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + anft$(1, 5) + anft$(1, 5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(1, 5) + "V50" + anft$(1, 2) + "V25" + anft$(1, 5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(1, 5) + "V50" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(3, 5) + "V50L16" + anft$(1, 2)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + anft$(1, 2) + "V25L32" + anft$(1, 2) + "V50" + anft$(3, 5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + anft$(1, 5) + "V25" + anft$(1, 5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + anft$(1, 2) + "V25" + anft$(3, 5) + "V50L8" + anft$(1, 2)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + anft$(1, 2) + "L16" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + anft$(1, 5) + "V25" + anft$(1, 5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > athird

DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + en$(2) + en$(5) + en$(2) + enft$(3, 5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + en$(2) + enft$(3, 5) + en$(2) + enft$(3, 5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + en$(5) + en$(5) + "L16" + en$(5)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + enft$(3, 5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + en$(2) + enft$(3, 5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + en$(2) + enft$(3, 5) + "L8" + en$(5)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + en$(5) + "L16" + en$(2) + enft$(3, 5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + en$(2) + en$(5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + en$(2) + enft$(3, 5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + en$(2) + "V25" + en$(5) + "V50" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + en$(2) + "V25" + enft$(3, 5) + en$(2) + "V50" + enft$(3, 5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + en$(5) + "V25" + en$(5) + "V50L16" + en$(5)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + en$(5) + "V25L32" + en$(5) + "V50" + enft$(3, 5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + en$(2) + "V25" + enft$(3, 5) + "V50L8" + en$(5)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + en$(5) + "L16" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + en$(2) + "V25" + en$(5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > 0

PLAY e$

DO WHILE PLAY(0) > 0
_LIMIT 600
IF _KEYDOWN(32) THEN EXIT DO
IF _KEYDOWN(27) THEN EXIT DO
LOOP
IF _KEYDOWN(27) THEN EXIT FOR
DO : LOOP WHILE _KEYDOWN(32)
NEXT 'song

SYSTEM


scaleslist:
DATA "3334","3344","3444","3445","3454","3545","4545","4543","3456","4565","4546"
DATA "4556","4666","5666","5444","5334","5355","5463","6444","6445","6366","6463"
DATA "END"


FUNCTION en$ (topval AS INTEGER)
en$ = "N" + _TRIM$(STR$(thiscale(Random1(topval))))
END FUNCTION

FUNCTION enft$ (fromval AS INTEGER, totoval AS INTEGER)
enft$ = "N" + _TRIM$(STR$(thiscale(Rand(fromval, totoval))))
END FUNCTION

FUNCTION anft$ (fromval AS INTEGER, totoval AS INTEGER)
anft$ = "N" + _TRIM$(STR$(altscale(Rand(fromval, totoval))))
END FUNCTION


FUNCTION Rand& (fromval&, toval&)
DIM sg%, f&, t&
IF fromval& = toval& THEN
Rand& = fromval&
EXIT FUNCTION
END IF
f& = fromval&
t& = toval&
IF (f& < 0) AND (t& < 0) THEN
sg% = -1
f& = f& * -1
t& = t& * -1
ELSE
sg% = 1
END IF
IF f& > t& THEN SWAP f&, t&
Rand& = INT(RND * (t& - f& + 1) + f&) * sg%
END FUNCTION

FUNCTION Random1& (maxvaluu&)
DIM sg%
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION

One fault with this program is that it doesn't play phrases (or "hooks", don't know how to say it out of the popular music industry) so one could recognize which song it is LOL. This program creates music which is too random. I programmed the "phrases" thing half-successfully with my Lua script for "1bitr". With "phrases" this program could make a good companion to bplus' program indicated in this thread:

https://qb64phoenix.com/forum/showthread.php?tid=1668

Purposely I set the songs playing fairly fast, ie. using "L32" instead of "L16" that I preferred, however PLAY statement doesn't allow tempos higher than 255. The logic of this program isn't very good for computing music with lengths and amplitude, which could be improved.

Print this item

  BAM: Horizontal Marquis app: using it as a "service" with custom messages
Posted by: CharlieJV - 06-17-2023, 06:24 PM - Forum: QBJS, BAM, and Other BASICs - Replies (4)

Mixing a little bit of old-school BASIC with a little bit of modern stuff.

This is just a demo app to test some features for the next release of BAM:


To customise the message displayed in the Marquis:

The message displayed in the marquis can be set via a key-value (the key = text) pair provided in the "query string" part added to the URL.  For example:

Code: (Select All)
https://basicanywheremachine.neocities.org/Test/Horizontal%20Marquis.prod.run?text=How's she goin', buddy?


To use this program as a "service" for some website or locally-stored HTML files:

A BAM program exported to a single HTML file is very convenient for deploying, whether that be to a web server or file hosting service (whether outside your firewall or inside your firewall), or to any local storage device.  Everything is self-contained in the one file, ready to go for online/offline access.

Click on the "Run the marquis program" link above.

(Chrome web browser) For the browser tab/window opened, find your browser's "Save page as" menu item, and save the webpage as HTML. 

You'll want that webpage saved to a spot available to your website or locally-stored HTML.

Here's a template for what you need to use the marquis program as a "service":
Code: (Select All)
<iframe src="https://basicanywheremachine.neocities.org/Test/Horizontal%20Marquis.prod.run.html?text=How' she goin', buddy?" width=300px height=200px>
</iframe>

Print this item

  2D Physics Engine
Posted by: justsomeguy - 06-17-2023, 04:25 AM - Forum: Programs - Replies (26)

Hello All,

I've made a demo of the physics engine ("fzxNGN") I've been working for the last few years. Its a port of the Impulse engine written by Randy Gaul. Its been 100% ported to QB64 and not a 3rd part wrapper. Some may recognize the demo from a few years back, I've simply updated it to the newer engine, and changed some of the graphics.

Inside the compressed file you will find two directories, "fzxNGN_BASE_v2" and "fzxDemo" The "fzxNGN_BASE" is the core of the engine. The actual demo is located in "fzxDemo/fzxDemo.bas". Hopefully, all you have to do is run the "fzxDemo.bas" to play with the demo. I develop in Linux, so there may be some changes needed for Windows and Mac. And the speed of your machine may vary from mine so adjusting the dt(delta time) and iterations may help. My machine is probably old enough to drive a car in my state. Undecided

Code: (Select All)
DIM AS LONG iterations: iterations = 2
DIM SHARED AS DOUBLE dt: dt = 1 / 60

The idea of this mini game is to cross the sketchy bridge and then make the loop-to-loop. Beware the sketchy bridge will break. The more red the bridge is, the more stress its under. This was in part a test of a game mechanic I was kicking around for a driving/platformer.

Current features:
  • Rigid body simulation
  • Circle and polygon primitives
  • Joint simulation
  • Camera library to help with large play fields
  • Input Library
  • Finite State machine helper functions
  • Perlin noise library
  • XML parsing library - (not 100% and not fully integrated)
  • LERP functions
  • FPS helper functions
  • Countless vector, matrix math functions

Caveats:
  • Not documented
  • Work in progress
  • Not fully optimized
  • Possibility of vestigial code, or code that has yet to be updated.
When time permits, I'll work on proper documentation.

As far as license goes:
Quote:This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely.

I will try to use this thread to post more updates for the engine.

[Image: screenshot.png]



Attached Files
.7z   fzxNGN_Demo_1.7z (Size: 1.61 MB / Downloads: 85)
Print this item

  Silent Pause in PLAY being skipped
Posted by: PhilOfPerth - 06-17-2023, 12:59 AM - Forum: Help Me! - Replies (13)

I'm experimenting with the PLAY function, and am (once again) confused with one section, the P (for silent pause).
With the string below, I expected to play four notes of staccato duration, four of normal, and four of legato. 
It would then pause for 32 quarter-notes and then repeat. But the P32 seems to be ignored. 
Pauses of up to 64 quarter-notes are permitted, so why does this happen?  Huh

Code: (Select All)
Play "MS CCCC P8 MN CCCC P8 ML CCCC P32 MS CCCC P8 MN CCCC P8 ML CCCC"

Print this item

  InForm-PE
Posted by: a740g - 06-15-2023, 10:27 PM - Forum: a740g - Replies (80)

InForm-PE is a GUI engine and WYSIWYG interface designer for QB64-PE. It's a fork of InForm, but without any dependencies on falcon.h. All falcon.h function calls have been replaced by the new _U* family of font functions in QB64-PE that were introduced in v3.7.0 and v3.8.0. As such, the minimum required version of QB64-PE that this works with is v3.8.0. This also means that the entire InFrom-PE library is now in pure QB64-PE code.

There are some examples that are included in the "examples" directory to get you started. Also, the old InFrom wiki has been copied here: Home · a740g/InForm-PE Wiki (github.com). Note that the wiki needs work. Pull requests are welcome.

I may not be actively developing new features for this. However, please feel free to submit bug reports and suggestions here: Issues · a740g/InForm-PE (github.com). Pull requests are also welcome.

a740g/InForm-PE: A GUI engine and WYSIWYG interface designer for QB64-PE (github.com)

https://github.com/a740g/InForm-PE/archi...master.zip

[Image: Screenshot-2023-06-16-040215.png]

[Image: Screenshot-2023-06-16-035222.png]

[Image: Screenshot-2023-06-16-035303.png]

[Image: Screenshot-2023-06-16-035340.png]

[Image: Screenshot-2023-06-16-035435.png]

[Image: Screenshot-2023-06-16-035530.png]

Print this item

  Just a tiny and fun bit of code
Posted by: CharlieJV - 06-15-2023, 02:30 AM - Forum: QBJS, BAM, and Other BASICs - Replies (6)

Give it a spin in BAM :

(from page 422, Handbook of BASIC: for the IBM PC, XT, AT, PS/2, and compatibles)

Code: (Select All)
SCREEN 0
PRINT "ABCDEFG"
FOR J = 0 TO 7
LOCATE 2 + J, 1
FOR K = 0 TO 55
IF POINT(K,J) = 0 THEN PRINT " "; ELSE PRINT "*";
NEXT K
PRINT
NEXT J


   

Print this item