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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,032
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
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://staging.qb64phoenix.com/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: 35)
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: One Hit Wonders - Replies (20)

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

  QB64 Phoenix Edition v3.8.0 Released!
Posted by: RhoSigma - 06-14-2023, 08:19 AM - Forum: Announcements - Replies (57)

QB64 Phoenix Edition v3.8.0!

https://github.com/QB64-Phoenix-Edition/...tag/v3.8.0

Enhancements

  • #338 - C/C++ compiler update. - @a740g
    • Updates the MinGW toolchain to v12.2.0 r2.
  • #339 - Improvements on the various dialog functions. - @a740g
    • Many mandatory dialog parameters are now optional.
    • Parsable option string arguments are case-insensitive now (required lower case before).
  • #341 - Adds _UCHARPOS() to the _U* functions family. - @a740g
    • Ideally, this should have been added in v3.7.0 but was not due to an oversight. This function calculates the pixel distance of every character in a string from the origin and is especially helpful for variable width fonts.
  • #347 - Audio enhancements. - @a740g
    • Updates miniaudio to v0.11.17, which adds support for Apple AIFF and AIFC audio formats. So, we get those too.
    • PLAY has been extended to:
      • Select waveforms @n (square = 1, sawtooth = 2, triangle = 3 (default), sine = 4, noise = 5).
      • Adjust volume ramping Qn (0ms to 100ms).
    • SOUND has been extended to use the following syntax:
      • SOUND frequency#, duration#[, volume#][, panning#][, waveform&]
  • #346 - Improves the IDE code export abilities. - @RhoSigma-QB64
    • Added ability to export into a [ q b = e x p o r t ] Forum codebox.
    • The Forum/Wiki exports now go to the clipboard instead of a file and can directly be pasted into the Forum post or Wiki page.
    • Progress of export is shown in the status line and you'll get a message upon export completion.

Bug Fixes
Full Changelog: v3.7.0...v3.8.0

Print this item

  Jump due to timeout in response
Posted by: JuanjoGomez - 06-14-2023, 07:36 AM - Forum: General Discussion - Replies (2)

HI,
I have a problem. When I enter my program, the first thing I do is find out what my external IP is.  For that I use a function that I saw from another programmer.
The problem is that depending on the computer, connection, times you enter the program......, sometimes it does it instantly and sometimes it takes a long time to get it (1 minute or more).
Can anyone think of how to set a timer so that if it hasn't responded in, say, 3 seconds, then program continues at another line? or by presing a key if is more easy?
Tanks

Code: (Select All)
Dim miip As String
Cls: Locate 10, 20: Print "COSULTING PUBLIC IP ...."

miip = GetPublicIP
Locate 10, 20: Print "PUBLIC IP: "; miip

continue:
'----- Program

End


Function GetPublicIP$
    Dim URL As String
    Dim URLFile As String
    Dim publicip As String
    Dim a%
    URLFile = "publicip"
    URL = "https://api.ipify.org/"
    a% = FileDownload(URL, URLFile)
    Dim U As Integer
    U = FreeFile
    Open URLFile For Binary As #U
    If LOF(U) <> 0 Then
        Line Input #U, publicip
    Else
        Close #U
        Kill URLFile
        GetPublicIP = ""
        Exit Function
    End If
    Close #U
    Kill URLFile
    GetPublicIP = publicip
End Function

Declare Dynamic Library "urlmon"
    Function URLDownloadToFileA (ByVal pCaller As Long, szURL As String, szFileName As String, Byval dwReserved As Long, Byval lpfnCB As Long)
End Declare

Function FileDownload (URL As String, File As String)
    FileDownload = URLDownloadToFileA(0, URL, File, 0, 0)
End Function

Print this item

  No warning to mix screen 0 and screen graphic commands!
Posted by: TempodiBasic - 06-14-2023, 01:24 AM - Forum: Help Me! - Replies (8)

Help!
For all coders like me that are too old to abandon the old Qbasic Keywords vs new QB63pe keywords, it should be a warning AI in the parser!

run this code and you can experimenting what I'm saying.

