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,794
» Forum posts: 26,353

Full Statistics

Latest Threads
Tenary operator in QB64 w...
Forum: Utilities
Last Post: Kernelpanic
14 minutes ago
» Replies: 4
» Views: 44
List of file sound extens...
Forum: Help Me!
Last Post: madscijr
16 minutes ago
» Replies: 7
» Views: 105
fast file find with wildc...
Forum: Help Me!
Last Post: madscijr
20 minutes ago
» Replies: 0
» Views: 5
Need help capturng unicod...
Forum: General Discussion
Last Post: Petr
2 hours ago
» Replies: 23
» Views: 303
Video Renamer
Forum: Works in Progress
Last Post: SpriggsySpriggs
3 hours ago
» Replies: 1
» Views: 29
QB64PE v4.0 is now live!!
Forum: Announcements
Last Post: Kernelpanic
4 hours ago
» Replies: 33
» Views: 1,003
games or graphics for 3-D...
Forum: General Discussion
Last Post: madscijr
8 hours ago
» Replies: 26
» Views: 782
Text-centring subs
Forum: Utilities
Last Post: SierraKen
Today, 05:46 AM
» Replies: 2
» Views: 51
QB64-PE v4's new 4-voice ...
Forum: Learning Resources and Archives
Last Post: a740g
Today, 02:51 AM
» Replies: 6
» Views: 149
Sound Ball
Forum: Programs
Last Post: SierraKen
Yesterday, 11:34 PM
» Replies: 0
» Views: 28

 
  FormatX$ in QB64
Posted by: eoredson - 09-29-2024, 06:45 AM - Forum: Utilities - Replies (8)

Find attached the file FormatX5.zip which contains FormatX.bas and is a library of format functions.

They are not a Print Using replicants but contain certain FormatX$ functions similar to the ones in QB 7.1

The functions allow for parsing formatted strings and unique to QB64 which has no Format$ functions.

  Year between 1753 and 2078 increased to 0001 and 9999.

NOT backwards compatible with QB 4.5 because format date/time is stored in float Now## precision.

Read on! ejo Big Grin

