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,829
» Forum posts: 26,519

Full Statistics

Latest Threads
Rock Jockey 2.0 is ready ...
Forum: Games
Last Post: madscijr
2 minutes ago
» Replies: 19
» Views: 527
ANSIPrint
Forum: a740g
Last Post: bplus
1 hour ago
» Replies: 11
» Views: 158
Aloha from Maui guys.
Forum: General Discussion
Last Post: SMcNeill
1 hour ago
» Replies: 3
» Views: 46
Audio Spectrum Analyser
Forum: Programs
Last Post: Jack002
Today, 01:56 AM
» Replies: 7
» Views: 145
_mem
Forum: Help Me!
Last Post: hsiangch_ong
Today, 01:50 AM
» Replies: 13
» Views: 292
pan around a large image ...
Forum: Programs
Last Post: hsiangch_ong
Today, 01:32 AM
» Replies: 0
» Views: 18
trouble building ansiprin...
Forum: Help Me!
Last Post: hsiangch_ong
Today, 12:57 AM
» Replies: 2
» Views: 55
decfloat -- again
Forum: Programs
Last Post: Jack002
Yesterday, 10:30 PM
» Replies: 42
» Views: 2,924
multiplayer spacewar
Forum: Works in Progress
Last Post: madscijr
Yesterday, 07:07 PM
» Replies: 0
» Views: 27
games or graphics for 3-D...
Forum: General Discussion
Last Post: madscijr
Yesterday, 04:39 AM
» Replies: 28
» Views: 1,089

 
Star Truckload of old CP437 compatible fonts
Posted by: mnrvovrfc - 10-04-2023, 09:17 AM - Forum: General Discussion - Replies (2)

This was probably posted before:

https://int10h.org/oldschool-pc-fonts/

They claim most of the fonts they offer are compatible with CP437. So no Unicode to worry about, no problems with using `CHR$()` with them!

Print this item

  DATE$ function
Posted by: eoredson - 10-04-2023, 05:31 AM - Forum: Help Me! - Replies (55)

I noticed the Date$ function returns the current date, but there is no:

Code: (Select All)
  Print "Date";
  Input D$
  Date$ = D$
why would that be!?

I would like to be able to set the system date.

Erik.

Print this item

Question Fall 2023 Banner Contest - Vote here
Posted by: grymmjack - 10-03-2023, 11:15 PM - Forum: Announcements - Replies (65)

We have 2 entries to choose from for Fall Banner 2023.

One from @dbox (the run and jump)
One from @bplus (falling leaves)

Please cast your vote for which banner you would like!

Both banners were created with QBJS, and the winning banner will be embedded to the top of every page of the forum.

Good luck!

We will accept votes until this Friday October 6th, 2023.

@bplus Falling Leaves


@dbox Run and Jump

Print this item

  Balls rain from the top, some bouce then sink away.
Posted by: Dav - 10-03-2023, 01:05 PM - Forum: Programs - Replies (6)

I'm sure making this kind of thing is a piece of cake to a lot of you, but it was a learning experience for me.  Had a little help on it.

Balls rain from the top, some bounce with gravity, then sink away.

- Dav

Code: (Select All)
'============
'BALLRAIN.BAS
'============
'Balls rain from the top, some drop, some bounce then sink away.
'For QB64 by Dav, SEP/2023

SCREEN _NEWIMAGE(1000, 600, 32)

balls = 200 'number of balls on screen, 200 is my laptop's comfort zone

DIM ballx(balls), bally(balls), ballxvel(balls), ballyvel(balls), ballsize(balls)
DIM ballred(balls), ballgrn(balls), ballblu(balls)

'make random ball values
FOR b = 1 TO balls
    ballx(b) = RND * (_WIDTH) 'x position
    bally(b) = RND * -(_HEIGHT) 'y position
    ballxvel(b) = INT(RND * 7) 'x speed
    ballyvel(b) = INT(RND * 3) 'y speed
    ballsize(b) = RND * 15 + 10 'ball size
    ballred(b) = RND * 255 'red color
    ballgrn(b) = RND * 255 'green color
    ballblu(b) = RND * 255 'blue color
NEXT

