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

 
  post deleted
Posted by: bigriverguy - 06-25-2023, 02:46 PM - Forum: General Discussion - No Replies

post deleted

Print this item

  Questions on style
Posted by: justsomeguy - 06-25-2023, 06:18 AM - Forum: General Discussion - Replies (23)

Hello

I was wanting to ask the forum on how you guys prefer to organize your code, especially on larger projects. I've posted a few of my projects on here and people had trouble getting them to work due to the way I structure my code. I want to make it as easy as possible to share across platforms, since I'm a Linux guy. 

  • Do you prefer a large monolithic source file, or it broken up into libraries?
  • If you use "libraries", do you keep them together with your original project, or do you separate them for reuse on other projects?
  • Do you put the executable in the QB folder or in the source folder?
  • How do you handle assets in regards to your file structure, so that it is easier to share?

Any other tips to help me better share my projects would be appreciated.

Thanks
justsomeguy

Print this item

  Play Summary
Posted by: PhilOfPerth - 06-24-2023, 11:53 PM - Forum: Programs - Replies (7)

The discussion about the PLAY command prompted me to create this little demo of using the features it provides.
Most, if not all of it will be common knowledge, I guess, but I find it useful to clarify my thinking about some of the
less-common ones.

Code: (Select All)
Screen _NewImage(1200, 820, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace")
_Font f&

Color _RGB(255, 255, 0)
Print Tab(28); "The Sounds of Music"; Tab(24); "(as implemented in QB64PE)"
Print

Tones:
Color _RGB(255, 255, 0): Print " Tones:"
Color _RGB(255, 255, 255): Print
Print " The notes span seven octaves, from C in octave 0 to B# in octave 6, including"
Print " the semitones. Select the octave with ";: Color _RGB(255, 255, 0): Print "On";: Color _RGB(255, 255, 255)
Print " (n ";: Color _RGB(255, 255, 255): Print "can be from 0 to 6, default 3),"
Print " and the note from  ";: Color _RGB(255, 255, 0): Print "A ";: Color _RGB(255, 255, 255): Print "to ";: Color _RGB(255, 255, 0): Print "G";
Color _RGB(255, 255, 255): Print ". Use ";: Color _RGB(255, 255, 0): Print "+ ";: Color _RGB(255, 255, 255): Print "or ";: Color _RGB(255, 255, 0)
Print "# ";: Color _RGB(255, 255, 255): Print "for sharps,";: Color _RGB(255, 255, 0): Print " -";: Color _RGB(255, 255, 255): Print " for flats."
Print: Print " Example (2 octaves): ";: Color _RGB(255, 255, 0): Print "L8 O2 CDEFGAB O3 CDEFGAB O4 C";: Color _RGB(255, 255, 255)
Sleep 1: Play "L8 O2 CDEFGAB O3 CDEFGAB O4 C"
Sleep 3: Cls: Print
Semitones:
Color _RGB(255, 255, 0): Print " Semitones:"
Color _RGB(255, 255, 255): Print
Print " Each octave has 12 semitones: ";: Color _RGB(255, 255, 0): Print " C C# D D# E F F# G G# A A# B": Color _RGB(255, 255, 255)
Print " (that's called a chomatic scale). Select notes by their letter, followed by sharp or flat if needed"
Print " (spaces and case are both ignored)."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L8 O3 C C# D D# E F F# G G# A A# B O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L8 O3 C C# D D# E F F# G G# A A# B o4 C"
Sleep 3: Cls: Print
Tones2:
Color _RGB(255, 255, 0): Print " Tones (method 2):"
Color _RGB(255, 255, 255): Print
Print " Any of the 85 individual semitones (from 0 to 84) can also be selected with ";: Color _RGB(255, 255, 0): Print "Nn ": Color _RGB(255, 255, 255)
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L8 N32 N33 N34 N35 N36 N37 N38 N39 N40";: Color _RGB(255, 255, 255)
Sleep 1: Play "L8 N32 N33 N34 N35 N36 N37 N38 N39 N40"
Sleep 3: Cls: Print
Silence:
Color _RGB(255, 255, 0): Print " Silence:"
Color _RGB(255, 255, 255): Print
Print " Pauses, or rests (silence) can be from 1 to 64 quarter-notes in length"
Print " Example: (this is the same string, with pauses inserted:"
Print: Color _RGB(255, 255, 0): Print " O3 C C# D P4 D# E F P4 F# G G# P4 A A# B O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "O3 C C# D P4 D# E F P4 F# G G# P4 A A# B O4 C"
Sleep 3: Cls: Print
notelength:
Color _RGB(255, 255, 0): Print " Note Length (multiple notes):"
Color _RGB(255, 255, 255): Print
Print " Length (in fractions of a note) can be 1 to 64 (eg L16 is 1/16 note in length)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 EEE L4 EEE L8 EEE P2 L2 EEE L4 EEE L8 EEE";: Color _RGB(255, 255, 255)
Sleep 1: Play " L2EEE L4 EEE L8 EEE P2 L2 EEE L4 EEE L8 EEE"
Sleep 1: Print: Print
NoteLength2:
Color _RGB(255, 255, 0): Print " Note Length (single notes):"
Color _RGB(255, 255, 255): Print
Sleep 1: Print " An alternative way of changing a note length is by appending"
Print " a number to the note, rather than using Ln."
Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 CC8CC P2 C8CCC P2 CC8CC": Color _RGB(255, 255, 255): Print
Print " The difference is that the appended version only applies to the previous note, then"
Print " dies, while the Ln version persists until over-written by another Ln."
Sleep 2: Play "L2 CC8CC P2 C8CCC P2 CC8CC"
Sleep 3: Cls: Print
NoteLength3:
Color _RGB(255, 255, 0): Print " Note Length (single notes):"
Color _RGB(255, 255, 255): Print
Print " Duration can also be Modified for individual notes by adding one or two ";: Color _RGB(255, 255, 0): Print ". (periods)";: Color _RGB(255, 255, 255): Print " to the note."
Print " A single period extends its length to 1 1/2 times, while a double period extends it"
Print " to 1 3/4 times its length."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "C P1  C. P1 C.. P2  C P1 C. P1 C.. P2  C P1  C. P1 C..";: Color _RGB(255, 255, 255)
Sleep 1: Play "C P1  C. P1 C.. P2  C P1 C. P1 C.. P2  C P1  C. P1 C.."
Sleep 3: Cls: Print
Mood:
Color _RGB(255, 255, 0): Print " Mood:"
Color _RGB(255, 255, 255): Print
Print " The mood of music can be Modified for groups or for individual notes:"
Color _RGB(255, 255, 0): Print " MS = Staccato (3/4 length), MN = normal (7/8 length), ML = Legato (1.5 times length)":: Color _RGB(255, 255, 255)
Print " Aide de memoir: S for Short, N for Normal, L for Long)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 MS CCCC P8 MN CCCC P8 ML CCCC P1 MS CCCC P8 MN CCCC P8 ML CCCC";: Color _RGB(255, 255, 255)
Sleep 1: Play "L2 MS CCCC P8 MN CCCC P8 ML CCCC P1 MS CCCC P8 MN CCCC P8 ML CCCC"
Sleep 3: Cls: Print
Speed:
Color _RGB(255, 255, 0): Print " Speed (Tempo):"
Color _RGB(255, 255, 255): Print
Print " Tempo, or speed can be from 32 to 255 quarter-notes per minute"
Print " (Default is 120 - standard military march tempo)"
Print " Use ";: Color _RGB(255, 255, 0): Print "Tn";: Color _RGB(255, 255, 255): Print " (where n is from 32 to 255)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "O3 T90 CDEFGAB O4C T120 CDEFGAB O3C T240 CDEFGAB O4C": Color _RGB(255, 255, 255)
Sleep 1: Play "O3 T90 CDEFGAB O4C T120 O3 CDEFGAB O4C T240 O3 CDEFGAB O4C"
Sleep 3: Cls: Print
Volume:
Color _RGB(255, 255, 0): Print " Volume:"
Color _RGB(255, 255, 255): Print
Print " Volume is specified with ";: Color _RGB(255, 255, 0): Print " Vn";: Color _RGB(255, 255, 255): Print ", where n can be be 0 to 100)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2 V100 C P16 V75 C P16 V50 C P16 V25 C V100 C P16 V75 C P16 V50 C P16 V25 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L2 V100 C P16 V75 C P16 V50 C P16 V25 C V100 C P16 V75 C P16 V50 C P16 V25 C"
Sleep 3: Cls: Print
Polyphonics:
Color _RGB(255, 255, 0): Print " Polyphonics:"
Color _RGB(255, 255, 255): Print
Print " Polyphonics (multiple notes simultaneously) is provided with commas between notes"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L1 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L1 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C P4 O3 C,E,G,O4 C"
Sleep 3: Cls: Print
BackgroundSound:
Color _RGB(255, 255, 0): Print " Background Sound:"
Color _RGB(255, 255, 255): Print
Print " A programme can either continue executing, or pause while music is played."
Color _RGB(255, 255, 0): Print " MF (Music Foreground) pauses programme, MB allows programme to continue.": Color _RGB(255, 255, 255)
Print: Print " Example: (Press a key)":
Play "MF L2 O3 CDEFGAB O4 C"
For a = 1 To 4: Print " Music has finished!": _Delay .2: Next
Sleep 1: Play "MB L2 O3 CDEFGAB O4 C"
For a = 1 To 4: Print " Music is playing!";: _Delay .2: Next
Sleep 3: Cls: Print
timbre:
Color _RGB(255, 255, 0): Print " Timbre (richness):"
Color _RGB(255, 255, 255): Print
Print " The timbre, or texture  of notes can be changed by changing their waveform with the ";: Color _RGB(255, 255, 0): Print " @";: Color _RGB(255, 255, 255): Print " symbol."
Print " There are 5 waveforms: ";: Color _RGB(255, 255, 0): Print "1=square,  2=sawtooth,  3=triangle,  4=sine,  5=white-noise": Color _RGB(255, 255, 255)
Print " (You may need to turn volume up to hear the difference here)"
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print " L2 @1 C P2 @2 C P2 @3 C P2 @4 C P2 @5 C P4 @1 C P2 @2 C P2 @3 C P2 @4 C P3 @4 C": Color _RGB(255, 255, 255)
Sleep 1: Play "L2 @1 C P2 @2 C P2 @3 C P2 @4 C P2 @5 C P4 @1 C P2 @2 C P2 @3 C P2 @4 C P3 @4 C"
Print " (the reason for the final @4 in this string, is that the @ is sticky, and remains for the next PLAY string)."
Sleep 3: Cls: Print
accent:
Color _RGB(255, 255, 0): Print " Accent (attack):"
Color _RGB(255, 255, 255): Print
Print " The attack rate of notes can be changed with ";: Color _RGB(255, 255, 0): Print "Q";: Color _RGB(255, 255, 255): Print " (can be from 0 to 100)."
Print " This changes note from, say the emphatic piano sound, to the softer sound of a flute."
Print: Print " Example: ";: Color _RGB(255, 255, 0): Print "L2  Q0 CEG P1  Q50 CEG P1  Q100 CEG": Color _RGB(255, 255, 255)
Sleep 1: Play "L2  Q0 CEG P1  Q50 CEG P1  Q100 CEG": Sleep 1
Print: Print " Press a key to finish"
Sleep: System

Print this item

  BAM: Thinking about adding a SCROLL statement
Posted by: CharlieJV - 06-24-2023, 05:56 PM - Forum: QBJS, BAM, and Other BASICs - Replies (12)

   

Print this item

  _Hypot() Function
Posted by: bplus - 06-24-2023, 03:38 PM - Forum: Keyword of the Day! - Replies (7)

Wiki help: https://qb64phoenix.com/qb64wiki/index.php/HYPOT

What wiki doesn't say is that this function contains a very useful Distance Formula between two points on a 2D plane.

Distance between two points (x1, y1) and (x2, y2) ( a diagram would be helpful here, sorry I am going to attempt in words only).

Distance = SQR((x1 - x2) ^ 2 + (y1 - y2) ^ 2)

(x1 - x2) represents the length of one leg of a right triangle
(y1 - y2) represents the other leg

So by the Pythagorean Theorem the Hypotenuse (length) equals the SQR of the square (^2) of both sides.
ie Distance = _Hypot(x1 - x2), (y1 - y2))