Code: (Select All)
Format library v5.0a in BASIC for QB64 similar to BC7/VBDOS1 is PD 2024.
   Version v1.0a:
     Initial creation 09/30/2024.
   Version v2.0a:
     Adds StoreColor for Colorf function.
     Adds KeyBoardLine$ function.
     Adds Debug to StatusLine.
     Adds some constants.
  Version v3.0a:
    Adds Control-Break trapping.
    Adds statusline format strinng.
    Adds titlebar timer trap.
  Version v4.0a:
    Adds extended LineInput$ function.
  Version v5.0a:
    Fixes date/time display in:
      DateTimeClock$ and DateTimeClockSerial$ (serial##)

Now 2,590 lines.



Attached Files
.zip   FORMATX5.ZIP (Size: 20.83 KB / Downloads: 33)
Print this item

  Using pipes.
Posted by: ahenry3068 - 09-28-2024, 01:35 PM - Forum: Help Me! - Replies (7)

When using the Shell command I can redirect STDOUT with the standard command line syntax.    I have used the technique to use write files then open them in my code.

However      Is there a way to have the program output to a pipe and have my program read from the pipe without using an intermediate file ?

Print this item

Heart I have decided
Posted by: WriterHash - 09-27-2024, 12:29 PM - Forum: General Discussion - Replies (1)

okay so i been experimenting with 8088 machine via PCem, i used the hercules video card with amber color, i love it Big Grin
so i'll make a text adventure game but for the 80s era baby like dont you love opening your pc just to play a text adventure game Big Grin
for grammar i use chatgpt cause robots has good grammar i dont Big GrinDD


I was thinking of making an rpg similiar to Elder Scrolls daggerfall but scratch that i'll make my own rpg
with

stats
equipments
spells
golds
love (lust is okay too LOL)
a mid size world Big Grin wish me luck guys wohoooo

Print this item

  Old code needs fixing (problem solved)
Posted by: bplus - 09-27-2024, 09:31 AM - Forum: Help Me! - Replies (6)

I got this from Steve at old forum and tested it today on problem encountered by Cortez at another forum.

It does not work:

Code: (Select All)
' !!!!    2024-09-27 this does not work
' test
Print N2S$("1E6")
Print N2S$("10E6")
Print N2S$("100E6")
Print N2S$("1E-6")
Print N2S$("10E-6")
Print N2S$("100E-6")
Function N2S$ (EXP$) 'remove scientific Notation to String (~40 LOC)
    'SMcNeill Jan 7, 2020 ref: https://www.qb64.org/forum/index.php?topic=1555.msg112989#msg112989
    'Last Function in code marked Best Answer (removed debug comments and blank lines added these 2 lines.)
    ReDim t$, sign$, l$, r$, r&&
    ReDim dp As Long, dm As Long, ep As Long, em As Long, check1 As Long, l As Long, i As Long
    t$ = LTrim$(RTrim$(EXP$))
    If Left$(t$, 1) = "-" Or Left$(t$, 1) = "N" Then sign$ = "-": t$ = Mid$(t$, 2)
    dp = InStr(t$, "D+"): dm = InStr(t$, "D-")
    ep = InStr(t$, "E+"): em = InStr(t$, "E-")
    check1 = Sgn(dp) + Sgn(dm) + Sgn(ep) + Sgn(em)
    If check1 < 1 Or check1 > 1 Then N2S = _Trim$(EXP$): Exit Function 'If no scientic notation is found, or if we find more than 1 type, it's not SN!
    Select Case l 'l now tells us where the SN starts at.
        Case Is < dp: l = dp
        Case Is < dm: l = dm
        Case Is < ep: l = ep
        Case Is < em: l = em
    End Select
    l$ = Left$(t$, l - 1) 'The left of the SN
    r$ = Mid$(t$, l + 1): r&& = Val(r$) 'The right of the SN, turned into a workable long
    If InStr(l$, ".") Then 'Location of the decimal, if any
        If r&& > 0 Then
            r&& = r&& - Len(l$) + 2
        Else
            r&& = r&& + 1
        End If
        l$ = Left$(l$, 1) + Mid$(l$, 3)
    End If
    Select Case r&&
        Case 0 'what the heck? We solved it already?
            'l$ = l$
        Case Is < 0
            For i = 1 To -r&&
                l$ = "0" + l$
            Next
            l$ = "." + l$
        Case Else
            For i = 1 To r&&
                l$ = l$ + "0"
            Next
            l$ = l$
    End Select
    N2S$ = sign$ + l$
End Function

Anyone have a better way of doing this?

Cortez was testing Val() instead of N2S$() which didn't work either. Val has a bug also.

Print this item

  A Lava Lamp to stare at.
Posted by: Dav - 09-26-2024, 01:48 AM - Forum: Programs - Replies (19)

Something kind of silly but was fun to make.   I started playing with some plasma code and it morphed into a lava lamp somehow.  Never had one in real life.

This runs slow on my older laptop - commenting out the _LIMIT 30 didn't speed it up at all for me.  So if the blobs and plasma go too fast for you on your modern PC, play with the t = TIMER * .7 line to adjust speed.

- Dav

Code: (Select All)
'============
'LAVALAMP.BAS
'============
'By Dav, SEP/2024 for QB64PE

Screen _NewImage(1000, 700, 32)

Do

    Cls

    t = Timer * .7 'control speed here

    'plasma background
    For y = 0 To _Height Step 2
        For x = 0 To _Width Step 2
            r = Int(128 + 127 * Sin((x * .01) + t))
            g = Int(128 + 127 * Sin((y * .01) + t * 1.2))
            b = Int(128 + 127 * Sin((x * .01) + (y * 0.01) + t * .8))
            Line (x, y)-Step(1, 1), _RGBA(r, g, b, 50), BF
        Next
    Next

    'oily plasma blobs
    For y = 50 To _Height - 51
        For x = 325 To 675
            disx = x - _Width \ 2
            dixy = y - _Height \ 2
            wav = Sin(t + dixy * .05 + disx * .05) * 35
            rad = 150 + 50 * Sin(t * 1.5 + dixy * .1) + wav
            pulse = 1 + .5 * Sin(t + dixy * .1)
            If Sqr(disx ^ 2 / (85 * pulse) ^ 2 + dixy ^ 2 / (rad * pulse) ^ 2) < 1 Then
                clr = Int(255 - Sqr(disx ^ 2 + dixy ^ 2) / 2)
                Line (x, y)-Step(1, 1), _RGBA(255, clr, clr / 3, 150), BF
            End If
        Next
    Next

    'draw top half of lamp
    For y = 50 To 350
        wfix = (350 - y) / 3
        Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
    Next
    'draw bottom half of lamp
    For y = 351 To 650
        wfix = (y - 351) / 3
        Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
    Next

    'lamp top
    Line (425, 20)-(575, 50), _RGB(150, 100, 0), BF
    Line (425, 20)-(575, 50), _RGBA(255, 255, 100, 75), B

    'lamp base
    Line (375, 650)-(625, 700), _RGB(150, 100, 0), BF
    Line (375, 650)-(625, 700), _RGBA(255, 255, 100, 75), B

    _Display
    _Limit 30

Loop Until InKey$ <> ""

Print this item

  Line Points
Posted by: Petr - 09-25-2024, 07:10 PM - Forum: Petr - Replies (2)

Small utility for calculating points in line.

Code: (Select All)

Type LinePoints
    X As Integer
    Y As Integer
End Type
ReDim Shared LP(0) As LinePoints

Screen _NewImage(800, 600, 32)

Line (40, 399)-(100, 199)
GETPOINTS 40, 399, 100, 199, LP()
Sleep
'if all points in array are calctulated correctly, all points in LINE are draw yellow


For D = 0 To UBound(LP)
    PSet (LP(D).X, LP(D).Y), &HFFFFFF00
Next D


Sub GETPOINTS (x1, y1, x2, y2, A() As LinePoints)
    Dim lenght As Integer
    lenght = _Hypot(x1 - x2, y1 - y2) 'Fellippe Heitor show me using this great function.
    ReDim A(lenght) As LinePoints
    For fill = 0 To lenght
        If x1 > x2 Then A(fill).X = x1 - fill * ((x1 - x2) / lenght)
        If x1 < x2 Then A(fill).X = x1 + fill * ((x2 - x1) / lenght)
        If x1 = x2 Then A(fill).X = x1
        If y1 > y2 Then A(fill).Y = y1 - fill * ((y1 - y2) / lenght)
        If y1 < y2 Then A(fill).Y = y1 + fill * ((y2 - y1) / lenght)
        If y1 = y2 Then A(fill).Y = y1
    Next
End Sub

Print this item

  I have learned something new: how to get a run-time syntax error
Posted by: TDarcos - 09-25-2024, 04:08 PM - Forum: Programs - Replies (2)

In the following code

Code: (Select All)
Dim a As Integer
On Error GoTo Error1

Read a
Read b

Print a
Print b
End

Dim As Integer ER, EL
Error1:
ER = Err: EL = _ErrorLine
Resume Quit



Quit:
Print "?Error"; ER; " on line"; EL; "described as "
Print _ErrorMessage$(ER)
End

Data 6
Data 7        ' the number

It will trap with an error 2 on line 5. I discovered something today:
You can't put a comment on a data statement.
Without the comment it works just fine.

Print this item

  Copying and pasting a non-rectangular area of screen
Posted by: Dav - 09-25-2024, 12:26 PM - Forum: Help Me! - Replies (20)

Has anyone made a routine to copy a paste a non-rectangular area of the screen?  Or does QB64PE have a built-in way?  I'm working on a new drawing program and trying to add a feature where you can draw an enclosed area with the mouse, copy it, and paste it.  Making a circle area routine was easy, but having some difficulty with the any shape one.  I'm doing a polygon approach for the any shaped one, capture all the pixels inside the drawn polygon.   Wondered if someone here has already made such a routine that is working.

Here's the circle copy/paste that is working ok.

- Dav

Code: (Select All)

Screen _NewImage(1000, 700, 32)

For t = 1 To 7000
    Color _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
    Print _Trim$(Str$(Int(Rnd * 10)));
Next

Circle (100, 100), 51, _RGB(255, 255, 255)
x& = GetCircle&(100, 100, 50)

Locate 2, 24:: Color _RGB(255, 255, 255)
Print "  Copied this area of the screen  "
_Delay 2

Cls

Do
    PutCircle Rnd * _Width, Rnd * _Height, x&, Rnd * 255
    _Limit 30
Loop Until InKey$ <> ""



Function GetCircle& (cx, cy, radius)

    If circleimg& <> 0 Then _FreeImage circleimg&

    circleimg& = _NewImage(radius * 2, radius * 2) '

    _Dest circleimg&

    For x = 0 To radius * 2
        For y = 0 To radius * 2
            If Sqr((x - radius) ^ 2 + (y - radius) ^ 2) <= radius Then
                clr& = Point(cx - radius + x, cy - radius + y)
                PSet (x, y), clr&
            End If
        Next
    Next

    GetCircle& = _CopyImage(circleimg&)
    _FreeImage circleimg&

    _Dest 0

End Function

Sub PutCircle (cx, cy, img&, alpha)

    If img& = 0 Then Exit Sub

    radius = _Width(img&) / 2

    _Source img&
    _Dest 0

    For x = 0 To radius * 2
        For y = 0 To radius * 2
            If Sqr((x - radius) ^ 2 + (y - radius) ^ 2) <= radius Then
                clr~& = Point(x, y)
                r = _Red32(clr~&)
                g = _Green32(clr~&)
                b = _Blue32(clr~&)
                PSet (cx + x, cy + y), _RGBA(r, g, b, alpha)
            End If
        Next
    Next

    _Source 0

End Sub

Print this item

  HAPPY BIRTHDAY STEVE
Posted by: Pete - 09-25-2024, 12:14 AM - Forum: Announcements - Replies (15)

I baked you a cake with a zip file in it, and 51 LED candles. Good luck blowing these babies out! 

Pete

Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea 
Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea 
Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea Idea

Print this item

Tongue request: anyone want to do a remake of goat simulator or desert bus?
Posted by: madscijr - 09-24-2024, 01:00 PM - Forum: General Discussion - Replies (7)

If anyone is looking for a challenge or fun project, here are a couple games that QB64PE should able to handle - both are ridiculous! Big Grin

The original Goat Simulator!
goat simulator

Latest sequel:
goat simulator 3

Desert Bus!
desert bus

Print this item