DO
    CLS

    FOR b = 1 TO balls

        IF bally(b) < _HEIGHT - ballsize(b) THEN

            ballx(b) = ballx(b) + ballxvel(b)
            bally(b) = bally(b) + ballyvel(b)

            IF ballx(b) < ballsize(b) OR ballx(b) > _WIDTH - ballsize(b) THEN
                ballxvel(b) = -ballxvel(b)
            END IF

            IF bally(b) < ballsize(b) OR bally(b) > _HEIGHT - (ballsize(b) * 2) THEN
                ballyvel(b) = -ballyvel(b)
            END IF

            ballyvel(b) = ballyvel(b) + 3 'gravity value
            'ballxvel(b) = ballxvel(b) + (Rnd * 1.2 - Rnd * 1.2) 'x shake

            'draw gradient ball
            FOR y2 = bally(b) - ballsize(b) TO bally(b) + ballsize(b)
                FOR x2 = ballx(b) - ballsize(b) TO ballx(b) + ballsize(b)
                    clr = (ballsize(b) - (SQR((x2 - ballx(b)) * (x2 - ballx(b)) + (y2 - bally(b)) * (y2 - bally(b))))) / ballsize(b)
                    IF clr > 0 THEN PSET (x2, y2), _RGB(clr * ballred(b), clr * ballgrn(b), clr * ballblu(b))
                NEXT
            NEXT

        END IF
    NEXT

    'see if balls done
    onscreen = 0
    FOR b = 1 TO balls
        IF bally(b) < _HEIGHT - ballsize(b) THEN onscreen = 1
    NEXT
    IF onscreen = 0 THEN EXIT DO

    _DISPLAY
    _LIMIT 24

LOOP

Print this item

  logarithm to the base of 2 (binary logarithm), base 10 and base n
Posted by: BSpinoza - 10-02-2023, 12:18 PM - Forum: General Discussion - Replies (3)

As I see, QB64 only knows the logarithm function LOG() to the base e.
The following small program calculates the binary logarithm ( logarithm to the base of 2) and the logarithms to the base 10 and n

Code: (Select All)

DIM AS _FLOAT a, n
a = 22
PRINT log2##(a)
PRINT logn##(22, 2)
PRINT logn##(22, 10)
PRINT log10##(22)

'Function log2: logarithm to the base of 2 (binary logarithm)
FUNCTION log2## (a)
    log2## = (LOG(a) / LOG(2))
END FUNCTION

'Function log10: logarithm of a to the base of n
FUNCTION log10## (a)
    log10## = (log2##(a) / log2##(10))
END FUNCTION

'Function logn: logarithm of a to the base of n
FUNCTION logn## (a, n)
    logn## = (log2##(a) / log2(n))
END FUNCTION

LOG10 is often called LG and
LOG is often LN (for natural logarithm).

Could these functions be implemented as standard QB64PE functions: _LOG2(), _LOG10(), LOGn(,)?

Print this item

  Update on Cellular Automata
Posted by: justsomeguy - 10-01-2023, 10:47 PM - Forum: Works in Progress - No Replies

Hello all

I have an update to the cellular automata demo I did a long time ago. I've done some optimizations and I have more to go, but its in a 'playable' state.

I'm planning on adding it as a game mechanic to my rouge-like 'Panacea'. There are several materials for you to choose from and they have different interactions with other materials (especially acid).  Eventually there will many materials your character will have to collect and mix to make medicine for the village.

As of now it is a stand alone program so I'll upload it here so you can mess with it. 

The controls are simple. Use the mouse to select the material and draw it on the canvas.
 'c' clears the canvas, 'l' loads a canvas from 'cellauto.ca', 's' saves the canvas to 'cellauto.ca', and 'space' pauses the simulation.

[Image: screen1.jpg]

[Image: screen2.jpg]

[Image: screen3.jpg]



Attached Files
.zip   cellular automata.zip (Size: 18.08 KB / Downloads: 122)
Print this item

  Getting a random number wihout RND.
Posted by: Dav - 09-30-2023, 11:01 PM - Forum: Programs - Replies (23)

A while back I found some TI-84 code for a random number generator.  Played with it for a while, adapting it to QB64.  Messed with the calcs.  Gave it more randomness (I think) by feeding it the starting x/y position of the QB84 windows that seems to be placed randomly, and threw in TIMER for good luck.  I don't really understand it, but here it is for anyone interested in such a function.

- Dav

Code: (Select All)
'========
'RAND.BAS
'========
'Get a random number, without using RND
'Adapted for QB64 from TI-84 source found online.
'Thrown together By Dav, SEP/2023

'Since the QB64 window x/y position always starts at a
'random position, I'm using that as the seed starter.

_Delay .25

DIM SHARED seed: seed = _SCREENX * _SCREENY * TIMER

SCREEN _NEWIMAGE(800, 600, 32)

'Blocks of random size of random colors at random positions.

DO
    x = Rand(_WIDTH)
    y = Rand(_HEIGHT)
    s = Rand(100)
    r = Rand(255): g = Rand(255): b = Rand(255)
    LINE (x, y)-STEP(s, s), _RGB(r, g, b), BF
    _LIMIT 1000
LOOP


FUNCTION Rand (num)
    DIM z AS _INTEGER64, k AS _INTEGER64
    seed2 = seed * TIMER
    k = seed / 53668
    seed = 40014 * (seed - k * 53668) - k * 12211
    IF seed < 0 THEN seed = seed + 2147483563
    k = seed2 / 52774
    seed2 = 40692 * (seed2 - k * 52774) - k * 3791
    IF seed2 < 0 THEN seed2 = seed2 + 2147483563
    z = seed - seed2
    IF z < 1 THEN z = z + 2147483563
    Rand = z * 4.656613E-10 * 190000000 MOD num
