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,832
» Forum posts: 26,544

Full Statistics

Latest Threads
Problems with QBJS
Forum: Help Me!
Last Post: Jack002
1 hour ago
» Replies: 2
» Views: 45
sleep command in compiler...
Forum: General Discussion
Last Post: doppler
6 hours ago
» Replies: 0
» Views: 27
Aloha from Maui guys.
Forum: General Discussion
Last Post: madscijr
6 hours ago
» Replies: 8
» Views: 134
which day of the week
Forum: Programs
Last Post: Pete
7 hours ago
» Replies: 29
» Views: 627
Playing sound files in QB...
Forum: Programs
Last Post: ahenry3068
Today, 05:37 AM
» Replies: 9
» Views: 1,185
another variation of "10 ...
Forum: Programs
Last Post: Jack002
Yesterday, 11:54 PM
» Replies: 1
» Views: 86
Rock Jockey 2.0 is ready ...
Forum: Games
Last Post: NakedApe
Yesterday, 09:02 PM
» Replies: 20
» Views: 613
Button rack or hotkey fun...
Forum: Utilities
Last Post: Jack002
Yesterday, 08:20 PM
» Replies: 6
» Views: 402
ANSIPrint
Forum: a740g
Last Post: bplus
Yesterday, 05:36 PM
» Replies: 11
» Views: 221
Audio Spectrum Analyser
Forum: Programs
Last Post: Jack002
Yesterday, 01:56 AM
» Replies: 7
» Views: 167

 
  Book for sanity/insanity break: "10 PRINT CHR$(205.5+RND(1)); : GOTO 10"
Posted by: CharlieJV - 08-21-2023, 10:03 PM - Forum: General Discussion - Replies (4)

https://10print.org/10_PRINT_121114.pdf?...786I9Um03Q

Print this item

  QB64_GJ_LIB ARRay Library
Posted by: grymmjack - 08-21-2023, 12:07 AM - Forum: Programs - Replies (3)

Hi.

I've added some handy stuff to my library for dealing with arrays:
https://github.com/grymmjack/QB64_GJ_LIB/tree/main/ARR

What is in the library? Read the README.md, but:

TYPES SUPPORTED:

  • _BYTE
  • _UNSIGNED _BYTE
  • INTEGER
  • _UNSIGNED INTEGER
  • _INTEGER64
  • _UNSIGNED _INTEGER64
  • LONG
  • _UNSIGNED LONG
  • SINGLE
  • DOUBLE
  • _FLOAT
  • STRING

Every numeric type contains the following SUBs/FUNCTIONs e.g. ARR_INT.slice for the slice SUB for INTEGER type.

SUBS AND FUNCTIONS FOR NUMERIC TYPES:
Code: (Select All)
.slice        Slice an array from source to destination starting at index and count slices
.push         Push a element onto the end of the array
.pop          Pop a element off the end of the array
.shift        Pop a element off the beginning of the array
.unshift      Push a element on the beginning of the array
.copy         Copy an array
.join         Return array contents as comma delimited string
.new          Create new array using comma delimited string
.longest      Return the longest element of an array
.shortest     Return the shortest element of an array
.math         Do math on every element of an array
.min          Return minimum element of an array
.max          Return maximum element of an array
.first        Return 1st element of an array
.last         Return last element of an array
.nth          Return every nth element of an array
.in           Determine if a value exists in an array
.find         Find a value in an array and return it's index
.count        Return the number of elements in an array
.size         Return the size in bytes of all elements in an array
.reverse      Reverse the index of elements in an array
.random       Return a random element from the array
.sum          Return the sum of all elements in an array
.avg          Return the average of all elements in an array
.shuffle      Randomize the indexes of all elements in an array
.unique       Return unique elements in an array
.gt           Return elements greater than (>) value in an array
.gte          Return elements greater than or equal (>=) value in an array
.lt           Return elements less than (<>=) value in an array
.lte          Return elements less than or equal (<>=) value in an array
.replace      Replace elements in array with replacement value
.insert       Insert element in an array at index
.remove       Remove element in an array at index
.odd          Return odd numbered indexed elements in an array
.even         Return even numbered indexed elements in an array
.mod          Return evenly divisible by n numbered indexed elements in an array
.between      Return elements between a start and end index in an array
.sort         Sort elements of an array in ascending order
.rsort        Sort elements of an array in desscending order

