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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 482
» Latest member: zaalexijuniorz5256
» Forum threads: 2,793
» Forum posts: 26,347

Full Statistics

Latest Threads
Tenary operator in QB64 w...
Forum: Utilities
Last Post: RhoSigma
11 minutes ago
» Replies: 1
» Views: 15
Video Renamer
Forum: Works in Progress
Last Post: SpriggsySpriggs
19 minutes ago
» Replies: 1
» Views: 24
QB64PE v4.0 is now live!!
Forum: Announcements
Last Post: Kernelpanic
1 hour ago
» Replies: 33
» Views: 987
Need help capturng unicod...
Forum: General Discussion
Last Post: doppler
1 hour ago
» Replies: 22
» Views: 288
games or graphics for 3-D...
Forum: General Discussion
Last Post: madscijr
5 hours ago
» Replies: 26
» Views: 778
Text-centring subs
Forum: Utilities
Last Post: SierraKen
Today, 05:46 AM
» Replies: 2
» Views: 49
QB64-PE v4's new 4-voice ...
Forum: Learning Resources and Archives
Last Post: a740g
Today, 02:51 AM
» Replies: 6
» Views: 147
Sound Ball
Forum: Programs
Last Post: SierraKen
Yesterday, 11:34 PM
» Replies: 0
» Views: 28
InForm-PE
Forum: a740g
Last Post: a740g
Yesterday, 10:58 PM
» Replies: 78
» Views: 6,049
Spriggsy's API Collection
Forum: Utilities
Last Post: SpriggsySpriggs
Yesterday, 07:13 PM
» Replies: 8
» Views: 206

 
  Help needed regarding Lesson 17
Posted by: RhoSigma - 10-08-2024, 10:39 AM - Forum: Terry Ritchie's Tutorial - Replies (26)

Hi Terry,

there's a lost soul at Discord. He/she obviously got lots of informations from your Tutorial Lesson 17 (Movement and Rotation).

From a quick visit to that lesson I see for your teachings you use (for whatever reason) a modified version of the standard math coordinate system, which assumes 0° as north direction and then counts the angles clockwise.

Now, this guy/girl is trying to calculate the angle from one point to another one using the _ATAN2 function and wonders about the results, mayby you could have a look: https://discord.com/channels/97538191235...0559666196

Steve and me tried to help, but as his/her thinking is obviously compromised by your coordinate modell, we probably made it even worse than better.

Print this item

  Potencies high potencies
Posted by: Kernelpanic - 10-07-2024, 09:21 PM - Forum: Help Me! - Replies (4)

When I wanted to try something today, I came across a problem, at least for me.
The results do not match what the MS calculator and online calculators give. I am also confused by the fact that ((5 ^ 4)^4) is not the same as 5^(4*4) for the program, but 5^16 gives a result like ((5 ^ 4)^4). Have I there disregarded some mathematical laws?  Huh

Code: (Select All)

'Matheuebung Potenzen hoch Potenzen - 7. Okt. 2024

Option _Explicit

Dim As Integer a, b, c
Dim As _Unsigned Long sum, sum2, sum3

Locate 2, 3
Print "Berechnet ((a ^ b) ^ c)"
Locate 3, 3
Print "======================="
'Beispiel: ((5^4)^4) = 5^16
'MS-Rechner: 152.587.890.625 -- Hier: 2.264.035.265

Locate 5, 3
Input "a: ", a
Locate 6, 3
Input "b: ", b
Locate 7, 3
Input "c: ", c

sum = ((a ^ b) ^ c)
Locate 9, 3
Print Using "Summe 1: ###,##########"; sum

sum2 = a ^ (a * b)
Locate 11, 3
Print Using "Summe 2: ###,##########"; sum2

sum3 = a ^ 16
Locate 13, 3
Print Using "Summe 3: ###,##########"; sum3

End

[Image: Matheuebung-Potenzen2.jpg]