The point is we have a Distance formula built-into the QB64 Functions and don't need to carry a Distance Function from our Toolbox of Subs and Functions.

I bring this up because I am kicking myself for missing it yesterday in the enRitchied Code for Missile Command here:
https://staging.qb64phoenix.com/showthre...8#pid17088

I shoulda, coulda, done it better like this:

Code: (Select All)
Option _Explicit '                          Get into this habit and save yourself grief from Typos

_Title "Missile Command EnRitchied" '    another b+ mod 2023-06-24, replace distance with _Hypot.
'                                  I probably picked up this game at the JB forum some years ago.

'    Get Constants, Shared Variables and Arrays() declared. These Will Start with Capital Letters.
'        Get Main module variables and arrays declared with starting lower case letters for local.
'        This is what Option _Explicit helps, by forcing us to at least declare these before use.
'      While declaring, telling QB64 the Type we want to use, we can also give brief description.


Const ScreenWidth = 800, ScreenHeight = 600 '                    for our custom screen dimensions
Dim As Integer bombX, bombY '                          incoming bomb screen position to shoot down
Dim As Single bombDX, bombDY '                  DX and DY mean change in X position and Y position
Dim As Integer missileX, missileY '                                              missile position
Dim As Single missileDX, missileDY '                            change X and Y of Missile position
Dim As Integer hits, misses '                                                score hits and misses
Dim As Integer mouseDistanceX, mouseDistanceY '      for calculations of missile DX, DY direction
Dim As Single distance '                                                                    ditto
Dim As Integer radius '                                      drawing hits with target like circles
Dim As Integer boolean '                        to shorten the code line with a bunch of OR tests