Code: (Select All)
Dim Shared S1 As Long, S2 As Long
S1 = _NewImage(1200, 900, 32)
S2 = _NewImage(1200, 300, 32)
_SetAlpha 100, 0, S2
Screen S1
Paint (1, 1), _RGBA32(0, 100, 100, 256)
_Delay 1
_Dest S2
Print "If you see color back to this text all is ok"
_PutImage (1, 600), S2, S1
well, if you watch at the output... you see that all that is a screen 0 output (PRINT in this case)  has been _putimaged on the application screen without no alpha effect!
At a first time it has been clear to my old mind! Why the part of S2 that brings PRINT output is not under the effect of _setalpha? 
Yes PRINT is a keyword of SCREEN 0, but I believe that _setalpha should work on the whole S2 and not only to the part that brings a graphic effect.
In other words I should get this result if I make output directly to the main screen, while if I copy a screen that has a not full grade of trasparency (alpha < 256)  I should get that the whole image shows the trasparency effect.

In this case it seems that copying the output of a SCREEN 0 let it at screen 0 level! 
Like I cannot use screen function with graphic text (using Fonts).

Print this item

Video PLAY music grid wiki example code review
Posted by: grymmjack - 06-12-2023, 11:11 PM - Forum: Programs - Replies (2)

In this video I walk through the simple PLAY music grid wiki example by JP, to learn and understand the way it works. 

Check out the QB64PE Wiki Example here:
https://qb64phoenix.com/qb64wiki/index.php/PLAY

The commented source is here:
https://gist.github.com/grymmjack/d7fdcd...5a7da9b765

Experimentation and dissection as usual!

I'm still uploading the video - it should be up in an hour.

Thanks for watching!


https://youtu.be/8vCHnr1MAU4

This is an awesome example!

Code: (Select All)
DIM SHARED grid(16, 16), grid2(16, 16), cur
CONST maxx = 512
CONST maxy = 512
SCREEN _NEWIMAGE(maxx, maxy, 32)
_TITLE "MusicGrid"
cleargrid
DO
    IF TIMER - t# > 1 / 8 THEN cur = (cur + 1) AND 15: t# = TIMER
    IF cur <> oldcur THEN
        figuregrid
        drawgrid
        playgrid
        oldcur = cur
    END IF
    domousestuff
    in$ = INKEY$
    IF in$ = "C" OR in$ = "c" THEN cleargrid
LOOP UNTIL in$ = CHR$(27)

SUB drawgrid
scale! = maxx / 16
scale2 = maxx \ 16 - 2
FOR y = 0 TO 15
    y1 = y * scale!
    FOR x = 0 TO 15
        x1 = x * scale!
        c& = _RGB32(grid2(x, y) * 64 + 64, 0, 0)
        LINE (x1, y1)-(x1 + scale2, y1 + scale2), c&, BF
    NEXT x
NEXT y
END SUB

SUB figuregrid
FOR y = 0 TO 15
    FOR x = 0 TO 15
        grid2(x, y) = grid(x, y)
    NEXT x
NEXT y
FOR y = 1 TO 14
    FOR x = 1 TO 14
        IF grid(x, y) = 1 AND cur = x THEN
            grid2(x, y) = 2
            IF grid(x - 1, y) = 0 THEN grid2(x - 1, y) = 1
            IF grid(x + 1, y) = 0 THEN grid2(x + 1, y) = 1
            IF grid(x, y - 1) = 0 THEN grid2(x, y - 1) = 1
            IF grid(x, y + 1) = 0 THEN grid2(x, y + 1) = 1
        END IF
    NEXT x
NEXT y
END SUB

SUB domousestuff
DO WHILE _MOUSEINPUT
    IF _MOUSEBUTTON(1) THEN
        x = _MOUSEX \ (maxx \ 16)
        y = _MOUSEY \ (maxy \ 16)
        grid(x, y) = 1 - grid(x, y)
    END IF
LOOP
END SUB

SUB playgrid
n$ = "L16 "
'scale$ = "O1CO1DO1EO1FO1GO1AO1BO2CO2DO2EO2FO2GO2AO2BO3CO3D"
scale$ = "o1fo1go1ao2co2do2fo2go2ao3co3do3fo3go3ao4co4do4fo"
FOR y = 15 TO 0 STEP -1
    IF grid(cur, y) = 1 THEN
        note$ = MID$(scale$, 1 + (15 - y) * 3, 3)
        n$ = n$ + note$ + ","  'comma plays 2 or more column notes simultaneously
    END IF
NEXT y
n$ = LEFT$(n$, LEN(n$) - 1)
PLAY n$
END SUB

SUB cleargrid
FOR y = 0 TO 15
    FOR x = 0 TO 15
        grid(x, y) = 0
    NEXT x
NEXT y
END SUB

Print this item