Math-Solver

Print this item

  An Array v's A Dictionary
Posted by: Dimster - 10-07-2024, 07:18 PM - Forum: General Discussion - Replies (10)

I've just recently come across a Dictionary as an alternative to an Array. Doesn't appear that QB64PE supports Dictionaries. Does anyone who codes in languages which do use Dictionaries find them the same as using an Array or better than an Array or offering a completely different manipulation of data than an Array?

Print this item

  QBJS Hair mod
Posted by: vince - 10-07-2024, 08:27 AM - Forum: QBJS, BAM, and Other BASICs - Replies (14)

Print this item

  [Solved] How come CLS clears more than the _DEST image here?
Posted by: Dav - 10-07-2024, 12:01 AM - Forum: Help Me! - Replies (2)

I was playing with an image drawing program tonight, drawing over a moving plasma background.  To do this I'm combining two image screens (back& and drawing&) onto the main screen (_DEST 0).  That works fine, but when I try to CLS the drawing& image screen, it also clears the plasma back& image too.  How come?  I must be misunderstanding something about _DEST and CLS use.

Here's the program.  Use the mouse to draw on the screen.  You can press SPACE to clear the screen.  Afterwards you will see the plasma background is cleared also, although I _DEST to the drawing& image.

Line #93 is where the CLS thing happens.

- Dav

Code: (Select All)
'==============
'plasmadraw.bas
'==============
'Draw on a moving plasma background
'Coded by Dav, OCT/2024

Screen _NewImage(800, 800, 32)

'make screens
back& = _NewImage(800, 800, 32) 'plasma background
drawing& = _NewImage(800, 800, 32) 'drawing screen

points = 8 'number of drawing points on drawing screen
Dim pointa(points), pointx(points), pointy(points), lastmx(points), lastmy(points)
pointsize = 3 'size of points

cx = _Width \ 2: cy = _Height \ 2

Do

    t = Timer * 1

    '=== update plasma background image
    _Dest back&
    For y = 0 To _Height Step 3
        For x = 0 To _Width Step 3
            r = Int(128 + 127 * Sin(x / 15 + t) + 127 * Cos(y / 15 + t))
            g = Int(128 + 127 * Sin(x / 25 + t * 1.5) + 127 * Cos(y / 25 + t * 1.5))
            b = Int(128 + 127 * Sin(x / 35 + t * 2) + 127 * Cos(y / 35 + t * 2))
            Line (x, y)-Step(2, 2), _RGBA(r / 3, g / 3, b / 3, Rnd * 30), BF
        Next
    Next

    '=== do/update drawing screen
    _Dest drawing&
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY

    If _MouseButton(1) Then
        If stilldown = 1 Then
            dx = mx - cx: dy = my - cy
            a = _Atan2(dy, dx)
            dis = Sqr(dx * dx + dy * dy)
            For i = 1 To points
                pointa(i) = (360 / points) * i * (3.14159 / 180)
                pointx(i) = cx + dis * Cos(pointa(i) + a)
                pointy(i) = cy + dis * Sin(pointa(i) + a)
                stepx = lastmx(i) - pointx(i)
                stepy = lastmy(i) - pointy(i)
                length = Int((stepx ^ 2 + stepy ^ 2) ^ .5)
                dx2 = stepx / length
                dy2 = stepy / length
                r = Int(128 + 127 * Sin(pointx(i) / 25 + t) + 127 * Cos(pointy(i) / 25 + t))
                g = Int(128 + 127 * Sin(pointx(i) / 25 + t * 1.5) + 127 * Cos(pointy(i) / 25 + t * 1.5))
                b = Int(128 + 127 * Sin(pointx(i) / 25 + t * 2) + 127 * Cos(pointy(i) / 25 + t * 2))
                For i2 = 0 To length
                    newx = pointx(i) + dx2 * i2
                    newy = pointy(i) + dy2 * i2
                    fc newx, newy, pointsize, _RGB(r, g, b), 0
                Next
                lastmx(i) = pointx(i)
                lastmy(i) = pointy(i)
            Next
        Else
            dx = mx - cx
            dy = my - cy
            a = _Atan2(dy, dx)
            dis = Sqr(dx * dx + dy * dy)
            For i = 1 To points
                pointa(i) = (360 / points) * i * (3.14159 / 180)
                pointx(i) = cx + dis * Cos(pointa(i) + a)
                pointy(i) = cy + dis * Sin(pointa(i) + a)
                lastmx(i) = pointx(i)
                lastmy(i) = pointy(i)
                r = Int(128 + 127 * Sin(pointx(i) / 25 + t) + 127 * Cos(pointy(i) / 25 + t))
                g = Int(128 + 127 * Sin(pointx(i) / 25 + t * 1.5) + 127 * Cos(pointy(i) / 25 + t * 1.5))
                b = Int(128 + 127 * Sin(pointx(i) / 25 + t * 2) + 127 * Cos(pointy(i) / 25 + t * 2))
                fc pointx(i), pointy(i), pointsize, _RGB(r, g, b), 0
            Next
            stilldown = 1
        End If
    Else
        stilldown = 0
    End If

    '=== combine both images to the main screen image
    _Dest 0
    _PutImage (0, 0), back&
    _PutImage (0, 0), drawing&

    If InKey$ = " " Then
        _Dest drawing& 'point to drawing& image
        Cls, 0: _Display '<<< this clears back& image too.  How come?
        _Dest 0
    End If

    _Display
    _Limit 30