Screen _NewImage(ScreenWidth, ScreenHeight, 32) ' sets up a graphics screen with custom dimensions
'                                          the 32 is for _RGB32(red, green, blue, alpha) coloring.
'
_ScreenMove 250, 60 '            this centers screen in my laptop, you may need different numbers

InitializeForRound: '                            reset game and start a round with a bomb falling
Cls
bombX = Rnd * ScreenWidth '                                starts bomb somewhere across the screen
bombY = 0 '                                                          starts bomb at top of screen
bombDX = Rnd * 6 - 3 '                                  pick rnd dx = change in x between -3 and 3
bombDY = Rnd * 3 + 3 '                pick rnd dy = change in y between 3 and 6,  > 0 for falling
missileX = ScreenWidth / 2 '                                  missile base at middle across screen
missileY = ScreenHeight - 4 '  missile launch point at missile base is nearly at bottom of screen
missileDX = 0 '                          missile is not moving awaiting mouse click for direction
missileDY = 0 '                                                                              ditto
distance = 0 '                                            distance of mouse click to missile base

Do
    'what's the score?
    _Title "Click mouse to intersect incoming  Hits:" + Str$(hits) + ", misses:" + Str$(misses)
    _PrintString (400, 594), "^" '                                draw missle base = launch point
    While _MouseInput: Wend '                                            poll mouse to get update
    If _MouseButton(1) Then '              the mouse was clicked calc the angle from missile base
        mouseDistanceX = _MouseX - missileX
        mouseDistanceY = _MouseY - missileY
        distance = (mouseDistanceX ^ 2 + mouseDistanceY ^ 2) ^ .5
        missileDX = 5 * mouseDistanceX / distance
        missileDY = 5 * mouseDistanceY / distance
    End If

    missileX = missileX + missileDX '                                      update missile position
    missileY = missileY + missileDY '                                                        ditto
    bombX = bombX + bombDX '                                                  update bomb position
    bombY = bombY + bombDY '                                                                ditto

    '                    I am about to use a boolean variable to shorten a very long IF code line
    '                                boolean is either 0 or -1 when next 2 statements are execued
    '                                            -1/0 or True/False is everything still in screen?
    boolean = missileX < 0 Or missileY < 0 Or bombX < 0 Or bombY < 0
    boolean = boolean Or missileX > ScreenWidth Or bombX > ScreenWidth Or bombY > ScreenHeight
    If boolean Then ' done with this boolean
        '  reuse boolean to shorten another long code line checking if bomb and missile in screen
        boolean = bombY > ScreenHeight Or missileX < 0 Or missileY < 0 Or missileX > ScreenWidth
        If boolean Then misses = misses + 1
        GoTo InitializeForRound
    End If

    '    if the distance between missle and bomb < 20 pixels then the missile got the bomb, a hit
    'If ((missileX - bombX) ^ 2 + (missileY - bombY) ^ 2) ^ .5 < 20 Then '  show a strike as target

    'rewrite the above line using _Hypot() which is hidden distance forumla
    If _Hypot(missileX - bombX, missileY - bombY) < 20 Then


        For radius = 1 To 20 Step 4 '                        draw concetric circles to show strike
            Circle ((missileX + bombX) / 2, (missileY + bombY) / 2), radius
            _Limit 60
        Next
        hits = hits + 1 '                                                    add hit to hits score
        GoTo InitializeForRound
    Else
        PSet (missileX, missileY), &HFFFFFF00 '                            draw your missle yellow
        PSet (bombX, bombY), &HFF0000FF '                                          draw bomb blue
    End If
    _Limit 20
