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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 483
» Latest member: aplus
» Forum threads: 2,797
» Forum posts: 26,389

Full Statistics

Latest Threads
SaucerZap
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
6 minutes ago
» Replies: 1
» Views: 10
A question on using Infor...
Forum: Help Me!
Last Post: mdijkens
1 hour ago
» Replies: 6
» Views: 85
Mean user base makes Stev...
Forum: General Discussion
Last Post: PhilOfPerth
9 hours ago
» Replies: 17
» Views: 327
GNU C++ Compiler error
Forum: Help Me!
Last Post: Pete
11 hours ago
» Replies: 44
» Views: 552
_IIF limits two question...
Forum: General Discussion
Last Post: madscijr
Today, 03:53 AM
» Replies: 9
» Views: 170
What do you guys like to ...
Forum: General Discussion
Last Post: Pete
Yesterday, 05:16 PM
» Replies: 11
» Views: 188
Fast QB64 base64 encoder ...
Forum: a740g
Last Post: a740g
12-21-2024, 04:43 AM
» Replies: 3
» Views: 472
DeflatePro
Forum: a740g
Last Post: a740g
12-21-2024, 02:11 AM
» Replies: 2
» Views: 80
New QBJS Samples Site
Forum: QBJS, BAM, and Other BASICs
Last Post: dbox
12-20-2024, 06:16 PM
» Replies: 25
» Views: 909
Raspberry OS
Forum: Help Me!
Last Post: Jack
12-20-2024, 05:42 PM
» Replies: 7
» Views: 174

 
  3D rendering of Game of Life by ubi44
Posted by: bplus - 02-13-2024, 07:35 PM - Forum: Programs - Replies (4)

This code is far too good to NOT share here, but to be clear I did not write this, it comes from avatar name ubi44.

Code: (Select All)
Screen _NewImage(640, 488, 32)
_AllowFullScreen _SquarePixels
_FullScreen _SquarePixels , _Smooth
Dim As Integer MAX, MAX2

start:
MAX = 25 + Int(Rnd * 25): MAX2 = MAX / 2
ReDim U(MAX, MAX, MAX) As _Byte
ReDim U2(MAX, MAX, MAX) As _Byte

MoveZ = -MAX2 / 2
rand = (Rnd - Rnd * .25) * .2
Randomize Timer
t = 0
For x = 1 To MAX - 1
    For y = 1 To MAX - 1
        For z = 1 To MAX - 1
            If Rnd < .5 + rand Then U(x, y, z) = 1: t = t + 1 Else U(x, y, z) = -1
Next z, y, x
Dim Shade(255) As Long
For c = 0 To 255
    i& = _NewImage(1, 1, 32)
    _Dest i&
    Line (0, 0)-(_Width(i&), _Height(i&)), _RGB(c, c, c), BF
    Shade(c) = _CopyImage(i&, 33)
    _FreeImage i&