SUBS AND FUNCTIONS FOR STRING TYPE:
Code: (Select All)
.slice        Slice an array from source to destination starting at index and count slices
.push         Push a element onto the end of the array
.pop          Pop a element off the end of the array
.shift        Pop a element off the beginning of the array
.unshift      Push a element on the beginning of the array
.copy         Copy an array
.join         Return array contents as comma delimited string
.new          Create new array using comma delimited string
.longest      Return the longest element of an array
.shortest     Return the shortest element of an array
.first        Return 1st element of an array
.last         Return last element of an array
.nth          Return every nth element of an array
.in           Determine if a value exists in an array
.find         Find a value in an array and return it's index
.count        Return the number of elements in an array
.size         Return the size in bytes of all elements in an array
.reverse      Reverse the index of elements in an array
.random       Return a random element from the array
.shuffle      Randomize the indexes of all elements in an array
.unique       Return unique elements in an array
.replace      Replace elements in array with replacement value
.insert       Insert element in an array at index
.remove       Remove element in an array at index
.odd          Return odd numbered indexed elements in an array
.even         Return even numbered indexed elements in an array
.mod          Return evenly divisible by n numbered indexed elements in an array
.between      Return elements between a start and end index in an array
.sort         Sort elements of an array in ascending order
.rsort        Sort elements of an array in desscending order

Print this item

  polyFT - draw filled polygons
Posted by: James D Jarvis - 08-20-2023, 09:55 PM - Forum: Utilities - Replies (5)

an update of an older sub to draw filled polygons using _maptriangle . This one is faster than the earlier version (polyT) and includes options for rotation, horizontal and vertical scaling, and a border.

Code: (Select All)
'draw_polyFT
' by James D.  Jarvis  , August 20,2023
'draw filled  polygons
'
'HEADER
Dim Shared xmax, ymax
xmax = 800: ymax = 500
Screen _NewImage(xmax, ymax, 32)
Dim Shared pk& 'must be included in a program that uses polyFT
pk& = _NewImage(3, 3, 32) 'must be included in a program that uses polyFT

'======================================
' demo
'======================================
' This demo draws 64000 random polygons, and then clears the screen and draws a handful of polygons  rotating

Randomize Timer

t1 = Timer
For reps = 1 To 64000
    polyFT Int(Rnd * xmax), Int(Rnd * ymax), Int(3 + Rnd * 20), Int(3 + Rnd * 12), Int(Rnd * 60), Int(1 + Rnd * 3), Int(1 + Rnd * 3), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256)), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
Next reps
t2 = Timer
Print "That took "; t2 - t1; " seconds to draw 64000 polygons"
Sleep
rtn = 0
Do
    _Limit 60
    Cls
    Print "Press <ESC> to quit>"
    polyFT 100, 100, 40, 3, rtn, 1, 1, _RGB32(100, 200, 50), 0
    polyFT 200, 100, 40, 4, 45 + rtn, 1, 1, _RGB32(100, 200, 250), 0
    polyFT 300, 100, 40, 5, rtn, 1, 1, _RGB32(200, 100, 250), 0
    polyFT 400, 100, 40, 6, rtn, 1, 1, _RGB32(100, 250, 150), 0
    polyFT 500, 100, 40, 7, rtn, 1, 1, _RGB32(150, 200, 200), 0
    polyFT 600, 100, 40, 8, 22.5 + rtn, 1, 1, _RGB32(200, 200, 0), 0
    _PrintString (100 - (_PrintWidth("Triangle")) / 2, 160), "Triangle"
    _PrintString (200 - (_PrintWidth("Square")) / 2, 160), "Square"
    _PrintString (300 - (_PrintWidth("Pentagon")) / 2, 160), "Pentagon"
    _PrintString (400 - (_PrintWidth("Hexagon")) / 2, 160), "Hexagon"
    _PrintString (500 - (_PrintWidth("Heptagon")) / 2, 160), "Heptagon"
    _PrintString (600 - (_PrintWidth("Octagon")) / 2, 160), "Octagon"
    rtn = rtn + 1: If rtn > 360 Then rtn = 0
    _Display 'for smooth display
Loop Until InKey$ = Chr$(27)