Loop

Update: testing what happens when I edit this post and save.
Update again: lost the nice edge on right side, can I get it back? No I guess not.

Print this item

Photo QB64 Phoenix Edition Summer 2023 Banner Contest Poll
Posted by: grymmjack - 06-24-2023, 03:22 PM - Forum: Announcements - Replies (46)

QB64 Phoenix Edition Summer 2023 Banner Contest

Please vote for your choice in the banner contest!
*edit* @bplus entry was updated for final version. @JRace submission was added. @dbox last submission was kept all others removed, and votes moved to @dbox last submission if they existed for other submissions.

*subtle drum-roll*

And the entries for the QB64 PE Summer 2023 Banner Contest are...

*cymbals*

1. @bplus - Summer Fun Edition
[Image: attachment.php?aid=1912]

2. @TerryRitchie - Summer Edition (made with QB64PE source)
[Image: attachment.php?aid=1917]

3. @JRace - Summer Edition modification on @TerryRitchie
[Image: 7-JRace-QB64-PE-Summer-Edition-created-w...itchie.png]

4. @SMcNeill - Summer Edition Phoenix (get well soon Steve)
[Image: attachment.php?aid=1933]

5. @dbox - Angry Birds - Sun, Sand, and Syntax Errors
[Image: attachment.php?aid=1945]