Loop Until _KeyDown(27)


Sub fc (cx As Integer, cy As Integer, radius As Integer, clr~&, grad)
    If radius < 1 Then Exit Sub ' safety bail
    If grad = 1 Then
        red = _Red32(clr~&)
        grn = _Green32(clr~&)
        blu = _Blue32(clr~&)
        alpha = _Alpha32(clr~&)
    End If
    r2 = radius * radius
    For y = -radius To radius
        x = Abs(Sqr(r2 - y * y))
        ' If doing gradient
        If grad = 1 Then
            For i = -x To x
                dis = Sqr(i * i + y * y) / radius
                red2 = red * (1 - dis) + (red / 2) * dis
                grn2 = grn * (1 - dis) + (grn / 2) * dis
                blu2 = blu * (1 - dis) + (blu / 2) * dis
                clr2~& = _RGBA(red2, grn2, blu2, alpha)
                Line (cx + i, cy + y)-(cx + i, cy + y), clr2~&, BF
            Next
        Else
            Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
        End If
    Next
End Sub

Print this item

  I have fallen in a bug or weird behaviour
Posted by: TempodiBasic - 10-06-2024, 10:52 PM - Forum: General Discussion - Replies (2)

Hi QB64 friends

building my first multiclient network in localHost I've got this weird behaviour (or a bug about applications interface)...

if you try my little example about TCP/IP connections among applications you can observe that after a first quick time all the client windows get the same background color also if they have been build with different background colors...
what do you think about this result?
what suggestion do you want to say to me?

here the link to TCP/IP program  TCP/IP connections

while you think an answer hear this kind music  Tokyo , Maneskin, THE LONELIEST

Print this item

  a little TCP/IP network in LocalHost
Posted by: TempodiBasic - 10-06-2024, 10:41 PM - Forum: Programs - Replies (5)

Hi QB64 friends...
here it follows a my new TCP/IP experience creating a little network with 3 clients and 1 host server.

The same pocedure is for a network behind the home LAN.... you must use Host on a server PC connected to outside via TCP/IP and a pc for each Client program connected via TCP/IP to outside line.... the only difference is the URL used for creating connections!


Here the codes for Host and LClient1, Lclient2 and Lclient3 in the same PC

Host

Code: (Select All)

Rem Project to simulate a server with multiple clients TCP/IP