'==========================================================================
'subroutines
'
'  polyFT    draw a filled polygon
'
' setklr    is a sub to build the color image used by triangles in  polyFT
'====================================== ==================================
Sub polyFT (cx As Long, cy As Long, rad As Long, sides As Integer, rang As Long, ww, vv, klr As _Unsigned Long, lineyes As _Unsigned Long)
    'draw an equilateral polygon using filled triangle for each segment
    'centered at cx,cy to radius rad of sides # of face rotated to angle rang scaled to ww and vv of color klr and lineyes if there is an outline, a value 0 would create no outline
    setklr klr
    Dim px(sides)
    Dim py(sides)
    pang = 360 / sides
    ang = 0
    For p = 1 To sides
        px(p) = cx + (rad * Cos(0.01745329 * (ang + rang))) * ww
        py(p) = cy + (rad * Sin(0.01745329 * (ang + rang))) * vv
        ang = ang + pang

    Next p
    For p = 1 To sides - 1
        _MapTriangle (0, 0)-(0, 2)-(2, 0), pk& To(cx, cy)-(px(p), py(p))-(px(p + 1), py(p + 1))
        If lineyes > 0 Then Line (px(p), py(p))-(px(p + 1), py(p + 1)), lineyes
    Next p
    _MapTriangle (0, 0)-(0, 2)-(2, 0), pk& To(cx, cy)-(px(sides), py(sides))-(px(1), py(1))
    If lineyes > 0 Then Line (px(sides), py(sides))-(px(1), py(1)), lineyes



End Sub
Sub setklr (klr As Long)
    'internal routine to setup an image to copy a colored triangle from in the color klr
    'called by polyT
    _Dest pk&
    Line (0, 0)-(2, 2), klr, BF
    _Dest 0
End Sub

Print this item

  fhex ... a Filled Hex
Posted by: James D Jarvis - 08-19-2023, 06:52 PM - Forum: Utilities - Replies (2)

a little routine and associated demo for drawing a filled hex.

Code: (Select All)
'Fhex
'by James D. Jarvis August 19,2023
'draw a filled hex
'demo code
Screen _NewImage(500, 500, 32)
rr = 200
For d = 1 To 10
    fcirc 250, 250, rr, _RGB32(200, 200, 0)
    fhex 250, 250, rr, _RGB32(200, 100, 100)
    rr = rr * .86
Next d
For a = 60 To 360 Step 60
    ang_line 250, 250, 200, a, _RGB32(250, 0, 0)
Next a

hx = 60: hy = 60: hl = 12
fhex hx, hy, hl, _RGB32(100, 100, 100)
For ha = 30 To 390 Step 60
    hx = 60 + (hl * 1.9) * Cos(0.01745329 * ha)
    hy = 60 + (hl * 1.9) * Sin(0.01745329 * ha)
    fhex hx, hy, hl, _RGB32(ha / 2, ha / 2, ha / 20)
Next ha

Sub fhex (cx As Long, cy As Long, r, klr As _Unsigned Long)
    'draw a hex to radius r filled with color klr centeted on cx,cy
    rcheck = ((r * .867) * (r * .867))
    For dY = -r To r
        If dY * dY < rcheck Then
            dx = r - Abs(dY / _Pi * 1.81)
            Line (cx - dx, dY + cy)-(cx + dx, dY + cy), klr, BF
        End If
    Next dY
End Sub


'ang_line and fcirc included for demo not needed for fhex itself
Sub ang_line (sx, sy, lnth, ang, klr As _Unsigned Long)
    'draw a line lnth units long from sx,sy at anlge ang measures in degrees, 0 deg is out along X axis
    nx = sx + lnth * Cos(0.01745329 * ang)
    ny = sy + lnth * Sin(0.01745329 * ang)
    Line (sx, sy)-(nx, ny), klr

End Sub
Sub fcirc (CX As Long, CY As Long, R, klr As _Unsigned Long)
    'draw a filled circle with the quickest filled circle routine in qb64, not my development
    Dim subRadius As Long, RadiusError As Long
    Dim X As Long, Y As Long
    subRadius = Abs(R)
    RadiusError = -subRadius
    X = subRadius
    Y = 0
    If subRadius = 0 Then PSet (CX, CY): Exit Sub
    Line (CX - X, CY)-(CX + X, CY), klr, 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), klr, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), klr, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), klr, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), klr, BF
    Wend
End Sub

Print this item

  Microsoft BASIC PDS 7.1 User Interface Toolbox
Posted by: a740g - 08-19-2023, 04:49 AM - Forum: a740g - Replies (15)

This was supposed to go in the Museum a long time ago. However, I never got to re-implementing the assembler routines that this uses... until now.
I've included the assembly sources as comments in General.bas. Below those comments you can find the QB64 function ports.

From MS PDS 7.1 Getting Started docs:

Quote:User Interface Toolbox

With the new user interface code samples, you can design your own user interface using
BASIC procedures. The code samples in this toolbox give you complete control of character-
based window interfaces. For example, you could write a BASIC program with multiple
windows, menu bars, dialog boxes, and mouse interaction. For more information about the User
Interface toolbox, see Part 3 of the BASIC Language Reference.
Please note that this is by no means a perfect port. There are a few differences and quirks.