---

The winner of this poll will have their work featured on the forum on all themes!

Good luck to all the contestants and please place your votes now.

We will accept voting until July 1st at which time the winner will be chosen based on the number of votes their submission has received!

---

Feel free to talk and socialize in this thread and to congratulate the winner when the contest is over!

Print this item

  BAM documentation enhancement in the works: syntax diagrams
Posted by: CharlieJV - 06-23-2023, 09:02 PM - Forum: QBJS, BAM, and Other BASICs - Replies (2)

A few done so far related to BAM enhancements in the works:

The All Syntax Diagrams page.

Print this item

Music Fake space music
Posted by: mnrvovrfc - 06-23-2023, 06:55 PM - Forum: Utilities - Replies (2)

I was supposed to go further with my "musak" creators for PLAY, but decided this time to provide something different. This was an idea I already revealed. I would like to thank Mr.Why from the old forum, from the one Galleon was administrator, for inspiring me many years ago into stuff like this.

This is a program that does silly "space music". It creates an empty QB64 screenie because I'm not a good artist, I focused only on the sound. Press [ESC] to quit. Don't panic if it doesn't leave straight away, give it 3 seconds at least until the sound dies away.

This purposely does 440 samples to generate sound or not, then checks if it could create a new voice. Usually the "space dot" is created which is very brief. At other times, it could create a whitenoise wash (would like to be able to produce a brown or pink noise here instead), or it could create a "space rumble" although not a very good one maybe because the pitches are a bit too high.

There are two constants that could be adjusted near the top of the program. I don't recommend changing "NUMNOISE" to a value near "NUMSOUNDS", otherwise the program will choose the "deep" noises more often than the "dots".

Code: (Select All)

