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,799
» Forum posts: 26,379

Full Statistics

Latest Threads
Raspberry OS
Forum: Help Me!
Last Post: Jack
2 minutes ago
» Replies: 2
» Views: 38
Merry Christmas Globes!
Forum: Programs
Last Post: SierraKen
2 hours ago
» Replies: 3
» Views: 31
List of file sound extens...
Forum: Help Me!
Last Post: SMcNeill
3 hours ago
» Replies: 13
» Views: 182
Merry Christmas Globes!
Forum: Christmas Code
Last Post: SierraKen
6 hours ago
» Replies: 1
» Views: 22
fast file find with wildc...
Forum: Help Me!
Last Post: madscijr
6 hours ago
» Replies: 2
» Views: 48
Tenary operator in QB64 w...
Forum: Utilities
Last Post: Pete
8 hours ago
» Replies: 6
» Views: 84
Video Renamer
Forum: Works in Progress
Last Post: Pete
9 hours ago
» Replies: 3
» Views: 55
Need help capturng unicod...
Forum: General Discussion
Last Post: SMcNeill
9 hours ago
» Replies: 24
» Views: 323
QB64PE v4.0 is now live!!
Forum: Announcements
Last Post: RhoSigma
10 hours ago
» Replies: 35
» Views: 1,048
Remark Remover (WIP)
Forum: Works in Progress
Last Post: Pete
10 hours ago
» Replies: 0
» Views: 12

 
  UH little help guys
Posted by: WriterHash - 08-31-2024, 04:13 AM - Forum: Help Me! - Replies (4)

So my project on the world is something like this

Code: (Select All)
Dim money As Integer
Dim strength As Integer
Dim speed As Integer
Dim babes As Integer
Dim balls As Integer
Dim cash As Integer
Dim directions As Integer


'intro
Screen 0
Color 4, 0
Locate 8, 38
Print "The World"
Locate 8, 38
Print "Is Loading"
_Delay 5

'opening
Cls
Print "You finally got released from Prison at Kulai Headquarters"
Print "you looked at the sky and the people below it, you began"
Print "wondering, that you can become rich and powerfull"
Print "so you began your journey."
_Delay 10
GoSub 10


10 Sub MainPart
    Cls
    Print "Whats your name?"
    Input name$
    Sleep 2
    Cls
    Print "You are outside of Kulai Headquarters,"
    Print "Where will you go?"
    Print "(NORTH)"
    Print "(SOUTH)"
End Sub


Sub Options (directions)
    If x = north Then
        Print "You Found A Market of Stores"
    ElseIf x = south Then
        Print "You went to Kulai Headquarters"
    End If
End Sub

so what i want is after the opening i want it to directly jump to Sub MainPart anyone knows how to do it xD

Print this item

  Ideas for Simple A.I. Builds
Posted by: Pete - 08-30-2024, 05:53 PM - Forum: General Discussion - Replies (5)

So part of A.I. is getting a computer to exhibit critical thinking.

I guess we could start off with some rudimentary approaches, for example:

Code: (Select All)
Randomize Timer
Palette 7, 63
Color 0, 7: Cls
View Print 1 To 23
Dim As Integer red, green, blue, mred, mgreen, mblue, i, cnt, pass(3)
score = 100
Do
    cnt = cnt + 1
    red = Rnd * 10 - 4
    green = Rnd * 10 - 6
    blue = Rnd * 10 - 8
    i = Int(Rnd * 3) + 1
    Print i;
    If pass(i) Then action$ = "Pass" Else action$ = "Catch"
    Select Case i
        Case 1
            Color 4, 7: Print "RED "; red; action$
            If action$ = "Catch" Then
                score = score + red
                mred = mred + red
            End If
        Case 2
            Color 2, 7: Print "GREEN "; green; action$
            If action$ = "Catch" Then
                score = score + green
                mgreen = mgreen + green
            End If
        Case 3
            Color 1, 7: Print "BLUE "; blue; action$
            If action$ = "Catch" Then
                score = score + blue
                mblue = mblue + blue
            End If
    End Select
    Color 0, 7
    x = CsrLin
    Locate 25, 1: Print "Score = "; LTrim$(Str$(score)); "    ";
    Locate x, 1

    If cnt = 10 Then
        If mred < mblue And mred < mgreen Then If pass(2) + pass(3) <> 5 Then pass(1) = 1 ' Don't catch red apples.
    ElseIf mgreen < mred And mgreen < mblue Then If pass(1) + pass(3) <> 4 Then pass(2) = 2 ' Don't catch green apples.
    ElseIf mblue < mred And mblue < mgreen Then If pass(1) + pass(2) <> 3 Then pass(3) = 3 ' Don't catch blue apples.
        cnt = 0
    End If
    Sleep
    If InKey$ = Chr$(13) Then Run