Rem the first program is the server side of the network

Screen _NewImage(800, 640, 32)
Cls , _RGBA32(250, 100, 200, 255)
_ScreenMove 10, 10
_PrintString (10, 200), "testing if SERVER is already ON"

Dim Server As Long
Server = _OpenClient("TCP/IP:7319:localhost")
If Server Then Msg$ = "Server Host already ON" Else Msg$ = "Server Host OFF, activating Server Host..."
_PrintString (10, 230), Msg$ + Space$(6)

If Server = 0 Then
    Server = _OpenHost("TCP/IP:7319 ")
    If Server = 0 Then Msg$ = "Failed to activate server Host. Host is OFF" Else Msg$ = " Activated Server Host. Host is ON"
    _PrintString (10, 300), Msg$
End If

Rem here Host runs Client apps

Shell _DontWait "LClient1.exe"
Shell _DontWait "LClient2.exe"
Shell _DontWait "LClient3.exe"

Rem here Host searches connections with clients and if activated it reads data

Dim Cli(1 To 3) As Long, n As Integer, Comd As String

Do
    n = n + 1
    If n = 4 Then n = 1
    If Cli(n) = 0 Then Cli(n) = _OpenConnection(Server) ' Is cli(n) connected?

    Comd = "" ' it deletes previous command read by client
    If Cli(n) <> 0 Then
        If Not EOF(Cli(n)) Then Get #Cli(n), , Comd ' has Cli(n) sent data?
    End If

    ' data executor
    Select Case Comd
        Case " ":
            _PrintString (10, 100), "Client" + Str$(n) + " quits" + Space$(6)
            Close
            ' it quits
        Case "c", "C":
            Cls , _RGBA32((Rnd * (255)) + 1, (Rnd * (255)) + 1, (Rnd * (255)) + 1, 255)
            _PrintString (10, 100), "Client" + Str$(n) + " changes color" + Space$(6)
            ' it changes color
        Case "s", "S":
            Play "cdc"
            _PrintString (10, 100), "Client" + Str$(n) + " makes sound" + Space$(6)
            ' it sounds some notes
    End Select
    _PrintString (10, 300), " Press space key to quit" + Space$(16)
Loop Until InKey$ = " " Or Comd = " " ' press space to quit
Close
End

Lclient1
Code: (Select All)

Rem Project to simulate a server with multiple clients TCP/IP

Rem the second program is the first client side of the network

Screen _NewImage(800, 640, 32)
Cls , _RGBA32(128, 200, 200, 255)
_ScreenMove 400, 100
_PrintString (10, 200), "testing if CLIENT is already ON"

Dim Server As Long
Server = _OpenClient("TCP/IP:7319:localhost")
If Server Then Msg$ = "Client is ON" Else Msg$ = "Cannot activate Client..."
_PrintString (10, 230), Msg$

If Server = 0 Then
    Server = _OpenClient("TCP/IP:7319:localhost") ' it tries a second time the connection with Host
    If Server = 0 Then Msg$ = "Failed to activate server Client. Client is OFF" Else Msg$ = " Activated Server Client. Client is ON"
    _PrintString (10, 300), Msg$
    If Server = 0 Then End
End If


Rem here Client waits user input and sends this to Host

Dim Comd As String

Do
    _Delay 1
    Cls , _RGBA32(128, 200, 200, 255)
    _PrintString (10, 100), "Client is ON, press c/C to change color, s/S to sound notes and space key to quit"
    Comd = "" ' it deletes previous command read by client
    Comd = InKey$

    If Comd <> "" Then Put #Server, , Comd ' has Cli(n) sent data?

    ' data executor
    Select Case Comd
        Case " ":
            _PrintString (10, 200), " > Quitting command sent"
            ' it quits
        Case "c", "C":
            _PrintString (10, 200), " > Changing color command sent" ' it changes color
        Case "s", "S":
            _PrintString (10, 200), " > Playing sound command sent" ' it sounds some notes
    End Select