END FUNCTION

Print this item

  A couple questions about the dialogs....
Posted by: Dav - 09-30-2023, 01:17 AM - Forum: Help Me! - Replies (20)

I'm making a utility program that doesn't use a main SCREEN at all, but instead relies on dialogs for interaction.  A couple questions, about the message dialog & input box.

1) Is the message dialogs display behavior the same on all OS's?  Will a CHR$(10) start a new line for everyone?

2) Is there a way to center the input box on the screen?

Here's an example of what I'm doing with those.  Giving away what I'm working on again - since _LOADIMAGE/_SNDOPEN has a "memory" option now, I had to reawaken the old QBV project.

- Dav

Code: (Select All)


_ScreenHide

lf$ = Chr$(10)
a$ = "QBV Video Builder v1.0." + lf$ + lf$
a$ = a$ + "This app builds an .QBV Audio/Video file from a" + lf$
a$ = a$ + "numeric sequence of images (ex: 000001.JPG, etc)" + lf$
a$ = a$ + "and an optional .OGG file.  You will be allowed" + lf$
a$ = a$ + "to specify a frame rate." + lf$ + lf$
a$ = a$ + "Please select a starting image file..."

_MessageBox "QB64 Video Builder", a$, "info"

result$ = _InputBox$("QBV Video Builder", "Frame rate p/s:", "15")

End

Print this item

  Volume display utility
Posted by: eoredson - 09-30-2023, 01:06 AM - Forum: Programs - No Replies

I have been using FindFirst for awhile and found FindFirstVolume in MSDN which is here:

Code: (Select All)
Const MAX_PATH = 260
Const INVALID_HANDLE_VALUE = -1
Declare Dynamic Library "kernel32"
    Function FindFirstVolumeW~%& (ByVal lpFileName~%&, MAX_PATH)
    Function FindNextVolumeW& (ByVal hFindFile~%&, Byval hFindPoint~%&, MAX_PATH)
    Function FindVolumeClose& (ByVal hFindFile~%&)
End Declare

Dim ASCIIZ As String * 260
Dim Wfile.Handle As _Unsigned _Offset

' find first long filename
Wfile.Handle = FindFirstVolumeW(_Offset(ASCIIZ), MAX_PATH)

' check findirst error
If Wfile.Handle <> INVALID_HANDLE_VALUE Then
    ' filename/directory loop
    Do
        X$ = ASCIIZ
        Do
            X = InStr(X$, Chr$(0))
            If X Then
                X$ = Left$(X$, X - 1) + Mid$(X$, X + 1)
            Else
                Exit Do
            End If
        Loop
        Print X$
    Loop While FindNextVolumeW(Wfile.Handle, _Offset(ASCIIZ), MAX_PATH)
    X = FindVolumeClose(Wfile.Handle)
End If
End
but I don't understand the output.

Erik.



Attached Files
.bas   findvol.bas (Size: 913 bytes / Downloads: 30)
Print this item

  _SETALPHA Question
Posted by: TerryRitchie - 09-29-2023, 04:08 AM - Forum: Help Me! - Replies (16)

I seem to be having issues with _SETALPHA.

When I initially set a color to a transparency level with _SETALPHA I can't change it to another transparency level later on.

I'm certain I've done this in the past.

I've found a work-around using a temporary image but I'm sure this is not needed ... or is it? See my code below and please explain to me why the first block of code is not working. A bug? Brain-fart on my part?

Code: (Select All)
'|
'| Fade in a red box test
'|

DIM RedBox AS LONG
DIM TempBox AS LONG
DIM c AS INTEGER

SCREEN _NEWIMAGE(640, 480, 32)

RedBox = _NEWIMAGE(320, 240, 32)
_DEST RedBox
CLS , _RGB32(255, 0, 0)
_DEST 0

'c = 0 '                                       |
'DO '                                          | This block of code does not work?
'    CLS '                                     |
'    _LIMIT 30 '                               | The Wiki shows however this should be acceptable
'    _SETALPHA c, _RGB32(255, 0, 0), RedBox '  |
'    _PUTIMAGE (159, 119), RedBox '            |
'    _DISPLAY '                                |
'    c = c + 1 '                               |
'LOOP UNTIL c = 256 '                          |


c = 0 '                                       |
DO '                                          | This block of code does work.
    CLS '                                     |
    _LIMIT 30 '                               | Why do I need to copy the original RedBox to
    TempBox = _COPYIMAGE(RedBox) '            | to another image for every iteration of the loop?
    _SETALPHA c, _RGB32(255, 0, 0), TempBox ' |
    _PUTIMAGE (159, 119), TempBox '           |
    _DISPLAY '                                |
    _FREEIMAGE TempBox '                      |
    c = c + 1 '                               |
LOOP UNTIL c = 256 '                          |

Print this item