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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 512
» Latest member: zaidativanovoz1699
» Forum threads: 2,909
» Forum posts: 27,042

Full Statistics

Latest Threads
Hardware Acceleration and...
Forum: General Discussion
Last Post: Pete
26 minutes ago
» Replies: 3
» Views: 43
Roll The Dice InputBox$ a...
Forum: Programs
Last Post: bplus
1 hour ago
» Replies: 14
» Views: 173
Memory Usage Monitor
Forum: Utilities
Last Post: Steffan-68
5 hours ago
» Replies: 4
» Views: 95
'BandInte' - Bandwidth & ...
Forum: Utilities
Last Post: Sanmayce
Today, 08:59 AM
» Replies: 5
» Views: 507
Dialog Tools
Forum: bplus
Last Post: bplus
Today, 12:18 AM
» Replies: 4
» Views: 246
PCX file format
Forum: Petr
Last Post: a740g
Yesterday, 10:05 PM
» Replies: 9
» Views: 113
BMP File format
Forum: Petr
Last Post: Petr
Yesterday, 09:39 PM
» Replies: 0
» Views: 29
QB64 and QB64PE together?
Forum: General Discussion
Last Post: Mad Axeman
Yesterday, 08:48 PM
» Replies: 7
» Views: 127
Updating my mouse and key...
Forum: Works in Progress
Last Post: Pete
Yesterday, 08:39 PM
» Replies: 28
» Views: 722
Word-list creator
Forum: Utilities
Last Post: PhilOfPerth
Yesterday, 07:18 AM
» Replies: 2
» Views: 83

 
  You are now in my power...
Posted by: SMcNeill - 02-07-2025, 05:46 AM - Forum: SMcNeill - Replies (4)

You will do as I say....

Code: (Select All)
Screen _NewImage(640, 480, 32)
Dim As Integer x, y, r, g, b
Dim As Single t
Do
t = t + 0.2
For y = -240 To 240
For x = -320 To 320
r = Plasma(x, y, t) ' Red channel
g = Bubbles(x, y, t) ' Green channel
b = Plasma(x, y, t + 2) ' Blue channel
PSet (x + 320, y + 240), _RGB32(r, g, b)
Next x
Next y
_Display
_Limit 60 ' Limit to 60 frames per second
Loop Until InKey$ <> ""
System

Function Bubbles% (x As Single, y As Single, t As Single) ' Function to create bubble effect
Bubbles = 127 + 127 * Sin(Sqr((x - 320 * Sin(t / 5)) ^ 2 + (y - 240 * Cos(t / 7)) ^ 2) / 8 - t)
End Function

Function Plasma% (x As Single, y As Single, t As Single) ' Function to calculate plasma effect
Plasma = 127 + 127 * Sin(Sqr(x * x + y * y) / 8 - t)
End Function

I really don't know what to call the above program. I *was* attempting to create a plasma-like bubble effect, similar to a lava lamp. Instead, I've created one of the most interesting little goofs that I've had the pleasure of creating for a very long time!

Everyone should test this one and see what can be accomplished in only 25 lines of code. Then, after everyone tries it out, the really smart people (which we all know excludes @Pete) should tell me HOW THE HECK??!!

Print this item

  Anyone recall why QB64 was made to do this?...
Posted by: Pete - 02-06-2025, 11:40 PM - Forum: General Discussion - Replies (4)

Code: (Select All)
For i = 21 To 30
    Locate i, 1
    Print i;
    Sleep
Next

Press a key and after it reaches to bottom of the page, the next key changes the screen to a 50-width (or appears to do so) and cuts the font size in half.

In QB, it apparently just errors out.

Anyway, just curious, as much of QB64 was made to mimick QuickBASIC, and this came up from a post by an old acquaintance at the QB Forum. He found QB was not able to correctly PCOPY in 50-line width mode. Now it does in QB64, but I'd consider that the fixing of a QB bug.

Pete

Print this item

  Slight Forum Change
Posted by: SMcNeill - 02-06-2025, 09:45 PM - Forum: Announcements - Replies (1)

Some of you might've noticed, some might not care, but I did some minor organization on the forums today.  Big Grin

Prolific Programmers (the forums where people who write a bunch of junk and want to keep it all organized in their own personal subforums) got splintered into adding a new forum called "Retired Programmers".

