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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 495
» Latest member: EOTechggh
» Forum threads: 2,846
» Forum posts: 26,669

Full Statistics

Latest Threads
Editor WIP
Forum: bplus
Last Post: aadityap0901
1 hour ago
» Replies: 12
» Views: 661
QBJS v0.9.0 - Release
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
4 hours ago
» Replies: 14
» Views: 213
1990's 3D Doom-Like Walls...
Forum: Programs
Last Post: SierraKen
4 hours ago
» Replies: 7
» Views: 219
Fun with Ray Casting
Forum: a740g
Last Post: a740g
7 hours ago
» Replies: 2
» Views: 66
Big problem for me.
Forum: General Discussion
Last Post: bplus
10 hours ago
» Replies: 7
» Views: 79
discover graphics with xa...
Forum: Programs
Last Post: hsiangch_ong
11 hours ago
» Replies: 0
» Views: 26
another variation of "10 ...
Forum: Programs
Last Post: Jack002
Yesterday, 10:05 PM
» Replies: 37
» Views: 548
Aloha from Maui guys.
Forum: General Discussion
Last Post: doppler
Yesterday, 03:32 PM
» Replies: 14
» Views: 335
Cautionary tale of open, ...
Forum: General Discussion
Last Post: doppler
Yesterday, 03:28 PM
» Replies: 0
» Views: 26
Extended KotD #22: _MOUSE...
Forum: Keyword of the Day!
Last Post: SMcNeill
Yesterday, 12:29 AM
» Replies: 0
» Views: 56

 
  Merry Xmas! Santa Steve comes bringing gifts to all!!
Posted by: SMcNeill - 12-22-2022, 12:52 AM - Forum: Learning Resources and Archives - Replies (14)

https://1drv.ms/u/s!AknUrv8RXVYMm_UjHLPp...q8Lyc?dl=1

As usual, it's Christmas time once again, and those of you who have been members of the QB64 community for a while, you know what that means!!  It's the time of year when Santa Steve shows up and offers a hard drive full of goodies for one and all!

Now most years, Santa Steve just downloads and archives the QB64 wiki, and makes them available for one and all so they can have full access to the year's newest wiki information -- but this year, Santa Steve has went above and beyond even that!!  This year, Santa Steve is hosting and offering the whole QB64-PE FORUMS as well as the QB64-PE WIKI for everyone to enjoy!!

https://1drv.ms/u/s!AknUrv8RXVYMm_UjHLPp...q8Lyc?dl=1

Grab it at the link above!!

Grab it at this link: https://1drv.ms/u/s!AknUrv8RXVYMm_UjHLPp...q8Lyc?dl=1

Grab it at the link below:

https://1drv.ms/u/s!AknUrv8RXVYMm_UjHLPp...q8Lyc?dl=1

If you want it, there's no reason why you can't grab a copy of the QB64-PE Archives for 2022!  It's free!  It's available for one and all!  

If you're in a country or area that absolutely can't download the 1.3GB archive, then post here!  It's Christmas time, for goodness sake!  Somebody can burn off a copy of the archive to a DVD and snail mail it to you, if that's absolutely necessary!

QB64-PE Archives 2022 -- for one and for all!!  

Enjoy, guys!  (And you gals out there too!)

Print this item

Lightbulb Asteroid Shower
Posted by: mnrvovrfc - 12-22-2022, 12:08 AM - Forum: Programs - Replies (15)

The idea of this rather simple game comes from "Astrostorm", which I beheld first on an Apple IIe nearly 40 years back!

Lazy game program. Just press spacebar to start or stop your spaceship. Beware: the response could be a bit late. Work your way toward the top of the screen. The game ends if your spaceship is bashed by an asteroid.

Code: (Select All)
'by mnrvovrfc 2022-dec-21
OPTION _EXPLICIT
DIM AS INTEGER px, py, ph, cm, cb, uc, j, ay, ax, fc
DIM AS LONG kk
DIM AS _BYTE dead, done, holdspace
DIM AS STRING sp40

_TITLE "Astroshower LC"
WIDTH 40, 25: CLS

px = 1: py = 20: ph = 0: cm = 10: cb = 0: kk = 0
sp40 = SPACE$(40)