Loop Until InKey$ = " " Or Comd = " " ' press space to quit
Close
End

Lclient2
Code: (Select All)

Rem Project to simulate a server with multiple clients TCP/IP

Rem the second program is the first client side of the network

Screen _NewImage(800, 640, 32)
Cls , _RGBA32(33, 72, 200, 255)
_ScreenMove 600, 100
_PrintString (10, 200), "testing if CLIENT is already ON"

Dim Server As Long
Server = _OpenClient("TCP/IP:7319:localhost")
If Server Then Msg$ = "Client is ON" Else Msg$ = "Cannot activate Client..."
_PrintString (10, 230), Msg$

If Server = 0 Then
    Server = _OpenClient("TCP/IP:7319:localhost") ' it tries a second time the connection with Host
    If Server = 0 Then Msg$ = "Failed to activate server Client. Client is OFF" Else Msg$ = " Activated Server Client. Client is ON"
    _PrintString (10, 300), Msg$
    If Server = 0 Then End
End If


Rem here Client waits user input and sends this to Host

Dim Comd As String

Do
    _Delay 1
    Cls , _RGBA32(33, 72, 200, 255)  '  typo error _RGBA32(128, 200, 200, 255)
    _PrintString (10, 100), "Client is ON, press c/C to change color, s/S to sound notes and space key to quit"
    Comd = "" ' it deletes previous command read by client
    Comd = InKey$

    If Comd <> "" Then Put #Server, , Comd ' has Cli(n) sent data?

    ' data executor
    Select Case Comd
        Case " ":
            _PrintString (10, 200), " > Quitting command sent"
            ' it quits
        Case "c", "C":
            _PrintString (10, 200), " > Changing color command sent" ' it changes color
        Case "s", "S":
            _PrintString (10, 200), " > Playing sound command sent" ' it sounds some notes
    End Select
Loop Until InKey$ = " " Or Comd = " " ' press space to quit
Close
End

Lclient3
Code: (Select All)

Rem Project to simulate a server with multiple clients TCP/IP

Rem the second program is the first client side of the network

Screen _NewImage(800, 640, 32)
Cls , _RGBA32(128, 200, 67, 255)
_ScreenMove 1200, 200
_PrintString (10, 200), "testing if CLIENT is already ON"

Dim Server As Long
Server = _OpenClient("TCP/IP:7319:localhost")
If Server Then Msg$ = "Client is ON" Else Msg$ = "Cannot activate Client..."
_PrintString (10, 230), Msg$

If Server = 0 Then
    Server = _OpenClient("TCP/IP:7319:localhost") ' it tries a second time the connection with Host
    If Server = 0 Then Msg$ = "Failed to activate server Client. Client is OFF" Else Msg$ = " Activated Server Client. Client is ON"
    _PrintString (10, 300), Msg$
    If Server = 0 Then End
End If


Rem here Client waits user input and sends this to Host

Dim Comd As String

Do
    _Delay 1
    Cls , _RGBA32(128, 200, 67, 255)   ' typo error _RGBA32(128, 200, 200, 255)
    _PrintString (10, 100), "Client is ON, press c/C to change color, s/S to sound notes and space key to quit"
    Comd = "" ' it deletes previous command read by client
    Comd = InKey$

    If Comd <> "" Then Put #Server, , Comd ' has Cli(n) sent data?

    ' data executor
    Select Case Comd
        Case " ":
            _PrintString (10, 200), " > Quitting command sent"
            ' it quits
        Case "c", "C":
            _PrintString (10, 200), " > Changing color command sent" ' it changes color
        Case "s", "S":
            _PrintString (10, 200), " > Playing sound command sent" ' it sounds some notes
    End Select
Loop Until InKey$ = " " Or Comd = " " ' press space to quit
Close
End

Well save files with its own name, compile them with F11  (only EXE) and at the end run Host with double click on it.