The main reason for this simple change?

To make it so all sub-forums are easy visible without that "and more" hiding them.  9 sub-forums can be displayed in the main forums, and anything beyond that is just "and more".  This makes certain that everyone is easily visible.

Nothing is lost.  No posts disappeared.  The only change is that the guys who haven't posted for a while have basically just been archived to make it easier to find and keep up with the guys who are still active and adding to their Prolific Programmers sub-forums.  No biggy; just something I wanted to take a moment to bring to everyone's attention and explain what happened and where those came from.  Smile


   

Print this item

  Sierpinski Triangle in QB64PE (and others)
Posted by: SMcNeill - 02-06-2025, 05:19 AM - Forum: Programs - Replies (14)

Code: (Select All)
_Title "Sierpinski Triangle in QB64PE"
Screen _NewImage(800, 800, 32)
For d = 0 To 7
SierpinskiTriangle 50, 50, 700, d
_Display
_Delay 2
Next
System

Sub SierpinskiTriangle (x As Integer, y As Integer, size As Integer, depth As Integer)
If depth = 0 Then
Line (x, y)-(x + size, y)
Line (x + size, y)-(x + size / 2, y + Int(size * Sin(_Pi / 3)))
Line (x + size / 2, y + Int(size * Sin(_Pi / 3)))-(x, y)
Else
Color _RGB32(255 * Rnd, 255 * Rnd, 255 * Rnd)
SierpinskiTriangle x, y, size / 2, depth - 1
SierpinskiTriangle x + size / 2, y, size / 2, depth - 1
SierpinskiTriangle x + size / 4, y + Int((size / 2) * Sin(_Pi / 3)), size / 2, depth - 1
End If
End Sub

Print this item

  QB64PE Mandelbrot
Posted by: SMcNeill - 02-06-2025, 02:13 AM - Forum: Programs - Replies (1)

Code: (Select All)
_Title "Mandelbrot Set in QB64PE"
Screen 12
Dim Shared xCenter As Double, yCenter As Double, scale As Double, maxIter As Long
xCenter = -0.5: yCenter = 0: scale = 2: maxIter = 100

Do
    Cls
    DrawMandelbrot xCenter, yCenter, scale, maxIter
    _Limit 120
    Select Case _KeyHit
        Case 18432: yCenter = yCenter - 0.1 * scale
        Case 20480: yCenter = yCenter + 0.1 * scale
        Case 19200: xCenter = xCenter - 0.1 * scale
        Case 19712: xCenter = xCenter + 0.1 * scale
        Case 61, 43: scale = scale / 1.1 '= or +
        Case 45, 95: scale = scale * 1.1 '- or _
        Case 113, 81: maxIter = maxIter + 10 'q      or Q
        Case 69, 101: maxIter = maxIter - 10 'e or E
        Case 27: System 'ESC
    End Select
    _Display
Loop

Sub DrawMandelbrot (xCenter As Double, yCenter As Double, scale As Double, maxIter As Long)
    Dim As Long x, y
    Dim As Double zx, zy, zx2, zy2, cx, cy
    Dim As Long iter
    For y = 0 To 479
        For x = 0 To 639
            cx = (x / 320 - 1.5) * scale + xCenter
            cy = (y / 240 - 1.0) * scale + yCenter
            zx = 0: zy = 0: zx2 = 0: zy2 = 0: iter = 0
            Do While (zx2 + zy2 <= 4) And (iter < maxIter)
                zy = 2 * zx * zy + cy
                zx = zx2 - zy2 + cx
                zx2 = zx * zx
                zy2 = zy * zy
                iter = iter + 1
            Loop
            If iter = maxIter Then
                PSet (x, y), 0
            Else
                PSet (x, y), iter * 255 / maxIter
            End If
        Next x
    Next y
End Sub

Simple enough to run/test.

Arrow Keys - Pan up / down / left / right.
+ / - - Zoom in / out.
Q / E - Increase / decrease maximum iterations.

Print this item

  Pseudo-fractal - interactive version
Posted by: hsiangch_ong - 02-05-2025, 09:42 PM - Forum: Programs - Replies (3)

i was bored so i messed about with the "pseudo-fractal" program (the last one listed in the post) shown in this topic:

https://qb64phoenix.com/forum/showthread...07#pid1907

please read the instructions further below.