'by mnrvovrfc 23-June-2023
OPTION _EXPLICIT

CONST NUMSOUNDS = 50, NUMNOISE = 10

'active = the voice is active (1=dot random sine; 2=whitenoise; 3=deep space "rumble" sine)
'enable = the voice is being sent to audio output
' (after amplitude envelope goes through attack and release, this is set to zero and "hold" is updated)
'freq = voice frequency, could be changed by "tun"
'acount = amplitude attack increment in degrees
'rcount = amplitude release increment in degrees
' these two operate over half a sinewave to do an amplitude envelope
'a = degrees for amplitude envelope
't = time according to computation in QB64 Wiki example for _SNDRAW
'vol = volume adjustment for the voice
'tun = small change in frequency only for active=3
'hold = after the voice stops being enabled, how long to hold until making this voice available again
' this is a count in samples so depends on sampling rate
' I assumed 44100Hz so this could go for as long as four seconds but not less than 1/4-second
' this is to prevent the sound scape from being too thick
TYPE spacemtype
AS _BYTE active, enable
AS SINGLE freq, acount, rcount, tun, vol, a
AS LONG t, hold
END TYPE

DIM SHARED s(1 TO NUMSOUNDS) AS spacemtype
DIM AS INTEGER kount, i, j, o
DIM AS SINGLE twopi, ao, ag, samprate

twopi = _PI * 2
samprate = _SNDRATE

RANDOMIZE TIMER
_TITLE "Fake Cosmos!"

DO
IF kount < NUMNOISE THEN
kount = kount + 1
createnewsound Rand(2, 3)
ELSE
createnewsound 1
END IF
FOR o = 1 TO 440
ag = 0
FOR i = 1 TO NUMSOUNDS
IF s(i).active THEN
s(i).t = s(i).t + 1
IF s(i).a > 90 THEN
s(i).a = s(i).a + s(i).rcount
ELSE
s(i).a = s(i).a + s(i).acount
END IF
IF s(i).a > 180 THEN
s(i).enable = 0
s(i).hold = s(i).hold - 1
IF s(i).hold < 1 THEN
IF s(i).active > 1 THEN kount = kount - 1
s(i).active = 0
EXIT FOR
END IF
END IF
IF s(i).enable THEN
IF s(i).freq THEN
ao = s(i).freq
IF s(i).tun THEN s(i).freq = s(i).freq + s(i).tun
ELSE
ao = Random1(7900) + 100
END IF
ao = ao / samprate
ao = (SIN(ao * twopi * s(i).t) * s(i).vol * SIN(_D2R(s(i).a)))
ag = ag + ao
END IF
END IF
NEXT 'i
IF ag < -1.0 THEN ag = -1.0
IF ag > 1.0 THEN ag = 1.0
_SNDRAW ag
NEXT 'o
DO WHILE _SNDRAWLEN > 3
_LIMIT 100
IF _KEYDOWN(27) THEN EXIT DO
LOOP
LOOP UNTIL _KEYDOWN(27)

DO WHILE _SNDRAWLEN
_LIMIT 100
LOOP
SYSTEM


SUB createnewsound (which)
DIM AS INTEGER i, j
FOR i = 1 TO NUMSOUNDS
IF s(i).active = 0 THEN j = i: EXIT FOR
NEXT i
IF j = 0 THEN EXIT SUB
s(j).active = which
s(j).enable = 1
s(j).a = 0
IF which = 1 THEN
s(j).freq = Rand(5, 80) * 50
s(j).acount = Rand(30, 100) / 100
s(j).rcount = Rand(30, 100) / 100
s(j).tun = 0
s(j).vol = Rand(10, 50) / 100
s(j).hold = 0
ELSEIF which = 2 THEN
s(j).freq = 0
s(j).tun = 0
s(j).acount = Rand(7, 50) / 10000
s(j).rcount = Rand(25, 100) / 2000
s(j).vol = 0.0625
s(j).hold = Rand(11025, 88200)
ELSEIF which = 3 THEN
s(j).freq = Rand(80, 240)
s(j).acount = Rand(25, 100) / 2000
s(j).rcount = Rand(7, 50) / 10000
s(j).vol = 0.125
s(j).hold = Rand(22050, 176400)
IF Random1(3) = 1 THEN
IF s(j).freq > 160 THEN s(j).tun = -1 ELSE s(j).tun = 1
s(j).tun = s(j).tun * Random1(100) / 1E+6
ELSE
s(j).tun = 0
END IF
END IF
END SUB


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