Loop

The computer memorizes and evaluates values, and decides to only catch red apples, fairly soon.

Refinements would include ways to deduce this faster, and to widen the sampling if we gave it feedback using greater variance with its results vs the best possible outcome. I mean real A.I. means the computer would keep refining its calculation method until it reached the most efficient method.

Anyway, just having some fun and wondering if anyone else has made anything along A.I. lines they would like to share, or just discuss in this thread.

I'll be back a bit later today to catch up!

Pete

Print this item

  Finally i've found a proper way
Posted by: WriterHash - 08-30-2024, 11:55 AM - Forum: General Discussion - Replies (5)

So for these past months, i been experiancing PTSD, ADHD at full speed so what i did is i left the discord group not just QB64 but all of em and i quit discord, so i been writing a proper way to make my dream project The World happend oh man did i found it, i finally understand the Subtext, how to make a simple intro and the other commands, i did not give up, also i will be using this account from now on Big GrinD Heart

Print this item

  Annoying Patreon Plug
Posted by: SMcNeill - 08-28-2024, 09:37 PM - Forum: Announcements - Replies (6)

Helps!   Helps!   Helps!   We needs all your moneys!!   For just dollars a day, you can help save the world!!


,
,
,

Now, if you're past the awful begging for money sales pitch, I just thought I'd take a moment and remind folks that we DO, in fact, have a Patreon where you can pledge and donate a few dollars to help keep the lights on and running.   This last year, we hit enough subscribers that we should *ALMOST* be at a perpetual always-paid-for state for server costs and what not.

As of last April, I believe we were close enough that a full year's worth of donations would put us all of about $20.00 short, or such, for paying for our server costs.

Only real issue is -- prices on *everything* seems to keep increasing, except for what we ask folks to donate to help keep the lights on around here.  Our income is staying the same, but the expenses slowly go up over time.

Easiest solution?

Come here and beg, whine, and guilt everyone into giving me ALLS your moneys!   $$$

Tongue

Nah.   The easiest solution is just to remind folks every couple of releases or so that we do, indeed, have a Patreon.  If you feel like tossing us a few bucks each month, that's perfectly fine.  If not, that's perfectly fine as well.  We're NOT in this for the money, and we're definitely not a FOR-PROFIT on anything.  I just know different folks like to support the project in various ways, and as such, every so often like to remind them that THIS option still exists -- even if we don't advertise it or push for it much:

Sign up on Patreon and join the recurring monthly donations of $3, $5, or $10!  (I know, we ask for a LOT, when that tiny amount won't even pay for a large coffee at Starbucks once a month anymore.)  https://www.patreon.com/user?u=86544769

I'm not pushing anyone to donate.  I'm not even ASKING anyone to donate.  You're not going to get anything in the world extra if you DO donate.  I'm just, like always, reminding folks that they CAN donate via Patreon, if they WANT to.



And dammit, don't laugh at me because I have a sucky sales pitch!  I'm a farmer, not a dang car salesman!!  Big Grin

Print this item

  Polygon playground
Posted by: Dav - 08-28-2024, 06:48 PM - Forum: Programs - Replies (5)

Had a small Polygon drawing SUB handy, thought I'd make a screen saver using it.  You can specify the number of sides, radius, angle, border and fill color of polygon.  Maybe useful to somebody.

UPDATED:  Now draws filled polygons.

- Dav

Code: (Select All)
'=====================
'PolygonPlayground.bas v2.0
'=====================
'A single SUB that draws a polygon, filled or not..
'Specify number of sides, radius, angle, border and fill color of polygon.
'Put together by Dav, AUG/2024

'This demo shows the SUB in action.


Screen _NewImage(1000, 700, 32)

Randomize Timer

polygons = 200 'number of polgons in playground

Dim polysides(polygons)
Dim polyradius(polygons)
Dim polyclr&(polygons)
Dim polycx(polygons)
Dim polycy(polygons)

'make random polgons specs

For i = 1 To polygons
    polysides(i) = 3 + Int(Rnd * 10)
    polyradius(i) = 30 + Int(Rnd * 150)
    polyclr&(i) = _RGBA(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255)
    'turn some of those no fill  (zero value)
    If Int(Rnd * 5) = 1 Then polyclr&(i) = 0
    polycx(i) = Rnd * _Width
    polycy(i) = Rnd * _Height
Next


Do
    'spin them all it around
    For a = 0 To 359
        Cls , _RGB(255, 255, 255)
        For i = 1 To polygons
            Polygon polysides(i), polycx(i), polycy(i), polyradius(i), a, _RGBA(0, 0, 0, 128), polyclr&(i)
        Next
        _Display
        _Limit 60
        If InKey$ <> "" Then Exit Do
    Next
Loop




Sub Polygon (sides, cx, cy, radius, angle, borderclr~&, fillclr~&)
    'Draws a polygon. Must have at least 3 sides.
    'Polygon can be filled or not.
    'borderclr~& is the color of the polygon sides.
    'if you want a filled polygon, give a fillclr~& color.
    'if you want only sides drawn (not filled polygon),
    'just use a 0 for the fillclr~& parameter.

    If sides < 3 Then sides = 3

    rot = _D2R(angle)

    x1 = cx + radius * Cos(rot)
    y1 = cy + radius * Sin(rot)
    'draw sides
    For i = 1 To sides
        va = rot + 2 * _Pi * i / sides
        x2 = cx + radius * Cos(va)
        y2 = cy + radius * Sin(va)
        Line (x1, y1)-(x2, y2), borderclr~&
        x1 = x2: y1 = y2
    Next
    'fill inside, if not 0 given
    If fillclr~& <> 0 Then
        ymin = cy - radius
        ymax = cy + radius
        For y = ymin To ymax
            edge = 0
            x1 = cx + radius * Cos(rot)
            y1 = cy + radius * Sin(rot)
            For i = 1 To sides
                va = rot + 2 * _Pi * i / sides
                x2 = cx + radius * Cos(va)
                y2 = cy + radius * Sin(va)
                If ((y1 < y And y2 >= y) Or (y2 < y And y1 >= y)) Then
                    edge = edge + 1
                    If edge = 1 Then
                        leftx = x1 + (y - y1) * (x2 - x1) / (y2 - y1)
                    ElseIf edge = 2 Then
                        rightx = x1 + (y - y1) * (x2 - x1) / (y2 - y1)
                    End If
                End If
                x1 = x2: y1 = y2
            Next
            If edge = 2 Then Line (leftx, y)-(rightx, y), fillclr~&
        Next
    End If
End Sub

Print this item

  Another small filled circe sub (not as fast as fcirc)
Posted by: Dav - 08-28-2024, 02:43 AM - Forum: Programs - Replies (115)

Here's yet another filled circle SUB.  I make a lot program using balls.  A personal challenge I've had for some time - trying to get a faster filled circle routine than the awesome fcirc SUB.  This came close, but fcirc still reigns supreme.  So I will finally yield to the champ (fcirc), posting the final attempt here.  On my laptop fcirc edges out the victory everytime.  I find it rather surprising - fcirc has many more lines of code, but it's still so fast.

- Dav

Code: (Select All)

'FC.BAS
'Dav, AUG/2024

'fc & fcirc circle fill test.
'testing two filled circle SUB's for the fastest one.
'draws 100,000 circles and compares speed.

'fcirc still reigns as fastest on my laptop, by a little.

Screen _NewImage(1000, 700, 32)

'time the fc sub
t# = Timer
For c = 1 To 100000
    fc Rnd * _Width, Rnd * _Height, 35, _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next
t1# = Timer - t#

'time the fcirc sub
t# = Timer
For c = 1 To 100000
    fcirc Rnd * _Width, Rnd * _Height, 35, _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next
t2# = Timer - t#

Print
Print "fc    ="; t1#
Print "fcirc ="; t2#
Print

If t2# < t1# Then
    Print "fcirc wins!"
Else
    Print "fc wins!"
End If

Sub fc (cx, cy, r, clr&)
    For y = -r To r
        x = Int(Sqr(r * r - y * y))
        Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
    Next
End Sub


Sub fcirc (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

Print this item

  Can't attach random-access file
Posted by: PhilOfPerth - 08-28-2024, 02:34 AM - Forum: Help Me! - Replies (7)

I've just submitted a game, which requires a random-access word-list file. I tried to use the Attach File function at the bottom of the page, and it went through all the motions of attaching the file, but the attachment is not showing on the post. Are random-access text files allowed? Huh

Print this item

  WORM - another word-game
Posted by: PhilOfPerth - 08-28-2024, 02:19 AM - Forum: Games - Replies (2)

This is a word-game for two players, where they take turns to build a word, by adding a letter either on the ends or anywhere in the body of the "worm". 
The group of letters must always be part of a legit word, but must not complete the word. A player may "Claim" a completed word, "Challenge" a group of letters and earns points based on the length of the worm.The worm can also be "flipped" (reversed) before adding a letter. A dictionary which checks all submitted words ( up to length 15 letters) is included.

Code: (Select All)
Common Shared Name$(), Score(), MinSize, WinScore, Plr, OK$, Bad$, Alert$, CPL, LN$, DumWrd$, Found, DictWord$, Srch$
Common Shared Wrd$, CsrH, WdPos, Picked, Flipped, L$, Words$(), TLimit, WordVal, TryVal, Try$, A$

SW = 1020: SH = 720
Screen _NewImage(SW, SH, 32)
SetFont: F& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font F& '       choose monospace font
SMode = 32
CPL = Int(SW / _PrintWidth("X")) '                                                        find chars per line for this window width
CTR = Int((CPL + 1) / 2) '                                                                find horiz screen centre
_ScreenMove (_DesktopWidth - SW) / 2, 90 '                                                place window there

CheckDictionary: '                                                                        need random-access word list
If Not (_FileExists("R_ALL15")) Then
    Centre "This game requires the random-access file R_ALL15 to be present", 12
    Sleep: System
End If

Randomize Timer

MinSize = 3 '                                                                             minimum word size
Dim Name$(2), Score(2), Words$(2)
OK$ = "o4l32ce": Bad$ = "o3l32ec": Alert$ = "o4l32msep32ep32ep32ep32e" '                                                       sound for good and bad actions
Name$(1) = "PLAYER 1": Name$(2) = "PLAYER 2" '                                            default names

instructions

Names:
_KeyClear: k$ = ""
Centre "Name of first player (enter for default PLAYER 1)    ", 15
Locate 15, 62
Input k$
If k$ > Chr$(13) Then
    Name$(1) = UCase$(k$)
Else Name$(1) = "PLAYER 1"
End If
Play OK$
Centre Name$(1), 17: Sleep 1: Cls
k$ = ""
Centre "Name of second player (enter for default PLAYER 2)", 15
Locate 15, 64
Input k$
If k$ > Chr$(13) Then
    Name$(2) = UCase$(k$)
Else Name$(2) = "PLAYER 2"
End If
Play OK$
Centre Name$(2), 17: Sleep 1: Cls

WinningScore:
Centre "Winning score  level (1=100 to 9=900, default 100) ?", 15
SetWinScore:
k$ = InKey$
If k$ = "" Then GoTo SetWinScore
If k$ < "1" Or k$ > "9" Then
    WinScore = 100 '                                                                      default winning score
Else
    WinScore = Val(k$) * 100
End If
Play OK$
Centre LTrim$(Str$(WinScore)), 17: Sleep 1: Cls

SetTimeLimit:
Centre "Time limit for new letter (1=30, 2=60, 3=90, 4=120 seconds, default=30) ?", 15
TimeLimit:
k$ = InKey$
If k$ = "" Then GoTo SetTimeLimit
If k$ < "1" Or k$ > "4" Then
    TLimit = 30 '                                                                         default time limit fo letter selection
Else
    TLimit = Val(k$) * 30
End If
Play OK$
txt$ = LTrim$(Str$(TLimit)) + " seconds"
Centre txt$, 17: Sleep 1: Cls

SetUpGame:
Plr = 2
Csr$ = " / "

NewWord:
If Score(1) >= WinScore Or Score(2) >= WinScore Then Winner
Flipped = 0
Wrd$ = Chr$(Int(Rnd * 26) + 65)

PlayerUp:
Cls
If Plr = 1 Then Plr = 2 Else Plr = 1
CsrH = CTR - 1: WdPos = CTR - Int((Len(Wrd$) + 1) / 2) + 1 '                                centre the word and centre cursor for start
wipe "17": Locate 17, WdPos: Print Wrd$
txt$ = Name$(1) + ":" + Str$(Score(1)) + Space$(15) + "Winning score:" + Str$(WinScore) + Space$(15) + Name$(2) + ":" + Str$(Score(2))
Centre txt$, 2
IP = Int((Len(Wrd$) + 1) / 2) + 1
wipe "19" '                                                                                 clear player input line
Locate 19, CsrH + 1: Print "?"
yellow

ShowChoices:
txt$ = Name$(Plr) + " playing"
Centre txt$, 4
Centre "Press A-Z to select a letter to add", 22
If Len(Wrd$) > 1 And Flipped = 0 Then '                                                     show only if more than 1 letter and word is not flipped
    Centre "or", 24
    Centre "1 to Claim a word    2 to Challenge a group    3 to Concede this round", 26 '
End If
Centre "Down-arrow to flip the word", 27 '                                                   can flip multiple times
Centre "Esc to close the game", 28
_KeyClear

GetChoice:
t1 = Timer
Action = 0
While Action < 1
    _Limit 30
    Action = _KeyHit
    t2 = Int(TLimit + 1 - Timer + t1)
    wipe "05": Centre LTrim$(Str$(t2)), 5
    If t2 < 1 Then
        Centre "Too late!", 5
        Sleep 2
        wipe "05"
        Play Bad$
        GoTo PlayerUp
    End If
Wend
wipe "05"
Select Case Action
    Case Is = 27 '                                                                          exit game
        System
    Case Is = 49 '                                                                          claim a completed word
        If Flipped = 0 Then
            Claim
        Else GoTo GetChoice '                                                               if flipped, ignore
        End If
        GoTo NewWord
    Case Is = 50 '                                                                          challenge a group
        If Flipped = 0 Then
            Challenge
        Else GoTo GetChoice '                                                               if flipped, ignore
        End If
        GoTo NewWord
    Case Is = 51 '                                                                         concede this group is unwinnable
        Concede '                                                                           can still concede after flipping
        GoTo NewWord
    Case Is = 20480 '                                                                       down-arrow to flip worm
        Flip
        GoTo PlayerUp
    Case 65 To 90 '                                                                         CAPITAL letter
        L$ = Chr$(Action)
        Locate 19, CsrH + 1: Print L$
        Locate 18, CsrH: Print Csr$
        Picked = 1
    Case 97 To 122 '                                                                        lower-case letter
        L$ = Chr$(Action - 32)
        Locate 19, CsrH + 1: Print L$
        Locate 18, CsrH: Print Csr$
        Picked = 1
    Case Else
        GoTo GetChoice
End Select
Play OK$

Move: '                                                                                     after letter selected, only left-, right- or up-arrow
Centre "Use Left/Right arrows to change its position, then up-arrow to place it", 22
Action = 0
While Action < 1
    Action = _KeyHit
Wend '
Select Case Action
    Case Is = 19200, 52 '                                                                   move left
        If IP > 1 Then
            CsrH = CsrH - 1: IP = IP - 1
            Locate 18, CsrH: Print Csr$
            Locate 19, CsrH + 1: Print L$; " "
        End If
        GoTo Move
    Case Is = 19712, 54 '                                                                   move right
        If CsrH < WdPos + Len(Wrd$) - 2 Then
            CsrH = CsrH + 1: IP = IP + 1
            Locate 18, CsrH: Print Csr$
            Locate 19, CsrH: Print " "; L$
        End If
        GoTo Move
    Case Is = 18432, 56 '                                                                   up (place letter at cursor)
        Wrd$ = Left$(Wrd$, IP - 1) + L$ + Right$(Wrd$, Len(Wrd$) - IP + 1)
        Flipped = 0: Picked = 0
        GoTo PlayerUp
    Case Else
        Play Bad$: GoTo Move
End Select
Sleep

Sub wipe (ln$) '                                                                            erase lines of text - e.g. "020308" for lines 2, 3 and 8
    For a = 1 To Len(ln$) - 1 Step 2 '                                                      ln$ is lines to erase, as string of 2 digit line numbers
        Locate Val(Mid$(ln$, a, 2))
        Print Space$(CPL)
    Next
End Sub

Sub Centre (Txt$, LineNum) '                                                                centres text on selected line
    ctr = Int(CPL / 2 - Len(Txt$) / 2) + 1 '                                                centre is half of Chars Per Line minus half Txt$ length
    Locate LineNum, ctr
    Print Txt$
End Sub

Sub red
    Color _RGB(255, 0, 0)
End Sub

Sub yellow
    Color _RGB(255, 255, 0)
End Sub

Sub white
    Color _RGB(255, 255, 255)
End Sub

Sub Grey
    Color _RGB(128, 128, 128)
End Sub

Sub Claim
    wipe "2224262728"
    Play Alert$ '                                                        clear prompts
    txt$ = Name$(Plr) + " claims that this is a word"
    yellow: Centre txt$, 10
    WordVal = 0:
    For a = 1 To Len(Wrd$): WordVal = WordVal + a: Next
    txt$ = "(Points Value is" + Str$(WordVal) + ")" '                                       calc word value (summation of length)
    Centre txt$, 12
    Centre "Stand by, checking...", 11: Sleep 1
    wipe "04"
    Try$ = Wrd$
    WRdSearch
    claimResult:
    txt$ = "This word is "
    If Found = 0 Then '                                                                    if Found is still 0 (search failed to find this word),
        red: txt$ = txt$ + "not accepted"
        Play Bad$
        If Plr = 1 Then Plr = 2 Else Plr = 1 '                                              swap players and assign points to opponent
        Score(Plr) = Score(Plr) + WordVal
        If Plr = 1 Then Plr = 2 Else Plr = 1 '                                              and swap players back to normal flow
    Else '                                                                                  but if the word is valid,
        yellow: txt$ = txt$ + "acccepted"
        Play OK$
        Words$(Plr) = Words$(Plr) + "  " + Wrd$
        Score(Plr) = Score(Plr) + WordVal '                                                 assign points to player
    End If
    Centre txt$, 4: yellow
    Sleep 2
End Sub

Sub Challenge
    WordVal = 0: Found = 0 '                                                                flag word as not found
    wipe "2224262728": Play Alert$ '                                                        clear prompts
    txt$ = Name$(Plr) + " claims that this group is not part of a word"
    yellow: Centre txt$, 9
    If Plr = 1 Then Plr = 2 Else Plr = 1 '                                                  change Plr ito the CHALLENGED player
    txt$ = Name$(Plr) + " Please type a word containing this group"
    Centre txt$, 11
    _KeyClear
    wipe "13"
    Locate 13, 36
    Input Try$ '                                                                            get the challenged player's claim
    Try$ = UCase$(Try$)
    If Len(Try$) < Len(Wrd$) Or InStr(Try$, Wrd$) < 1 Then '                                if it's shorter than, or doesn't contain the group, fail it,
        For a = 1 To Len(Wrd$): WordVal = WordVal + a: Next: GoTo ChalResult '              and use the original Wrd$ for value (summation of length)
    End If
    wipe "13"
    Centre Try$, 13
    For a = 1 To Len(Try$): WordVal = WordVal + a: Next '                                   otherwise use the length of their try for value
    txt$ = "(Points Value is" + Str$(WordVal)
    Centre txt$, 15
    Centre "Stand by, checking...", 17 '                                                    search word-list for their try
    wipe "04"
    WRdSearch
    ChalResult: '                                                                           now analyze Found
    If Found = 0 Then '                                                                     if their try word is not found
        Play Bad$
        txt$ = Try$ + " is not accepted"
        red
        If Plr = 1 Then Plr = 2 Else Plr = 1 '                                              swap players back to normal and assign points to challenger,
        Score(Plr) = Score(Plr) + WordVal
        If Plr = 1 Then Plr = 2 Else Plr = 1
    Else '                                                                                  but if their word is found,
        Play OK$
        white: txt$ = Try$ + " is accepted"
        Score(Plr) = Score(Plr) + WordVal '                                                 assign points to challenged player
        Words$(Plr) = Words$(Plr) + "  " + Try$ '                                           add the word to their successful words list
    End If
    Centre txt$, 19: _Delay 2: wipe "19"
    yellow
    If Plr = 1 Then Plr = 2 Else Plr = 1 '                                                  swap players
End Sub

Sub Concede
    WordVal = 0
    Play Bad$
    For a = 1 To Len(Wrd$): WordVal = WordVal + a: Next '                                   calculate word value
    txt$ = Name$(Plr) + " concedes this group as unwinnable"
    yellow: Centre txt$, 9
    If Plr = 1 Then Plr = 2 Else Plr = 1 '                                                  swap players,
    Score(Plr) = Score(Plr) + WordVal '                                                     allocate points to other player,
    If Plr = 1 Then Plr = 2 Else Plr = 1 '                                                  and swap back to normal flow
    _Delay 3
End Sub


Sub WRdSearch
    Found = 0 '                                                                             start search with Found as 0 (failed)
    Open "R_ALL15" For Random As #1 Len = 19
    FL = LOF(1) \ 19 + 1 '                                                                  FL is number of words in file
    bot = 0: top = FL '                                                                     search area between top and bottom words of file
    While Abs(top - bot) > 1
        srch = Int((top + bot) / 2)
        Get #1, srch, A$ '                                                                  get word at centre of search area
        A$ = UCase$(A$)
        Select Case A$
            Case Is = Try$ '                                                                if the word=Wrd$
                Found = 1 '                                                                 mark Found as 1, and stop searching
                Exit While
            Case Is < Try$ '                                                                if the word is less than Wrd$
                bot = srch '                                                                move bottom of search to middle of search
            Case Is > Try$ '                                                                if the word is greater than wrd$
                top = srch '                                                                move top of search to middle of search
        End Select
    Wend '                                                                                  if gap top to bottom >1, repeat search with new search area
    Close

End Sub

Sub Flip
    TmpWrd$ = String$(Len(Wrd$), ".") '                                                      create temporary word
    For a = 1 To Len(Wrd$)
        Mid$(TmpWrd$, a, 1) = Mid$(Wrd$, Len(Wrd$) - a + 1, 1) '                             write letters in reverse order into temp word
    Next
    Wrd$ = TmpWrd$ '                                                                         and change Wrd$ to TmpWrd$
    Flipped = 1 '                                                                            set Flipped flag to prevent their claiming or challenging
    If Plr = 1 Then Plr = 2 Else Plr = 1 '                                                   keep same player after flip
End Sub

Sub Winner
    Cls
    For a = 1 To 5: Play OK$: Next
    yellow
    Centre "We have a winner!", 12: white: Print
    txt$ = Name$(1) + ": " + LTrim$(Str$(Score(1))) + "     " + Name$(2) + ": " + LTrim$(Str$(Score(2)))
    Centre txt$, 14
    yellow: txt$ = "Congratulations "
    If Score(1) > Score(2) Then txt$ = txt$ + Name$(1) Else txt$ = txt$ + Name$(2)
    Centre txt$, 16
    Print: Print
    Print Name$(1); " words: ": white: Print Words$(1)
    Print
    yellow: Print Name$(2); " words: ": white: Print Words$(2)
    Print

    Sleep
    System
End Sub

Sub instructions
    Cls: yellow
    Centre "Worm - An original word-Game for two players by Phil Taylor", 3
    Centre "Instructions", 5: white
    Print
    Print " A random letter is presented, and two players take turns to add a letter to"
    Print " it, building towards a word, but avoiding completing it. The letter may be"
    Print " placed at either end, or anywhere inside the group, exending the "; Chr$(34); "Worm"; Chr$(34); ". By";
    Print " default, they have just 30 seconds in which to choose their letter, but a"
    Print " different time limit can be selected."
    Print
    Print " If a player sees that their opponent has completed a word, they can ";: yellow: Print "Claim";: white: Print " it"
    Print " to score points. If successful the challenger gains points based on the word"
    Print " length. If not,their opponent gains the points. A new word then starts."
    Print
    Print " Players may also";: yellow: Print " Flip";: white: Print " (reverse) the Worm before adding their letter (but the"
    Print " Found of the Flip can not be claimed as a word)."
    Print
    Print " If they think that the group is not part of a real word they may ";: yellow: Print "Challenge";: white: Print ","
    Print " and their opponent must then type a complete word containing the group. If"
    Print " they can"; Chr$(39); "t,  the challenger gains points, based on the size of the group, or"
    Print " the length of their attempt, whichever is greater."
    Print
    Print " If a player thinks that all the words that can be formed from the group will"
    Print " cost them points, they may ";: yellow: Print "Concede";: white: Print " the group, to limit the number of points"
    Print " they lose."
    Print
    Print " Word lengths of from two to fifteen letters allowed, and words are checked"
    Print " automatically by the computer. The game ends when a player reaches the chosen"
    Print " winning score."
    yellow: Centre "Press a key to continue.", 33
    Sleep
    Cls: Play OK$
End Sub



Attached Files
.7z   R_ALL15.7z (Size: 653.84 KB / Downloads: 32)
Print this item

  Scrapship
Posted by: 40wattstudio - 08-27-2024, 04:18 PM - Forum: Games - Replies (2)

After 4 years I've finally finished my first QB64 game: Scrapship -- a top-down space shooter.

https://40wattstudio.itch.io/scrapship

The full game is 100% free to play.

Print this item

Heart QB64-PE v3.14.1 is now released
Posted by: RhoSigma - 08-27-2024, 09:46 AM - Forum: Announcements - Replies (18)

Due to a serious bug in _SNDOPEN (reported here) we once again decided to release a quick bugfix version, rather than letting this bug lurking around for another 2-3 month until our next regular release.
Visit GitHub for download.

Enhancements

  • #531, #532 - Extended `ON ERROR GOTO` syntax - @RhoSigma-QB64
      - _NEWHANDLER and _LASTHANDLER keywords allow for easy overriding and restoring of error handlers
Bug Fixes Full Changelog: https://github.com/QB64-Phoenix-Edition/......v3.14.1

Developer Notice
We are probably going to deprecate the $NOPREFIX feature sooner or later in the future. Nothing is finally decided yet, but as we have more and more efforts to keep new things compatible with $NOPREFIX it's a decision we've to make. Especially CONST and the pre-compiler metacommands show bad interactions with $NOPREFIX over and over again and make implementations overcomplicated.

With this notice we wish to get your attention for the issue and recommend to adapt your coding habits to no longer rely on $NOPREFIX right now, so it becomes an easy transition when we finally drop it.

Print this item