Code: (Select All)
'based on program shown on this topic:
'https://qb64phoenix.com/forum/showthread.php?tid=372&pid=1907#pid1907
'modifications by mnrvovrfc (a.k.a. hsiangch_ong) 5-feb-2025
OPTION _EXPLICIT
DIM AS INTEGER oloc(1 TO 15), colo(1 TO 7)
DIM AS SINGLE a, b, c, d, e, xn, xm, yn, k, xnsqr, ynsqr, cresh, maxiter
DIM AS SINGLE xpos, ypos, xmin, ymin, xmax, ymax, xnn, ynn, dx, dy
DIM AS INTEGER i, j, pg, o, cc, dd, ee
DIM AS STRING noyb, afile
DIM endl AS STRING, ff AS LONG, thiscr AS LONG, doit AS _BYTE, firsttime AS _BYTE
endl = CHR$(10)
$IF WIN THEN
endl = CHR$(13) + endl
$ELSEIF MACOSX THEN
endl = CHR$(13)
$END IF

$IF WIN THEN
afile = LCASE$(HEX$(VAL(MID$(DATE$, 4, 2)) * 1000000~& + INT(TIMER(0.001) * 1000)))
$ELSE
noyb = "/tmp/noyb1"
SHELL _HIDE "uuidgen > " + noyb
afile = _READFILE$(noyb)
KILL noyb
afile = LeftLen$(afile, 1)
ReplaceString2 afile, "-", "", 0
$END IF
afile = "pseudofract" + afile

RANDOMIZE VAL(RIGHT$(TIME$, 2))
FOR i = 1 TO 15
    oloc(i) = i
NEXT
o = VAL(MID$(TIME$, 4, 2)) + 1
DO WHILE o > 0
    o = o - 1
    FOR i = 1 TO 15
        DO
            j = Random1(15)
        LOOP WHILE i = j
        SWAP oloc(i), oloc(j)
    NEXT
LOOP
pg = 1
GOSUB dopalette