Happy tinkering!

[Image: Screenshot-2023-08-19-010014.png]

[Image: Screenshot-2023-08-19-081928.png]

[Image: Screenshot-2023-08-19-082014.png]

[Image: Screenshot-2023-08-19-082028.png]



Attached Files
.zip   PDSUITB64.zip (Size: 45.29 KB / Downloads: 155)
Print this item

  API Questions
Posted by: TerryRitchie - 08-18-2023, 07:35 PM - Forum: Help Me! - Replies (24)

Since I've started diving into API calls I figured a dedicated thread for API related questions would be better.

Here is my first question.

In the Wiki here: https://qb64phoenix.com/qb64wiki/index.p...ndow_Focus

It's shown how to determine the foreground window (the one in focus).

The Microsoft docs for GetForegroundWindow are located here: https://learn.microsoft.com/en-us/window...oundwindow

I noticed in the Wiki example that GetForegroundWindow is declared as an _OFFSET (%&). How was this determined? Looking at the Microsoft docs there is no indication of the type of variable returned. With other window handle (hWnd) related functions I've noticed a variable type of LONG is used. Why was _OFFSET needed here instead of LONG?

This has me confused. Any clarification would be greatly appreciated.

Print this item

  QBJS Particle Fountain
Posted by: bplus - 08-17-2023, 09:19 AM - Forum: QBJS, BAM, and Other BASICs - Replies (1)

I am tweaking dbox pset version with less bubble release each frame for consistent fountain pattern (same tweak as in Proggies) PLUS a wider viewing frame that spreads Bell Curve a little better:

https://qbjs.org/index.html?code=J09wdGl...A1FTdWIKCg==


   

Print this item

  Number Touch - Number block moving puzzle game
Posted by: Dav - 08-17-2023, 03:21 AM - Forum: Dav - Replies (1)

NUMBER TOUCH is my version of a popular online puzzle called 'NumberHood'.  The goal is to move the blocks, side by side, until they all turn green.  Each block has a number. That number means how many blocks that block must touch to turn green.  Blocks with a 1 have to touch 1 other block to turn green.  Blocks with a 2 have to touch 2 other blocks, etc.  If they touch too many other blocks, then the block will turn red.  When place just right, all blocks will turn green and the level is solved.  The screenshot should help you understand the game better.  There are 15 levels, move to them with the arrow keys if you want.

This is updated from the one posted at the old forum.  Now auto-sizes to fit your desktop screensize, , has game sounds, and I also fixed a couple bugs.

- Dav


.zip   numbertouch.zip (Size: 122.87 KB / Downloads: 112)

   

Print this item

  Number Touch - Number block moving puzzle game
Posted by: Dav - 08-17-2023, 03:21 AM - Forum: Games - Replies (1)

NUMBER TOUCH is my version of a popular online puzzle called 'NumberHood'.  The goal is to move the blocks, side by side, until they all turn green.  Each block has a number. That number means how many blocks that block must touch to turn green.  Blocks with a 1 have to touch 1 other block to turn green.  Blocks with a 2 have to touch 2 other blocks, etc.  If they touch too many other blocks, then the block will turn red.  When place just right, all blocks will turn green and the level is solved.  The screenshot should help you understand the game better.  There are 15 levels, move to them with the arrow keys if you want.

This is updated from the one posted at the old forum.  Now auto-sizes to fit your desktop screensize, , has game sounds, and I also fixed a couple bugs.

- Dav


.zip   numbertouch.zip (Size: 122.87 KB / Downloads: 105)

   

Print this item

Rainbow antonis.de is a gold mine!
Posted by: grymmjack - 08-17-2023, 12:58 AM - Forum: General Discussion - Replies (5)

Anyway. Just wanted to share. This site was found by reading _Antoni.txt included by the source of the QBINVADE.BAS that was posted recently here: https://qb64phoenix.com/forum/showthread.php?tid=1888

http://www.antonis.de/ has loads of great stuff in it.

This site is a gold mine. If you don't speak German, use Google Translate:
https://www-antonis-de.translate.goog/?_...r_hl=en-US

Great resources:
- Books - and some include source code - This one is great http://ethanwiner.com/BTU_BOOK.PDF

- Monster FAQ v2 - with loads of example programs
417 programs. https://www-antonis-de.translate.goog/fa...r_sch=http

- QB Cook Book - great recipes
https://www-antonis-de.translate.goog/qb...=http#soun

Print this item