Print this item

  Problem with DRAW or my "scanning" routine?
Posted by: James D Jarvis - 06-23-2023, 04:34 PM - Forum: Help Me! - Replies (9)

Is the problem with my scanning/conversion routine or how DRAW actually draws?
(The draw statements it produces could be optimized to be briefer, I just haven't done that here. I want to get the scanning and rendered correctly first).

Code: (Select All)
'***************************************************************
'scanning a section of the screen converting and writing it with DRAW
'why doesn't it work?
'***************************************************************
Screen _NewImage(480, 400, 256)
$Console
_Console Off
Randomize Timer
Cls
_PrintMode _KeepBackground
_PrintString (0, 0), "AB"
'Line (1, 1)-(1, 14), 15
_Delay 0.5
msg$ = "<-- scanning this as a sample image"
_PrintString (40, 0), msg$
x = 0: y = 0
dd$ = ""
wid = 16
ht = 16
Draw "s4"
dd$ = Scan_draw$(x, y, ht, wid)
_Delay 1
Locate 4, 4
Line (40, 0)-(40 + Len(msg$) * 8, 15), 0, BF
msg$ = "ready (press any key)"
_PrintString (0, 100), msg$
Sleep
Line (0, 100)-(Len(msg$) * 8, 115), 0, BF
Locate 4, 4
Print "Draw Scanned image, Why isn't it drawing correctly?"
Print "Is the problem in the scanning routine or in how draw functions?"
putdraw 50, 0, dd$
drawto_console dd$
Input alldone$
End
'***************************************************************
' subroutines for making use of draw strings in 256 color mode.
' color 0 is treated as transpaernt
Sub putdraw (xx, yy, dd$)
    Draw "bm" + Str$(xx) + "," + Str$(yy) + dd$
End Sub
Sub drawto_console (dd$)
    'program must have console output activated earlier
    'prints the string in a clean console window so it may be copied and pasted on any system with console support
    sd& = _Dest
    _Console On
    _Dest _Console
    Cls
    Print dd$
    Print
    Print "Copy and Paste the above text for future use in DRAW commands"
    _Dest sd&
End Sub
Function Scan_draw$ (sx, sy, ht, wid)
    'scan a screen area starting at point sx,sy and saving it to the string DRW$ for use in later draw commands
    'simply scans each row and tracks color changes
    For y = 0 To ht - 1
        x = 0
        Do
            klr = Point(sx + x, sy + y)
            n = -1
            Do
                n = n + 1
                nklr = Point(x + n, y)

            Loop Until nklr <> klr Or x + n >= wid
            If klr = 0 Then
                dd$ = dd$ + "br" + _Trim$(Str$(n))
            Else
                dd$ = dd$ + "C" + _Trim$(Str$(klr)) + " " + "R" + _Trim$(Str$(n))
            End If
            x = x + n
        Loop Until x >= wid
        dd$ = dd$ + "bd1bl" + Str$(wid)
    Next y
    Scan_draw$ = dd$
End Function

Print this item

  raylib-64
Posted by: a740g - 06-23-2023, 02:02 PM - Forum: One Hit Wonders - Replies (10)

This is a QB64-PE binding library for the popular raylib library. raylib is a simple and easy-to-use library to enjoy videogames programming.

a740g/raylib-64: QB64-PE bindings for raylib (a simple and easy-to-use library to learn videogames programming) (github.com)

https://github.com/a740g/raylib-64/archi...master.zip

Note that this is still a work-in-progress. However, many things already work. Please read the FAQ and notes in README.md before using the library.

Open any feedback / issue here: Issues · a740g/raylib-64 (github.com)

Pull Requests are welcome.  Smile

Cheers!

Update: Finished bindings for 2D physics library Physac.

[Image: screenshot2.png]

[Image: screenshot3.png]

[Image: screenshot4.png]

[Image: Screenshot-2023-07-23-042302.png]

Print this item