across = 1024
down = 576
thiscr = _NEWIMAGE(across, down, 12)
SCREEN thiscr
_TITLE afile
xpos = Rand(24, 40) * 10
ypos = Rand(18, 30) * 10
a = Rand(2, 5) * 0.5 * (-1)
ee = Random1(9)
e = ee / 10
b = e * (-1)
cc = Rand(12, 36)
c = cc / 10
dd = Rand(3, 13)
d = (dd * 5) / 10 * (-1)
xmin = (Rand(5, 9) * 5) / 10 * (-1)
xmax = (Rand(5, 9) * 5) / 10
ymin = Rand(10, 20) / 10 * (-1)
ymax = Rand(10, 20) / 10
'changing this does nothing:
maxiter = 70
cresh = 500
dx = (xmax - xmin) / across
dy = (ymax - ymin) / down
firsttime = 1
DO
    IF firsttime THEN
        firsttime = 0
    ELSE
        doit = 0
        DO
            _LIMIT 12
            IF _KEYDOWN(27) THEN doit = 2
            IF _KEYDOWN(13) THEN
                doit = 3
                EXIT DO
            END IF
            FOR j = 49 TO 57
                IF _KEYDOWN(j) THEN
                    doit = 1
                    a = (j - 48) * 0.5 * (-1)
                    EXIT FOR
                END IF
            NEXT
            'if _keydown(91) then
            'doit = 1
            'if maxiter > 5 then maxiter = maxiter - 5
            'end if
            'if _keydown(93) then
            'doit = 1
            'if maxiter < 200 then maxiter = maxiter + 5
            'end if
            IF _KEYDOWN(44) OR _KEYDOWN(61) THEN
                doit = 1
                IF cresh < 2000 THEN cresh = cresh + 100
            END IF
            IF _KEYDOWN(95) OR _KEYDOWN(45) THEN
                doit = 1
                IF cresh > 100 THEN cresh = cresh - 100
            END IF
            IF _KEYDOWN(105) THEN
                doit = 1
                ypos = ypos - 10
                IF ypos < 0 THEN ypos = 0: doit = 0
            END IF
            IF _KEYDOWN(107) THEN
                doit = 1
                ypos = ypos + 10
                IF ypos > down - 40 THEN ypos = ypos - 10: doit = 0
            END IF
            IF _KEYDOWN(106) THEN
                doit = 1
                xpos = xpos - 10
                IF xpos < 0 THEN xpos = 0: doit = 0
            END IF
            IF _KEYDOWN(108) THEN
                doit = 1
                xpos = xpos + 10
                IF xpos > across - 70 THEN xpos = xpos - 10: doit = 0
            END IF
            IF _KEYDOWN(44) OR _KEYDOWN(60) THEN
                doit = 1
                pg = pg - 1
                IF pg < 1 THEN pg = 15
                GOSUB dopalette
            END IF
            IF _KEYDOWN(46) OR _KEYDOWN(62) THEN
                doit = 1
                pg = pg + 1
                IF pg > 15 THEN pg = 1
                GOSUB dopalette
            END IF
            IF _KEYDOWN(67) THEN
                doit = 1
                cc = cc - 1
                IF cc < 12 THEN cc = 59
                c = cc / 10
            END IF
            IF _KEYDOWN(68) THEN
                doit = 1
                dd = dd - 1
                IF dd < 3 THEN dd = 13
                d = (dd * 5) / 10 * (-1)
            END IF
            IF _KEYDOWN(69) THEN
                doit = 1
                ee = ee - 1
                IF ee < 1 THEN ee = 9
                e = ee / 10
                b = e * (-1)
            END IF
            IF _KEYDOWN(99) THEN
                doit = 1
                cc = cc + 1
                IF cc >= 60 THEN cc = 12
                c = cc / 10
            END IF
            IF _KEYDOWN(100) THEN
                doit = 1
                dd = dd + 1
                IF dd > 13 THEN dd = 3
                d = (dd * 5) / 10 * (-1)
            END IF
            IF _KEYDOWN(101) THEN
                doit = 1
                ee = ee + 1
                IF ee > 9 THEN ee = 1
                e = ee / 10
                b = e * (-1)
            END IF
        LOOP UNTIL doit
        _KEYCLEAR
        IF doit = 2 THEN EXIT DO
    END IF
    CLS
    FOR ynn = 1 TO down
        FOR xnn = 1 TO across
            k = 0
            xn = xmin + dx * xnn
            yn = ymin + dy * ynn
            DO
                k = k + 1
                xnsqr = xn * xn
                ynsqr = yn * yn
                IF (xnsqr + ynsqr) > cresh THEN
                    GOSUB PlotPoint
                    EXIT DO
                END IF
                IF k > maxiter THEN
                    EXIT DO
                END IF
                xm = a + b * xn + c * ynsqr
                yn = d + e * xn
                xn = xm
            LOOP
        NEXT xnn
    NEXT ynn
    IF doit < 3 THEN
        _PRINTSTRING (0, 560), "Press escape to quit. Press cdeijkl123456789<>-+  position =" + STR$(xpos) + "," + STR$(ypos) + "  cresh =" + STR$(cresh)
    END IF
    IF doit = 3 THEN EXIT DO
LOOP UNTIL _KEYDOWN(27)
_KEYCLEAR
IF doit = 3 THEN
    _SAVEIMAGE afile + ".png", thiscr
    ff = FREEFILE
    OPEN afile + ".txt" FOR OUTPUT AS ff
    PRINT #ff, "xpos ="; xpos; endl; "ypos ="; ypos; endl;
    PRINT #ff, "a ="; a; endl; "b ="; b; endl; "c ="; c; endl;
    PRINT #ff, "d ="; d; endl; "e ="; e; endl;
    PRINT #ff, "xmin ="; xmin; endl; "xmax ="; xmax; endl;
    PRINT #ff, "ymin ="; ymin; endl; "ymax ="; ymax; endl;
    PRINT #ff, "maxiter ="; maxiter; endl; "cresh ="; cresh; endl;
    CLOSE ff
END IF
SYSTEM

PlotPoint:
PSET (xpos - .5 * across + xnn, ypos - .5 * down + ynn), colo((k MOD 7) + 1)
RETURN


dopalette:
j = pg
FOR i = 1 TO 7
    colo(i) = oloc(j)
    j = j + 1
    IF j > 15 THEN j = 1
NEXT
RETURN


FUNCTION Random1& (maxval AS LONG)
    Random1& = INT(RND * maxval + 1)
END FUNCTION

FUNCTION Rand& (loval AS LONG, hival AS LONG)
    Rand& = INT(RND * (hival - loval + 1) + loval)