dead = 0
done = 0
holdspace = 0
uc = 20
fc = 8
LOCATE 24, 1: COLOR 7: PRINT 0;
LOCATE py, px: COLOR fc: PRINT ">";
DO UNTIL dead OR done
    IF uc > 0 THEN
        uc = uc - 1
        IF uc < 1 THEN fc = 15
    END IF
    FOR j = 1 TO 5
        _DELAY 0.015
        IF uc < 1 THEN
            IF _KEYDOWN(27) THEN done = 1: EXIT FOR
            IF _KEYDOWN(32) AND holdspace = 0 THEN
                IF cm > 0 THEN cm = cm - 1
                holdspace = 1
                IF ph = 0 THEN ph = 1 ELSE ph = 0
            END IF
            IF _KEYDOWN(32) = 0 AND holdspace THEN holdspace = 0
        END IF
    NEXT ''j
    IF done THEN EXIT DO
    _DISPLAY
    IF ph = 1 THEN
        kk = kk + cm + 1
        LOCATE 24, 1: COLOR 7: PRINT kk;
        COLOR 15
        LOCATE py, px: PRINT " ";
        px = px + ph
        IF px > 40 THEN
            px = 1
            ph = 0
            IF py > 10 THEN
                py = py - 1
                cb = cb + 1
            END IF
            cm = cm + cb
        END IF
        IF SCREEN(py, px) = 42 THEN dead = 1: EXIT DO
        LOCATE py, px: PRINT ">";
    END IF
    j = random1(7) - 4
    IF j > 0 THEN
        COLOR 7
        DO WHILE j > 0
            DO
                ax = random1(38) + 1
            LOOP UNTIL SCREEN(1, ax) = 32
            LOCATE 1, ax: PRINT "*";
            j = j - 1
        LOOP
    END IF
    LOCATE py, px: COLOR fc: PRINT " ";
    COLOR 7
    ay = 23
    DO WHILE ay > 1
        ax = 40
        DO WHILE ax > 1
            LOCATE ay, ax: PRINT CHR$(SCREEN(ay - 1, ax));
            ax = ax - 1
        LOOP
        ay = ay - 1
    LOOP
    LOCATE 1, 1: PRINT sp40;
    IF SCREEN(py, px) = 42 THEN dead = 1: EXIT DO
    LOCATE py, px: COLOR fc: PRINT ">";
LOOP
_AUTODISPLAY
IF dead THEN
    LOCATE 1, 1: COLOR 4
    PRINT "You have died!";
    END
END IF
SYSTEM


FUNCTION random1& (maxval)
    random1 = INT(RND * maxval + 1)
END FUNCTION

Print this item

  Library help
Posted by: Pete - 12-21-2022, 08:22 PM - Forum: Help Me! - Replies (15)

Anyone know where I can find a cute librarian? Oops, wrong forum...

I'm finding I'd like to have several shorter libraries, rather than combined functions made into a single libraries. For example, I can have a single gui library that creates a form, allows user selection and input, and produces menus, or...

I can have...

Keyboard / Mouse library
Menu library
Form library
Input Text library

What's cool is each of the above could be ported to other apps.

So here's my options...

1) Each library loads the DIM SHARD statements into the main.

2) I have to pass all variables from every library I create, regardless if libraries I include in my app only use some of those variables and arrays.

Frankly I'm leaning towards option 1. To get around naming issues, I'd go with naming the variables in relation to the library they are best associated with like MyMenuChoices$, etc.

What do you guys think or do?

Pete

Print this item

  suggestion: initialize array values within the DIM statement
Posted by: bobalooie - 12-21-2022, 03:36 AM - Forum: General Discussion - Replies (19)

How difficult would it be to implement something similar to this in QB64PE? 

OPTION _EXPLICIT
DIM AS LONG LNUMS(5) = {1, 2, 5, 8, 4000}

This is syntax similar to C, and it is also supported to an extent by FreeBASIC. I have used this construct in FreeBASIC, and I have found it useful when initializing short arrays of 'fixed' data in a program.

(I always use OPTION _EXPLICIT, it has saved me more than a few times from fat-fingered typing.)

Print this item

  QB64 crash!?
Posted by: eoredson - 12-21-2022, 03:27 AM - Forum: Help Me! - Replies (5)

Try this code and tell me what happens..

btw: It does not display an error..

Code: (Select All)
Print clock$

Function clock$
  clock$ = "date/time is:"
  clock$ = clock$ + Date$ + " " + Time$
End Function

Print this item

  DAY 041: ELSEIF
Posted by: Pete - 12-21-2022, 02:29 AM - Forum: Keyword of the Day! - Replies (3)

Sounds like a keyword my av-ee-tar would like. ELSEIF ya don't, I'm eh gonna blast youse.

Okay, settle down Yosemite, and let's have a look at this handy conditional statement.


SYNTAX:

IF foo1 THEN
ELSEIF foo2 THEN
END IF

Usage: Handles multiple conditions while excluding program flow through unnecessary evaluation statements.

This is a nice alternative to SELECT CASE, and better than forcing your program through multiple IF/THEN statements, which could cause more than one desired condition to be triggered.

Example:

Code: (Select All)
a = 1: b = 2
IF a > b OR j = 0 THEN
    PRINT "1"
ELSEIF a = b OR j = 0 THEN PRINT "2"
ELSEIF a < b OR j = 0 THEN PRINT "3"
END IF

PRINT "---------------------------------"

IF a > b OR j = 0 THEN PRINT "1"
IF a = b OR j = 0 THEN PRINT "2"
IF a < b OR j = 0 THEN PRINT "3"

So by using IF THEN with ELSEIF in a block statement we get an output of '1' and done in the first condition block vs all three numbers printed out in the second IF/THEN only block.

--------------------------------------------------------------------------------------

Edit: Oh, here's a fun coding fact, inspired by mn's post below....

We can code a regular IF/THEN non-block statement with THEN (line number)...
...but with an IF/THEN/ESLEIF, the THEN part cannot reference a line number without using GOTO with it.:

Code: (Select All)
IF a = b THEN 5 ' This is accepted.
PRINT "Skip me!"
5 PRINT "Okay, I skipped you!"

IF a = b THEN
    PRINT "Okay!"
ELSEIF a < b THEN GOTO 5 ' You have to include GOTO here or it won't compile.
END IF

Pete

Print this item

  DAY 040: _TOGGLEBIT
Posted by: Pete - 12-19-2022, 07:43 PM - Forum: Keyword of the Day! - Replies (16)

Here is an interesting one for all you bit flipping coders out there...

_TOGGLEBIT

SYNTAX result = _TOGGLEBIT(numericalVariable, numericalValue)

Usage: For cross breeding elephants and rhinos. What's that good for? Eleph-i-no!

Okay, I know bit-flipping can be used somehow to detect a hardware malfunction in a Windows operating system. I would imagine encryption would be another practical use. I also did some reading on using bit-flipping as an alternative to doing string math, but that was a very involved process, so I have no work created to demonstrate how that would be accomplished.

What I can easily see if we flip the first bit, we can get a 0 or 1, which is good for a toggle function.

Now the easiest method to create your own toggle for a program has been demonstrated in this forum numerous times...

toggle = 1 - toggle Mark posted about that one months ago.

So using toggle = 1 - toggle we start out with toggle = 0, hence 1 - 0 = 1. Loop again and 1 - 1 = 0

Now we can accomplish the exact same toggle effect with _TOGGLEBIT, as follows...

Code: (Select All)
DIM a AS INTEGER ' Also avilable are _INTEGER64, LONG, _UNSIGNED, and _BYTE,
DO
    DO
        SELECT CASE a
            CASE 0
                PRINT " Steve is good...";
            CASE 1
                PRINT " Pete is better!": PRINT
        END SELECT
        SLEEP
        a = _TOGGLEBIT(a, 0)
        mykey$ = INKEY$
    LOOP UNTIL mykey$ = CHR$(9) OR mykey$ = CHR$(27)
    PRINT
    FOR i = 0 TO 15
        PRINT i; _TOGGLEBIT(a, i)
    NEXT
    PRINT
LOOP UNTIL mykey$ = CHR$(27)

So maybe this example will goad Steve a "bit" to elaborate on some of his experiences with _TOGGLEBIT. Also, I'd love to hear some comments from @jack about bit-flipping, and his experience with coding decfloat.

Pete

Print this item

  SCREEN ZERO HERO PRODUCTIONS...
Posted by: Pete - 12-19-2022, 04:41 PM - Forum: Christmas Code - Replies (7)

Code: (Select All)
t$ = "Frosty the No-man"
_TITLE t$
WIDTH 90, 25
PALETTE 5, 8
COLOR 15, 5
CLS
$UNSTABLE:MIDI
$MIDISOUNDFONT:DEFAULT
PRINT: PRINT " SCREEN ZERO HERO PRESENTS, A FROSTY CHRISTMAS!...": PRINT

DIM song$(1), songhand&(1)
song$(1) = "frosty.mid"
songhand&(1) = _SNDOPEN(song$(1), "stream")
IF songhand&(1) = 0 THEN
    PRINT "Error opening file: "; song$(1), _CWD$
    END
END IF

_SNDPLAY songhand&(1)

_DELAY 10: CLS: PRINT: _DELAY 1