Play press c/C or s/S and jumping from a client to another...
pressing space bar key the client active and the host stop running.
I have left the END instruction to let see what happens in the different applications windows... but the best is to close all applications. No such more code just few lines to get this result.

Print this item

  Bezier Path Generator
Posted by: TerryRitchie - 10-06-2024, 03:06 AM - Forum: Help Me! - Replies (4)

Has anyone worked with Bezier curves?

I'm attempting to write a path generator for items such as enemy ships, like when the ships form up in Galaga at the start of a level, or during a challenging stage.

The code below is a quick and dirty Bezier path maker. It works, but no matter what I set the variable Detail to the path comes up jagged, with a sort of stair step effect to it. Does anyone know how I can smooth this out if possible?

Code: (Select All)
TYPE POINT
    x AS INTEGER
    y AS INTEGER
END TYPE

DIM Curve(3) AS POINT
REDIM Path(0) AS POINT

DIM p AS POINT

Curve(0).x = 0
Curve(0).y = 479

Curve(1).x = 639
Curve(1).y = 239

Curve(2).x = 0
Curve(2).y = 239

Curve(3).x = 639
Curve(3).y = 0

SCREEN _NEWIMAGE(640, 480, 32)

Detail = .00001


FOR t = 0 TO 1 STEP Detail
    CurvePoint Curve(), p, t
    New = -1
    FOR i = 0 TO UBOUND(Path) - 1
        IF p.x = Path(i).x AND p.y = Path(i).y THEN
            New = 0
            EXIT FOR
        END IF
    NEXT i
    IF New THEN
        Path(UBOUND(Path)) = p
        REDIM _PRESERVE Path(UBOUND(Path) + 1) AS POINT
    END IF

    'PSET (p.x, p.y)
NEXT t

PSET (Path(0).x, Path(0).y)
FOR i = 1 TO UBOUND(Path) - 1
    LINE -(Path(i).x, Path(i).y)
NEXT i
PRINT UBOUND(Path)



SUB CurvePoint (c() AS POINT, p AS POINT, t AS SINGLE)

    'Quick and dirty Bezier point calculator
    'Note: only works for 4 points

    p.x = (1 - t) * (1 - t) * (1 - t) * c(0).x + 3 * (1 - t) * (1 - t) * t * c(1).x + 3 * (1 - t) * t * t * c(2).x + t * t * t * c(3).x
    p.y = (1 - t) * (1 - t) * (1 - t) * c(0).y + 3 * (1 - t) * (1 - t) * t * c(1).y + 3 * (1 - t) * t * t * c(2).y + t * t * t * c(3).y

END SUB

Print this item

  Dav's 10 x 10 Tiles
Posted by: Dimster - 10-05-2024, 04:36 PM - Forum: Dav - Replies (7)

Hi Dav
Think I mentioned to you a while back, that your 10 x 10 tile game is a go to of mine while stumped on a coding issue or just taking a break, while today, for the first time ever, the game hit a stalemate. I couldn't place a formed figure in the tile but neither did I get a game over notice. Here is a screen print of the stalemated board.



Attached Files Thumbnail(s)
   
Print this item

  Thanks for still making a 32-bit version of QB64-PE
Posted by: Dav - 10-05-2024, 01:31 AM - Forum: General Discussion - Replies (5)

Although I use Linux mostly now days, I still have a beloved Win7-32 bit laptop and appreciate that I can use the latest QB64-PE on it.  Thanks for still providing a Win 32-bit build!

Also, I see that the latest 32-bit windows version runs well under wine in LinuxMint.  In fact, using it tonight, I believe I prefer using the Win version of the IDE under Linux instead of the Linux build.  The Win version IDE runs snappier for me, and I haven't had the random program freezes yet that I've been having with the Linux version.  Also, I can have access to the Win API again this way in Linux, best of both worlds!

- Dav

Print this item