END FUNCTION

SUB ReplaceString2 (tx AS STRING, sfind AS STRING, repl AS STRING, numtimes AS LONG)
    DIM AS STRING s, t
    DIM AS LONG ls, count, u
    DIM goahead AS _BYTE
    IF (tx = "") OR (sfind = "") OR (sfind = repl) OR (LEN(sfind) > LEN(tx)) THEN EXIT SUB
    s = UCASE$(sfind): t = UCASE$(tx)
    ls = LEN(s)
    count = 0
    goahead = 1
    DO
        u = INSTR(t, s)
        IF u > 0 THEN
            tx = LEFT$(tx, u - 1) + repl + MID$(tx, u + ls)
            t = UCASE$(tx)
            IF numtimes > 0 THEN count = count + 1: IF count >= numtimes THEN goahead = 0
        ELSE
            goahead = 0
        END IF
    LOOP WHILE goahead
END SUB

FUNCTION LeftLen$ (tx$, numchar%)
    IF tx$ = "" THEN
        LeftLen$ = ""
    ELSEIF numchar% > 0 THEN
        LeftLen$ = LEFT$(tx$, LEN(tx$) - numchar%)
    ELSE
        LeftLen$ = tx$
    END IF
END FUNCTION

this is an interactive program:

key             function
escape          quit program
enter           save image and text-file info and quit program
i,j,k,l         shift image render
plus/minus      increase/decrease "cresh"
c,d,e           change those variables as listed in this program
number key      change variable "a" as listed in this program
comma/period    shift "palette"


this program will often refuse to create a picture, or create one which is a colored solid block.  it's better to press escape and try again.

the "palette" is 15 colors (except black) and is randomly created.  the comma and period keys (shifted or not) shift down or up the list of colors by one location.

the value of variable "b" is related to that of "e" on purpose.  the value of "d" could have a great effect on the render.  oftentimes, it produces worthless results.  the lowercase "c", "d" and "e" keys decrease the value for that variable.  type the letter in uppercase to increase the value instead.

perhaps variable "cresh" could be increased beyond 2000 but i wanted to be conservative.  in my experiments, changing "maxiter" had no effect.  for most "interesting" images the (xpos, ypos) to take up the whole screen in this program seems to be (510,290).  the screen for this program is purposely set to 3/4 what is my laptop's screen which is 1366 by 768 pixels.

this is important: press enter instead of escape to save the current image to png.  it will be saved to the same directory as the executable.  two files will be saved.  the other one is a text file that reveals the values used to come up with the fractal.  it will require another program that will read those values and draw the fractal like in the original "pseudo-fractal".  known issue: the "palette" is not recorded into the text file.

this program requires qb64 phoenix 3.12 or later.  for older releases it will have to be edited somewhere near the top.  i did not put a "compiler check" because whoever is still using "official" or a release older than 3.4 really should upgrade.  i'm sorry for sounding arrogant.

i'm on linux.  therefore the code to fabricate a random filename will have to be verified for windows.  i wrote a function that fabricates a name according to the system time and a running counter but can't find it in my backups yet.

(looks around anxiously.)  well you could ask, just what do i do with a text file generated by this program?!

run this program:

Code: (Select All)
'based on program shown on this topic:
'https://qb64phoenix.com/forum/showthread.php?tid=372&pid=1907#pid1907
'modifications by mnrvovrfc (a.k.a. hsiangch_ong) 5-feb-2025
$IF VERSION < 3.4 THEN
$ERROR Sorry, please upgrade QB64 to the latest Phoenix Edition!
$END IF
option _explicit
DIM AS INTEGER oloc(1 TO 15), colo(1 TO 7)
dim as single a, b, c, d, e, xn, xm, yn, k, xnsqr, ynsqr, cresh, maxiter
dim as single xpos, ypos, xmin, ymin, xmax, ymax, xnn, ynn, dx, dy
dim as integer across, down, i, j, pg, o, cc, dd, ee, zm, xk, yk
dim as long ff, thiscr, eq
dim as string afile, entry, ky

$IF WIN THEN
entry = "USERPROFILE"
$ELSE
entry = "HOME"
$END IF