DO
    READ a$
    IF a$ = "EOF" THEN EXIT DO
    seed = 0
    LOCATE , 2
    DO
        i = i + 1
        j = INSTR(seed, a$ + " ", " ")
        PRINT MID$(a$, seed, j - seed + 1);
        SELECT CASE i
            CASE 1
                _DELAY .75
            CASE 2
                _DELAY .35
            CASE ELSE
                _DELAY .42
        END SELECT
        seed = j + 1
    LOOP UNTIL j = 0
    PRINT: PRINT
    IF i = 1 THEN _DELAY 1.4 ELSE _DELAY .75
LOOP

DATA "Frosty the snowman, had two very cold snowballs"
DATA "'Til a kid named Sue, didn't think it through, and wrapped him up with Grandma's shawls"
DATA "Now Frosty the snowman, won't be smiling on Christmas day"
DATA "'Cause the heat from the shawls, warmed up his snow balls, 'till they dropped and rolled away"
DATA "There must have been, some magic in, that Super Glue we found"
DATA "'Cause when we glued his balls back on, he began to dance around"
DATA "Oh... Frosty the snowman, now he's jolly and that's a fact"
DATA "Even though he knows, his snowballs are froze, he's so glad he's got them back..."
DATA "FROSTY!"
DATA "EOF"


Requires the midi file attached below if you don't already have it from Dav's screensaver... (Thanks Dav!)


Pete



Attached Files
.7z   frosty.7z (Size: 5.89 KB / Downloads: 108)
Print this item

  DAY 039: VIEW PRINT
Posted by: Pete - 12-19-2022, 04:48 AM - Forum: Keyword of the Day! - Replies (4)

Every SCREEN ZERO HERO needs this keyword...

SYNTAX VIEW PRINT [topRow% TO bottomRow%]

Usage: Restricts the printable area of the screen.

Okay, let's take this puppy for a spin.

Use VIEW PRINT anytime you want to divide your text screen into a skin and message area.

Code: (Select All)
msg$ = "My Header"
COLOR 15, 1
LOCATE 1, 1: PRINT SPACE$(_WIDTH * 2);
LOCATE _HEIGHT - 1, 1: PRINT SPACE$(_WIDTH * 2);
LOCATE _HEIGHT, 1: PRINT SPACE$(_WIDTH);
LOCATE 1, _WIDTH / 2 - LEN(msg$) / 2: PRINT msg$;
LOCATE 2, 1: PRINT STRING$(_WIDTH, 196);
LOCATE _HEIGHT - 1, 1: PRINT STRING$(_WIDTH, 196);
PALETTE 5, 25
COLOR 7, 5
top% = 3
bottom% = _HEIGHT - 2
VIEW PRINT top% TO bottom%
CLS 2
msg$ = "Press [1] for info  /  Press [2] to make fun of Steve  /  Press [Esc] to end"
COLOR 15, 1: LOCATE _HEIGHT, _WIDTH / 2 - LEN(msg$) / 2: PRINT msg$; ' Look, we can print to the last row without changing VIEW PRINT.
LOCATE top%, 1
COLOR 7, 5
DO
    _LIMIT 30
    b$ = INKEY$
    IF LEN(b$) THEN
        SELECT CASE b$
            CASE "1"
                PRINT "INFO!"
            CASE "2"
                PRINT "Ha Ha Ha! ";
            CASE CHR$(27)
                EXIT DO
        END SELECT
    END IF
LOOP
SYSTEM

What's cool about VIEW PRINT is it leaves the last row unrestricted. That means we can print to the last row anytime we want, without changing the VIEW PRINT parameters.

What else do we need to know here, Pete?

Well, glad you asked!

1) CLEAR does not affect VIEW PRINT.

2) RUN removes VIEW PRINT.

3) CLS clears the whole screen.

4) CLS 2 only clears the VIEW PRINT area.

5) To get rid of the view print restriction, just code: VIEW PRINT

6) Remember when printing to the bottom of the screen to end your print statement with a semi-colon, so it doesn't scroll.

7) If you switch screens and switch back, you will have to redo your VIEW PRINT statement.

8) The top parameter must always be smaller than the bottom parameter. (If you're too dumb to figure that one out, switch to FreeBASIC).


Pete

Print this item

  Biaxial Symmetry Line Graphing ( Zen Time !)
Posted by: CharlieJV - 12-18-2022, 09:47 PM - Forum: QBJS, BAM, and Other BASICs - Replies (3)

Click here to access the program (and source code below it) in the BASIC Anywhere Machine - Sample Programs Wiki.

Print this item