Next c
Do
    TEX = .4 - (MoveZ + 10.5) * .001
    If _FullScreen Then _MouseHide Else _MouseShow
    If _KeyDown(18432) Then MoveZ = MoveZ - 1
    If _KeyDown(20480) Then MoveZ = MoveZ + 1
    Cls
    frames% = frames% + 1
    If oldtime$ <> Time$ Then
        fps = frames%
        frames% = 1
        oldtime$ = Time$
    End If
    _Limit 10
    Color _RGB(0, 0, 0), _RGB(200, 200, 200)
    Print t; " first gen cell alive "; b; "live cell at now!"
    Color _RGB(0, 0, 0), _RGB(227, 227, 227)
    Print "up down arrow key to move forward or backward"
    Color _RGB(0, 0, 0), _RGB(255, 255, 255)
    Print "space to restart || current grid:"; MAX; "^3"
    Color _RGB(255, 255, 255), _RGB(0, 0, 0)
    a = a + (fps) / 160
    If a > 360 Then a = 0
    cos1 = Cos(a)
    sin1 = Sin(a)

    For x = 1 To MAX - 1
        For y = 1 To MAX - 1
            For z = 1 To MAX - 1
                If U(x, y, z) = 1 Then
                    'set up cube
                    ix = (x - MAX2) - TEX: iy = (y - MAX2) - TEX: iz = (z - MAX2) - TEX
                    jx = (x - MAX2) + TEX: jy = (y - MAX2) - TEX: jz = (z - MAX2) - TEX
                    kx = (x - MAX2) + TEX: ky = (y - MAX2) + TEX: kz = (z - MAX2) - TEX
                    lx = (x - MAX2) - TEX: ly = (y - MAX2) + TEX: lz = (z - MAX2) - TEX

                    mx = (x - MAX2) - TEX: my = (y - MAX2) - TEX: mz = (z - MAX2) + TEX
                    nx = (x - MAX2) + TEX: ny = (y - MAX2) - TEX: nz = (z - MAX2) + TEX
                    ox = (x - MAX2) + TEX: oy = (y - MAX2) + TEX: oz = (z - MAX2) + TEX
                    px = (x - MAX2) - TEX: py = (y - MAX2) + TEX: pz = (z - MAX2) + TEX
                    'rotation x/z
                    ax = (ix) * cos1 - (iz) * sin1 '
                    az = (ix) * sin1 + (iz) * cos1 '
                    ay = iy
                    bx = (jx) * cos1 - (jz) * sin1
                    bz = (jx) * sin1 + (jz) * cos1 '
                    by = jy
                    cx = (kx) * cos1 - (kz) * sin1
                    cz = (kx) * sin1 + (kz) * cos1 '
                    cy = ky
                    dx = (lx) * cos1 - (lz) * sin1
                    dz = (lx) * sin1 + (lz) * cos1 '
                    dy = ly

                    ex = (mx) * cos1 - (mz) * sin1
                    ez = (mx) * sin1 + (mz) * cos1 '
                    ey = my
                    fx = (nx) * cos1 - (nz) * sin1
                    fz = (nx) * sin1 + (nz) * cos1 '
                    fy = ny
                    gx = (ox) * cos1 - (oz) * sin1 '
                    gz = (ox) * sin1 + (oz) * cos1 '
                    gy = oy
                    hx = (px) * cos1 - (pz) * sin1
                    hz = (px) * sin1 + (pz) * cos1 '
                    hy = py

                    'front
                    push = -(MAX + MAX2 + MoveZ)
                    u = checkV(ax, ay, az - push, bx, by, bz - push, dx, dy, dz - push)
                    If u > 0 Then
                        col% = maxi((205 - (((dz + MAX2)) / MAX) * 205) * u + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(ax, ay, -az + push)-(bx, by, -bz + push)-(dx, dy, -dz + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(bx, by, -bz + push)-(cx, cy, -cz + push)-(dx, dy, -dz + push)
                    End If
                    'back
                    u = checkV(hx, hy, hz - push, fx, fy, fz - push, ex, ey, ez - push)
                    If u > 0 Then
                        col% = maxi((205 - (((fz + MAX2)) / MAX) * 205) * u + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(ex, ey, -ez + push)-(fx, fy, -fz + push)-(hx, hy, -hz + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(fx, fy, -fz + push)-(gx, gy, -gz + push)-(hx, hy, -hz + push)
                    End If
                    'left
                    u = checkV(dx, dy, dz - push, ex, ey, ez - push, ax, ay, az - push)
                    If u > 0 Then
                        col% = maxi((205 - (((ez + MAX2)) / MAX) * 205) * (u) + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(ax, ay, -az + push)-(ex, ey, -ez + push)-(dx, dy, -dz + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(ex, ey, -ez + push)-(hx, hy, -hz + push)-(dx, dy, -dz + push)
                    End If
                    ''right
                    u = checkV(fx, fy, fz - push, cx, cy, cz - push, bx, by, bz - push)
                    If u > 0 Then
                        col% = maxi((205 - (((fz + MAX2)) / MAX) * 205) * (u) + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(bx, by, -bz + push)-(cx, cy, -cz + push)-(fx, fy, -fz + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(cx, cy, -cz + push)-(gx, gy, -gz + push)-(fx, fy, -fz + push)
                    End If
                    'up
                    u = checkV(bx, by, bz - push, ax, ay, az - push, ex, ey, ez - push)
                    If u > 0 Then
                        col% = maxi((205 - (((ez + MAX2)) / MAX) * 205) * (u) + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(ax, ay, -az + push)-(bx, by, -bz + push)-(ex, ey, -ez + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(bx, by, -bz + push)-(ex, ey, -ez + push)-(fx, fy, -fz + push)
                    End If
                    'down
                    u = checkV(hx, hy, hz - push, dx, dy, dz - push, cx, cy, cz - push)
                    If u > 0 Then
                        col% = maxi((205 - (((hz + MAX2)) / MAX) * 205) * (u) + 25)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(cx, cy, -cz + push)-(dx, dy, -dz + push)-(hx, hy, -hz + push)
                        _MapTriangle (0, 0)-(_Width(Shade(col%)), 0)-(0, _Height(Shade(col%))), Shade(col%) To(cx, cy, -cz + push)-(hx, hy, -hz + push)-(gx, gy, -gz + push)
                    End If
                End If
    Next z, y, x
    For x = 1 To MAX - 1
        For y = 1 To MAX - 1
            For z = 1 To MAX - 1
                mm = 0
                If U(x, y, z) = 1 Then
                    For xx = x - 1 To x + 1
                        For yy = y - 1 To y + 1
                            For zz = z - 1 To z + 1
                                If x = xx And y = yy And z = zz Then _Continue
                                If U(xx, yy, zz) = 1 Then mm = mm + 1
                    Next zz, yy, xx
                    If mm < 9 Or mm > 18 Then U2(x, y, z) = -1 Else U2(x, y, z) = 1
                Else
                    For xx = x - 1 To x + 1
                        For yy = y - 1 To y + 1
                            For zz = z - 1 To z + 1
                                If x = xx And y = yy And z = zz Then _Continue
                                If U(xx, yy, zz) = 1 Then mm = mm + 1
                    Next zz, yy, xx
                    If (mm > 12 And mm < 18) Then U2(x, y, z) = 1 Else U2(x, y, z) = -1
                End If
    Next z, y, x
    _Display
    b = 0
    For x = 1 To MAX - 1
        For y = 1 To MAX - 1
            For z = 1 To MAX - 1
                U(x, y, z) = U2(x, y, z)
                If U(x, y, z) = 1 Then b = b + 1
    Next z, y, x
    If _KeyDown(32) Then GoTo start
Loop Until _KeyDown(27)
Function checkV (x1, y1, z1, x2, y2, z2, x3, y3, z3)
    Xo = (y2 - y1) * (z3 - z1) - (z2 - z1) * (y3 - y1)
    Yo = (z2 - z1) * (x3 - x1) - (x2 - x1) * (z3 - z1)
    Zo = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
    D = Sqr(Xo * Xo + Yo * Yo + Zo * Zo)
    nx = Xo / D: ny = Yo / D: nz = Zo / D
    px = x1: py = y1: pz = z1
    D = Sqr(px * px + py * py + pz * pz)
    dx = px / D: dy = py / D: dz = pz / D
    uv = (nz * dz + ny * dy + nx * dx)
    If uv < 0 Or uv > 1 Then checkV = -1 Else checkV = uv
End Function
Function maxi (x)
    If x > 255 Then maxi = 255: Exit Function
    If x < 0 Then maxi = 0: Exit Function
    maxi = x
End Function

What does _SquarePixels do?

Print this item

  A _MOUSEMOVEMENTX question
Posted by: NakedApe - 02-13-2024, 07:35 PM - Forum: Help Me! - Replies (28)

Howdy. I'm using X axis mouse moves to control the rotation of a new, scrappy, little spaceship. All is great until I reach the end of the range of that command (the actual edges of the desktop not the screen image), then the ship either freezes up at one extreme or can rotate no further at the other end. The command's range is -50 to _DESKTOPWIDTH - 50. There's plenty of range for the game to work; it's just annoying that you have to stay within the parameters...

The question is, is there a way to overcome this and have unlimited X readings or do I need to warn the user to "unwind" the mouse position as they go and maybe provide an onscreen indicator as to where the mouse is within its range?  Gracias, amigos.

Print this item

  Quantum Data Storage
Posted by: Pete - 02-13-2024, 04:02 PM - Forum: Works in Progress - Replies (13)

Hi, it's been awhile...

So what have I been up to? Well, I've been working with Bill, you know, the guy with a theoretical degree in physics, yeah right, that Bill. Anyway, Bill and I finally put together our greatest project ever; a quantum storage source for storing all your data using the greatest environment for quantum computers currently known to man; that's right, a black hole. So forget about all that yesterday's news of putting your data on "The Cloud" because if you act right now, for just a small investment of all your life's savings, you could be living in the future, with Bill and Pete. That's right! Just trust Bill and Pete, with all your cache, and you'll be in "The Hole" in no time!

Pete - A work in progress

Print this item

  Does _MapTriangle work in a user defined Window?
Posted by: bplus - 02-13-2024, 03:30 PM - Forum: Help Me! - Replies (12)

i am using some old 3D rendering code from Stax who insists on Cartesian style coordinate system and build all vector routines around that so to use them I have to use Window call. Works fine for points and lines but I am having big problems with _MapTriangle ie nothing is getting drawn but no errors either.

Print this item

  Reading file
Posted by: emfril - 02-13-2024, 01:55 PM - Forum: Help Me! - Replies (9)

I just downloaded qb64 and it seems marvelous! I had written several programs in QB4.5 and I would like to review and revise some of them. Last time I used QBasic was inside DOSBox, but did not like it very much.

Now, I try to run a program that reads the coastline coordinates of the continents and prints maps, but the qb64 exe file does not find the coordinates file, though it is in the same (GEOGRAFY\) directory:

OPEN "GEOGRAFY\PMAP1.PNT" FOR RANDOM AS #1 ...

What is the correct file address of PMAP1.PNT?

Print this item

  Detect running from IDE
Posted by: mdijkens - 02-11-2024, 09:19 AM - Forum: Help Me! - Replies (1)

I regularly want to know if I'm running from the IDE (during development) or not.
To set the current working directory correct or to stop with End instead of System
etc.

I now use this code which seems to work for some time already:

Code: (Select All)
Dim Shared DEVELOPMENT As _Byte
$If WIN Then
  DEVELOPMENT = (Environ$("sessionname") = "Console"): If Not DEVELOPMENT Then ChDir _StartDir$
$End If
'...
If DEVELOPMENT Then End Else System
But is this a correct/reliable way? Where does sessionname=Console come from and will it stay like this in future versions?
I would love to have a _DEVELOPMENT variable out-of-the-box as part of QB64pe

Sidenote: Why is _CWD not correct initialized when not running from the IDE; It then points to the directory containing your exe instead

Print this item

  MyBB is great, but has an outdated design.
Posted by: The Joyful Programmer - 02-11-2024, 03:49 AM - Forum: General Discussion - Replies (2)

I love the MyBB forum software, which this site is powered by, but I find the out-of-the-box layout, look, and design very outdated. I also have an issue with it not being mobile-friendly.

As some of you know, I started using MyBB back in 2014 when I started my own QB64 community. I fell in love with how easy it is for me to modify and the powerful add-ons you get it for it.

However, back in those days, we were using v1.6.x and things were different. Today, we are in the v1.8.x (1.8.37 for my BASIC forum; my web hosting provider automatically updates the version for me so I don't have to deal with it.). However, the out-of-the-box download still is not mobile-friendly, which is saddening, and the look is still obsolete in my opinion.

Thankfully, there are a few mobile-friendly themes you can get for MyBB, and the one I chose had a fairly decent layout and design, though I hated the colors red and blue colors it uses. As such, I had to modify the theme to my liking. I wanted a nice color palette that was psychologically pleasing to most people and cultures, and after a bit of reading (research) I saw that green was still a good common color that promoted all kinds of (supposed) positive emotions. So, I opened up Adobe Photoshop and worked on a green palette.

I thought I had the colors I wanted until I read an article that had a single green button. I liked the green color and created a whole new palette based on it.
One of the great things I love about the new theme is that it removed most of the fluff from the index page and replaced it with a category list on the left and a recent thread list on the right, as you can see in the following screenshot.


   

I find this layout a lot more pleasing than the out-of-the-box one that comes with MyBB and most other forum software.

The out-of-the-box look and layout for a thread's posts is absolutely an eye-sore in my opinion. The theme I am using separates each post into a user-friendly look and feel, as you can see in the following screenshot:


   

Posting a message in the out-of-the-box MyBB is an eye-sore as well, in my opinion, and I don't believe there is ever a true need for the post icon or even emoticons. So, I removed them from my forum completely. I also removed the thread subject line on the reply page because it should never be changed. The "post options" and "thread subscriptions" are placed in a separate area that the user has to open (like a "show me" button). Here's a screenshot of a post page on the BASIC forum:


   

The user's list has also been updated to a more modern look as well, as you can see in the following screenshot:


   

As you may have seen in a previous screenshot, for admins, there is a "purge spammer" link that allows the admin to delete the user, all their posts, all their DM's, and everything else with a single click. Here's a small screenshot to show that section:

   

While my forum is open to the public, I still have some minor tweaks to make. The more the forum is used, the more things I seem to find to "fix".But, overall, I am very happy with how well the forum came out.

Print this item

  Color-Changing Xmas Tree
Posted by: CharlieJV - 02-10-2024, 07:12 PM - Forum: QBJS, BAM, and Other BASICs - No Replies

Yeah, a little bit past the season, but I saw a recent and neat one-liner, and the desire to mod the thing kicked into high gear:

https://basicanywheremachine-news.blogsp...-tree.html

Print this item

  Four Up
Posted by: a740g - 02-10-2024, 09:50 AM - Forum: a740g - No Replies

This is an implementation of the classic Connect 4 game as a library. The core game engine is implemented as a library that can be easily plugged into any kind of front-end. The engine also includes a Negamax solver that can be used either to implement an AI player or give hints to the players.

There are two front-end included. One is a fancy (?) InForm-PE GUI based one (FourUp.bas) and another console version commented inside FourUpEngine.bas.

[Image: screenshot.png]

The game engine is in the FourUpEngine.bas and FourUpEngine.bi files. The engine code does not include any graphics rendering, input management, sound etc.

[Image: Screenshot-2024-02-10-145804.png]

Try the game with the search depth of 6 or above. Anything more than 12 may be painfully slow. I'll make more optimizations later.

The zip file below has the frontend, library and all dependencies.

Find the latest version on GitHub.

Cheers!



Attached Files
.zip   FourUp.zip (Size: 239.44 KB / Downloads: 27)
Print this item

  Most Efficient Sprites Question
Posted by: NakedApe - 02-09-2024, 06:24 PM - Forum: Help Me! - Replies (14)

As I continue to have fun writing 2D games with lots of action, Asteroid-esque space stuff, I'm wondering:

What's the most efficient / fastest approach to moving arrays of objects around the screen in QB64PE?

A. Programatically generated images on the fly for fairly simple things?
B. Manipulating strings with DRAW commands, VARPTR$...?
C. Using small images, say 40x40, with _PUTIMAGE commands, _ROTATEIMAGE ()...?


Thanks, and have a great weekend, everybody.

Print this item