afile = _openfiledialog$("Please choose 'pseudo-fractal' text file.", environ$(entry) + "/Documents/", "*.txt", "TEXT")
if afile = "" then system
ff = freefile
open afile for input as ff
do until eof(ff)
    line input #ff, entry
    getintoequal entry, ky, eq
    if eq = -1 then _continue
    if ky = "a" then a = val(mid$(entry, eq)) : _continue
    if ky = "b" then b = val(mid$(entry, eq)) : _continue
    if ky = "c" then c = val(mid$(entry, eq)) : _continue
    if ky = "d" then d = val(mid$(entry, eq)) : _continue
    if ky = "e" then e = val(mid$(entry, eq)) : _continue
    if ky = "xpos" then xpos = val(mid$(entry, eq)) : _continue
    if ky = "ypos" then ypos = val(mid$(entry, eq)) : _continue
    if ky = "xmin" then xmin = val(mid$(entry, eq)) : _continue
    if ky = "xmax" then xmax = val(mid$(entry, eq)) : _continue
    if ky = "ymin" then ymin = val(mid$(entry, eq)) : _continue
    if ky = "ymax" then ymax = val(mid$(entry, eq)) : _continue
    if ky = "maxiter" then maxiter = val(mid$(entry, eq)) : _continue
    if ky = "cresh" then cresh = val(mid$(entry, eq)) : _continue
    if ky = "zm" then zm = val(mid$(entry, eq)) : _continue
    if ky = "xk" then xk = val(mid$(entry, eq)) : _continue
    if ky = "yk" then yk = val(mid$(entry, eq))
loop
close ff
if zm = 0 then zm = 100
if xk = 0 then xk = 100
if yk = 0 then yk = 100

RANDOMIZE VAL(RIGHT$(TIME$, 2))
FOR i = 1 TO 15
    oloc(i) = i
NEXT
o = VAL(MID$(TIME$, 4, 2)) + 1
DO WHILE o > 0
    o = o - 1
    FOR i = 1 TO 15
        DO
            j = int(rnd * 15 + 1)
        LOOP WHILE i = j
        SWAP oloc(i), oloc(j)
    NEXT
LOOP
pg = 1
j = pg
FOR i = 1 TO 7
    colo(i) = oloc(j)
    j = j + 1
    IF j > 15 THEN j = 1
NEXT

across = 1024
down = 576
thiscr = _NEWIMAGE(across, down, 12)
SCREEN thiscr
_title "Pseudo-fractal - Press escape to quit."
dx = (xmax - xmin) / across
dy = (ymax - ymin) / down
FOR ynn = 1 TO down
    FOR xnn = 1 TO across
        k = 0
        xn = xmin + (dx * zm / 100) * (xnn * xk / 100)
        yn = ymin + (dy * zm / 100) * (ynn * yk / 100)
        DO
            k = k + 1
            xnsqr = xn * xn
            ynsqr = yn * yn
            IF (xnsqr + ynsqr) > cresh THEN
                GOSUB PlotPoint
                EXIT DO
            END IF
            IF k > maxiter THEN
                EXIT DO
            END IF
            xm = a + b * xn + c * ynsqr
            yn = d + e * xn
            xn = xm
        LOOP
    NEXT xnn
NEXT ynn
do : _limit 100 : loop until _keydown(27)
_keyclear
system


PlotPoint:
PSET (xpos - 0.5 * across + xnn, ypos - 0.5 * down + ynn), colo((k MOD 7) + 1)
RETURN

'changed: ky, eq
sub getintoequal (entry as string, ky as string, eq as long)
    dim u as long
    u = instr(entry, "=")
    if u = 0 then
        eq = -1
        exit sub
    end if
    eq = u + 1
    ky = _trim$(lcase$(left$(entry$, u - 1)))
end sub

but what do variables "zm", "xk" and "yk" do?  heh heh.  i'm keeping it to myself.  the handling of the "palette" here is also left as an exercise to the reader.

Print this item

  QuickMouse
Posted by: SMcNeill - 02-05-2025, 06:19 PM - Forum: Utilities - No Replies

I was talking to someone on Discord earlier today, and they were looking for a simple little routine to add directional movement and pew-pews to a game, using a mouse.  They had a routine, but it was rather laggy and didn't work quite right for me, so I wrote this little demo for them and thought I'd share it here in case anyone else might need something really simple like this:

Code: (Select All)
Dim Shared As Long MB1, MB2, MMX, MMY
Const Drift = 5 'change the drift value for how lenient you want to be for your directional wandering of the mouse movement

_MouseHide
Do
quickmouse
If MMX < -Drift Then Print "LEFT"
If MMX > Drift Then Print "RIGHT"
If MMY < -Drift Then Print "UP"
If MMY > Drift Then Print "DOWN"
If MB1 Then Print "PEW PEW"
If MB2 Then Print "BYE BYE": System
_Limit 15
Loop

Sub quickmouse
Static omb1, omb2 'old mouse buttons
MB1 = _FALSE: MB2 = _FALSE 'mouse buttons
MMX = 0: MMY = 0
While _MouseInput
MMX = MMX + _MouseMovementX
MMY = MMY + _MouseMovementY
Wend
If _MouseButton(1) And Not omb1 Then MB1 = _TRUE
If _MouseButton(2) And Not omb2 Then MB2 = _TRUE
omb1 = _MouseButton(1): omb2 = _MouseButton(2)
End Sub

Print this item

Question sound file playback (and record) - manipulating speed + pitch in realtime?
Posted by: madscijr - 02-04-2025, 12:57 PM - Forum: Help Me! - Replies (11)

Back in the olden days before digital audio, when sound was recorded using analog formats like records and tapes, the pitch of the audio was affected by playback speed (e.g., 33 1/4 vs 45 vs 78 rpm for records, 3.75 vs 7.5 vs 15 vs 30 ips for audio tape). Or you could record at a very high speed, and playing back the recording at normal speed would result in a very slow and low sound. Playing back audio recorded at a very low speed would sound like chipmunks. Professional and even consumer tape machines often included a knob to vary the speed of the tape or turntable motor and thus the pitch & speed, where adjusting it a small amount allowed fine-tuning. DJs can accomplish this when playing records by lightly pressing their finger down on the record as it plays (the harder they press, the more it slows down).

I'm wondering how we might use modern QB64PE with its extensive audio capability to replicate this function? Perhaps the playback speed (or speed while recording) could be manipulated using a mouse or other analog or continuous type input device like an analog joystick, or a little at a time by pressing +/- keys.

Any ideas how this might be done?

Print this item

  Using QB64PE extension in Visual Studio Code
Posted by: Marco Kurvers - 02-03-2025, 04:31 PM - Forum: GitHub Discussion - Replies (2)

I have installed QB64PE extension in VSCode, but I see nothing in the language list. If I create a new bas file, VSCode does automatically Liberty BASIC. Maybe, I forgot something?

Print this item

  [Beginner Q] How to use subs/functions from external file?
Posted by: sublogic - 02-02-2025, 09:23 PM - Forum: General Discussion - Replies (10)

Hi all,

New user here, thanks for providing this forum & please bear with me...

I am trying to learn how to build my own external library of functions and/or subroutines.

Here is what I have right now:

Code: (Select All)
'$Include: 'mylib.bas'

AddNumbers

Error in message window: "Statement cannot be placed between SUB/FUNCTIONs on current line"

Code: (Select All)
' mylib.bas

' Add two numbers. Or don't.
Sub AddNumbers (a, b)
  'AddNumbersResult = a + b
  'Print "Adding: "; _ToStr$(a); " + "; _ToStr$(b); " = "; _ToStr$(AddNumbersResult)
  Print "Hello world."
End Sub

What I've tried so far:


  1. Adding, removing parens to/from the call to AddNumbers
  2. Adding, removing parameters to/from the call to AddNumbers - AddNumbers(2,3)
  3. Adding, removing "as Integer" to/from Sub/function parameters
  4. Using variables to call the sub/function, rather than literal integers
  5. Removing spaces between sub/function name and parens
  6. Converting the sub to function and back again
  7. Moving the include directive from top to bottom
  8. Adding a declaration of the sub to the library file
  9. Changing all function/sub logic to simply "Hello world." just in case
  10. Browsing the wiki entries for sub, function, include, etc.

The changes I made have changed the error message to say different things, but I haven't once been able to run the program after guessing which changes were required.

Any help is appreciated! Version I'm using is 4.0, Manjaro Linux. I am used to programming in other languages like PHP, Perl, Raku, Object Pascal, and others, but fairly new to this kind of library-call feature in basic dialects.

Print this item