QB64 Phoenix Edition
Twizzle Logic Puzzle Game - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Games (https://qb64phoenix.com/forum/forumdisplay.php?fid=57)
+----- Forum: Donald Foster (https://qb64phoenix.com/forum/forumdisplay.php?fid=58)
+----- Thread: Twizzle Logic Puzzle Game (/showthread.php?tid=3711)

Pages: 1 2


RE: Twizzle Logic Puzzle Game - PhilOfPerth - 05-28-2025

(05-28-2025, 02:09 AM)Donald Foster Wrote: This all got screwed up when I accidently deleted the code and tried remember and rush fixing it. I changed my _PrintString to _UPrintString and didn't really notice a difference, except the names in 5 buttons got shifted down and I moved them back up. But, I also noticed the top of my numbers are not chopped off anymore. bplus, did you change the font used? 

here is a fix to then not giving you credit for finishing the puzzle:

Code: (Select All)
_Title "Twizzle Logic Puzzle"

Screen _NewImage(1324, 737, 256): Randomize Timer

Randomize Timer

_PaletteColor 1, _RGB32(1) ' Black
_PaletteColor 2, _RGB32(50) ' Black
_PaletteColor 3, _RGB32(100) ' Black
_PaletteColor 4, _RGB32(0, 185, 0) ' Green
_PaletteColor 5, _RGB32(0, 159, 255) ' Blue
_PaletteColor 6, _RGB32(129, 0, 125) ' Purple
_PaletteColor 7, _RGB32(225, 0, 0) ' Red

Dim As _Byte U, Y, Z, Selected, Selection, Position, Knob, Rotation
Dim As Integer V, W, X
Dim As Integer LevelY(4), KnobX(9), KnobY(9), CardX(10), CardY(10), Rotate1X, Rotate1Y, Rotate2X, Rotate2Y
Dim Shared As _Byte StartCard, EndCard, Level, Moves, LevelColor(4), Tile(24), CardPattern(40, 24)
Dim Shared As Integer TileX(24), TileY(24)

LevelColor(0) = 0: LevelColor(1) = 4: LevelColor(2) = 5: LevelColor(3) = 6: LevelColor(4) = 7

'Setup Card Patterns
Data 0,0,0,0,1,1,0,0,0,0,3,2,2,3,0,0,0,0,4,4,0,0,0,0: ' Card 01
Data 0,0,0,4,3,1,2,0,0,0,0,0,0,0,0,0,0,2,1,3,4,0,0,0: ' Card 02
Data 4,0,3,1,0,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,3,1,0,4: ' Card 03
Data 2,0,3,2,0,0,3,0,0,0,0,0,0,0,0,0,0,4,0,0,1,4,0,1: ' Card 04
Data 0,0,0,0,1,1,0,2,0,3,0,0,0,0,2,0,3,0,4,4,0,0,0,0: ' Card 05
Data 0,0,0,0,1,3,0,2,0,4,0,0,0,0,3,0,1,0,4,2,0,0,0,0: ' Card 06
Data 0,0,0,0,0,0,0,2,4,3,1,0,0,1,2,4,3,0,0,0,0,0,0,0: ' Card 07
Data 0,4,0,0,0,0,0,0,4,0,1,1,2,2,0,3,0,0,0,0,0,0,3,0: ' Card 08
Data 0,0,1,0,0,2,2,0,0,1,0,0,0,0,4,0,0,3,3,0,0,4,0,0: ' Card 09
Data 0,0,0,0,0,2,0,3,2,0,0,3,4,0,0,1,4,0,1,0,0,0,0,0: ' Card 10
Data 0,3,0,1,3,3,2,0,0,0,1,0,0,2,0,0,0,1,4,4,2,0,4,0: ' Card 11
Data 1,1,1,4,0,0,3,0,0,0,4,0,0,3,0,0,0,4,0,0,3,2,2,2: ' Card 12
Data 2,1,2,3,0,0,4,0,0,0,4,0,0,3,0,0,0,3,0,0,4,1,2,1: ' Card 13
Data 2,2,2,0,4,3,0,0,0,0,0,4,3,0,0,0,0,0,4,3,0,1,1,1: ' Card 14
Data 0,0,0,0,1,4,0,1,1,4,0,3,4,0,3,2,2,0,3,2,0,0,0,0: ' Card 15
Data 0,0,0,0,3,4,0,1,1,1,0,3,4,0,2,2,2,0,3,4,0,0,0,0: ' Card 16
Data 3,0,3,2,0,0,1,0,3,0,0,2,1,0,0,4,0,2,0,0,1,4,0,4: ' Card 17
Data 0,3,0,0,1,1,0,2,0,4,4,0,0,2,2,0,4,0,3,3,0,0,1,0: ' Card 18
Data 4,0,2,1,3,3,1,2,0,4,0,0,0,0,0,3,0,0,4,2,0,0,1,0: ' Card 19
Data 3,0,0,4,4,0,0,3,3,0,0,4,1,0,0,2,2,0,0,1,1,0,0,2: ' Card 20
Data 4,4,4,1,4,4,2,1,0,2,1,0,0,2,1,0,2,1,3,3,2,3,3,3: ' Card 21
Data 3,3,3,4,4,1,1,3,0,3,4,0,0,1,2,0,2,4,4,1,1,2,2,2: ' Card 22
Data 4,3,1,2,1,2,2,4,0,3,1,0,0,4,2,0,1,3,3,4,3,4,2,1: ' Card 23
Data 4,3,1,2,1,2,2,4,0,3,1,0,0,4,2,0,1,3,3,4,3,4,2,1: ' Card 24
Data 4,2,4,2,3,3,1,1,0,2,1,0,0,4,2,0,3,3,1,2,1,4,3,4: ' card 25
Data 3,2,2,3,2,0,2,0,2,4,3,3,4,4,3,1,0,1,0,1,4,1,1,4: ' Card 26
Data 2,2,0,3,2,2,0,3,2,4,3,3,4,4,3,1,4,0,1,1,4,0,1,1: ' Card 27
Data 3,0,1,4,1,4,3,2,2,2,0,1,4,0,3,3,3,4,1,4,2,2,0,1: ' Card 28
Data 1,0,3,1,1,2,4,1,2,4,0,2,4,0,2,4,3,2,4,3,3,1,0,3: ' Card 29
Data 4,0,2,4,4,2,2,4,4,2,0,1,2,0,1,3,3,1,1,3,3,1,0,3: ' Card 30
Data 1,1,1,4,4,3,3,1,1,1,4,4,3,3,2,2,2,4,4,3,3,2,2,2: ' Card 31
Data 1,1,1,2,3,3,1,3,3,3,2,4,3,1,4,4,4,2,4,4,1,2,2,2: ' Card 32
Data 2,1,2,4,1,1,3,3,1,4,3,3,4,4,3,2,4,4,2,2,3,1,2,1: ' Card 33
Data 4,2,2,1,4,2,2,1,4,2,3,1,4,2,3,1,4,3,3,1,4,3,3,1: ' Card 34
Data 3,3,3,4,1,1,3,2,2,2,4,1,1,3,2,2,2,4,1,1,3,4,4,4: ' Card 35
Data 1,1,1,4,2,1,3,4,4,4,4,2,1,3,3,3,3,4,2,1,3,2,2,2: ' Card 36
Data 2,2,2,4,3,3,1,1,3,4,4,1,4,1,1,2,4,4,2,2,1,3,3,3: ' Card 37
Data 3,3,3,3,3,1,1,3,1,1,2,2,1,1,2,2,4,2,2,4,4,4,4,4: ' Card 38
Data 3,3,2,3,3,2,2,3,3,2,1,1,2,2,1,4,4,1,1,4,4,1,4,4: ' Card 39
Data 1,1,1,3,1,1,4,3,1,4,3,3,4,4,3,2,4,3,2,2,4,2,2,2: ' Card 40
For Z = 1 To 40: For Y = 1 To 24: Read CardPattern(Z, Y): Next: Next


LevelCursor$ = "R389D55L389U55H1R391D57L391U57"
CardCursor$ = "R165D165L165U165H1R167D167L167U167H1R169D169"

Puzzle: Cls , 15

' Draw Board
Circle (170, 170), 160, 2, 1.4, 3.3: Circle (567, 170), 160, 2, 0, 1.8: Circle (170, 567), 160, 2, 2.9, 4.8: Circle (567, 567), 160, 2, 4.4, 0
Line (170, 10)-(567, 10), 2: Line (170, 727)-(567, 727), 2: Line (10, 170)-(10, 567), 2: Line (727, 170)-(727, 567), 2: Paint (170, 170), 2
X = 70: W = 0: U = 0
For Z = 1 To 7
    V = 70
    For Y = 1 To 7
        If Z = 1 Or Z = 3 Or Z = 5 Or Z = 7 Then
            If Y = 2 Or Y = 4 Or Y = 6 Then
                Circle (V, X + 100), 138, 1, .81, 2.34: Circle (V, X - 100), 138, 1, 3.96, 5.455: Paint (V, X), 0, 1
                Tile(U) = 0: U = U + 1: TileX(U) = V: TileY(U) = X
            End If
        Else
            If Y = 1 Or Y = 3 Or Y = 5 Or Y = 7 Then
                Circle (V + 100, X), 138, 1, 2.36, 3.93: Circle (V - 100, X), 138, 1, 5.5, .771: Paint (V, X), 0, 1
                Tile(U) = 0: U = U + 1: TileX(U) = V: TileY(U) = X
            End If
            If Y = 2 Or Y = 4 Or Y = 6 Then Circle (V, X), 50, 1: Paint (V, X), 3, 1: W = W + 1: KnobX(W) = V: KnobY(W) = X
        End If
        V = V + 100
    Next
    X = X + 100
Next

BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

Color 0, 15: font& = _LoadFont(BoldFont$, 30): _Font font&: _UPrintString (820, 10), "T W I Z Z L E   L O G I C   P U Z Z L E"

font& = _LoadFont(BoldFont$, 25): _Font font&:

X = 220
For Z = 1 To 4
    Color LevelColor(Z), 15
    If Z = 1 Then _UPrintString (883, X), "L E V E L  1:  B E G I N N E R"
    If Z = 2 Then _UPrintString (850, X), "L E V E L  2:  I N T E R M E D I A T E"
    If Z = 3 Then _UPrintString (883, X), "L E V E L  3:  A D V A N C E D"
    If Z = 4 Then _UPrintString (905, X), "L E V E L  4:  E X P E R T"
    LevelY(Z) = X: X = X + 100
Next

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), "Choose a Level to Play"

ChooseLevel:
Do While _MouseInput
    For Z = 1 To 4
        If _MouseX > 830 And _MouseY < 1219 And _MouseY > LevelY(Z) - 20 And _MouseY < LevelY(Z) + 35 Then Selected = 1 Else Selected = 0
        If Selected = 1 Then PSet (830, LevelY(Z) - 20), 0: Draw LevelCursor$ Else PSet (830, LevelY(Z) - 20), 15: Draw LevelCursor$
        If _MouseButton(1) = -1 And Selected = 1 Then GoSub ReleaseButton: Level = Z: GoTo ClearLevels
    Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseLevel

ClearLevels:
Line (828, 198)-(1220, 560), 15, BF: Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), Space$(300)

Color 0, 15: _UPrintString (905, 320), "Choose Cards Randomly": _UPrintString (915, 420), "Choose Cards Yourself"

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), "Choose Cards Selection"

ChooseCardSelection:
Do While _MouseInput
    For Z = 1 To 2
        If _MouseX > 830 And _MouseY < 1219 And _MouseY > LevelY(Z + 1) - 20 And _MouseY < LevelY(Z + 1) + 35 Then Selected = 1 Else Selected = 0
        If Selected = 1 Then PSet (830, LevelY(Z + 1) - 20), 0: Draw LevelCursor$ Else PSet (830, LevelY(Z + 1) - 20), 15: Draw LevelCursor$
        If _MouseButton(1) = -1 And Selected = 1 Then GoSub ReleaseButton: Selection = Z: GoTo ChooseCards
    Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseCardSelection

ChooseCards:
Line (828, 198)-(1220, 560), 15, BF: Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), Space$(300)

If Selection = 2 Then

    If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31

    X = 118: Position = 1
    For Z = 1 To 4
        If Z = 4 Then W = 1: V = 1025 Else W = 3: V = 857
        For Y = 1 To W
            DrawCard V, X, Card: CardX(Position) = V: CardY(Position) = X
            Card = Card + 1: Position = Position + 1: V = V + 168
        Next
        X = X + 168
    Next

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose a Starting Card"

    StartingCard:
    Do While _MouseInput
        If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31
        For Z = 1 To 10
            If _MouseX > CardX(Z) - 80 And _MouseX < CardX(Z) + 80 And _MouseY > CardY(Z) - 80 And _MouseY < CardY(Z) + 80 And _MouseButton(1) = -1 Then
                GoSub ReleaseButton: StartCard = Card: Position = Z: GoTo PlaceStartCard
            End If
            Card = Card + 1
        Next
    Loop
    A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    GoTo StartingCard

    PlaceStartCard:
    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(CardPattern(StartCard, Z)), 1: Tile(Z) = CardPattern(StartCard, Z): Next

    Line (CardX(Position) - 80, CardY(Position) - 80)-(CardX(Position) + 80, CardY(Position) + 80), 15, BF

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose an Ending Card"

    EndingCard:
    Do While _MouseInput
        If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31
        For Z = 1 To 10
            If _MouseX > CardX(Z) - 80 And _MouseX < CardX(Z) + 80 And _MouseY > CardY(Z) - 80 And _MouseY < CardY(Z) + 80 And _MouseButton(1) = -1 Then
                If Z <> Position Then GoSub ReleaseButton: EndCard = Card: GoTo ClearCards
            End If
            Card = Card + 1
        Next
    Loop
    A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    GoTo EndingCard

    ClearCards: Line (777, 38)-(1290, 737), 15, BF

Else

    Card1 = Int(Rnd * 10) + 1
    If Level = 1 Then StartCard = Card1 Else If Level = 2 Then StartCard = Card1 + 10 Else If Level = 3 Then StartCard = Card1 + 20 Else If Level = 4 Then StartCard = Card1 + 30

    GetCard2: card2 = Int(Rnd * 10) + 1: If card2 = Card1 GoTo GetCard2
    If Level = 1 Then EndCard = card2 Else If Level = 2 Then EndCard = card2 + 10 Else If Level = 3 Then EndCard = card2 + 20 Else If Level = 4 Then EndCard = card2 + 30

    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(CardPattern(StartCard, Z)), 1: Tile(Z) = CardPattern(StartCard, Z): Next

End If

' Display Level
Color LevelColor(Level), 15
If Level = 1 Then _UPrintString (883, 60), "L E V E L  1:  B E G I N N E R"
If Level = 2 Then _UPrintString (850, 60), "L E V E L  2:  I N T E R M E D I A T E"
If Level = 3 Then _UPrintString (883, 60), "L E V E L  3:  A D V A N C E D"
If Level = 4 Then _UPrintString (905, 60), "L E V E L  4:  E X P E R T"

' Display Cards
DrawCard 873, 190, StartCard: DrawCard 1177, 190, EndCard: PSet (980, 190), 0: Draw "D30R30D30E60H60D30L30D30BR10P0,0"
Color 0, 15: _UPrintString (825, 280), "STARTING": Color 0, 15: _UPrintString (830, 305), "PATTERN"
Color 0, 15: _UPrintString (1135, 280), "ENDING": Color 0, 15: _UPrintString (1130, 305), "PATTERN"

' Display Rotation Arrows
Circle (873, 440), 70, 0, 1.5, 0: Circle (873, 440), 50, 0, 1.5, 0: PSet (873, 370), 0: Draw "U20F30G30U20BD50BR50R20BG10P0,0"
Circle (1177, 440), 70, 0, 3.1, 1.6: Circle (1177, 440), 50, 0, 3.1, 1.6: PSet (1177, 370), 0: Draw "U20G30F30U20BD50BL50L20BF10P0,0"

Color 0, 15: font& = _LoadFont(BoldFont$, 35): _Font font&: _PrintString (955, 370), "M O V E S": Moves = 0

' Display Buttons
DrawButtons

GameLoop:
' Display Move
If Moves < 10 Then X = 970 Else X = 935
Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 120): _Font font&: _PrintString (X, 410), Str$(Moves)

ChooseKnob:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose Knob to Rotate"

ChooseKnobInput:
Do While _MouseInput

    ' Select Knob
    For Z = 1 To 9
        If _MouseX > KnobX(Z) - 50 And _MouseX < KnobX(Z) + 50 And _MouseY > KnobY(Z) - 50 And _MouseY < KnobY(Z) + 50 And _MouseButton(1) = -1 Then
            GoSub ReleaseButton: Knob = Z: GoTo SelectKnob
        End If
    Next

    ' Restart Puzzle
    If _MouseX > 853 And _MouseX < 1009 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else SetupPuzzle: DisplayPuzzle: GoTo ChooseKnob
    End If

    ' New Puzzle
    If _MouseX > 1040 And _MouseX < 1197 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob
        For Z = 1 To 24: Tile(Z) = 0: Next: GoTo Puzzle
    End If

    ' Exit Puzzle
    If _MouseX > 759 And _MouseX < 915 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else System
    End If

    ' Load Puzzle
    If _MouseX > 947 And _MouseX < 1103 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else GoTo LoardPuzzle
    End If

    ' Save Puzzle
    If _MouseX > 1135 And _MouseX < 1291 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: GoTo SavePuzzle
    End If

Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseKnobInput

SelectKnob:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), Space$(250)

' Show Selected Knob
Paint (KnobX(Knob), KnobY(Knob)), 15, 1

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (930, 685), "Choose a Direction": _UPrintString (890, 713), "or Choose a Different Knob"

ChooseRotation:
Do While _MouseInput

    ' Choose Different Knob
    For Z = 1 To 9
        If _MouseX > KnobX(Z) - 50 And _MouseX < KnobX(Z) + 50 And _MouseY > KnobY(Z) - 50 And _MouseY < KnobY(Z) + 50 And _MouseButton(1) = -1 Then
            GoSub ReleaseButton: Paint (KnobX(Knob), KnobY(Knob)), 3, 1: Knob = Z:: Paint (KnobX(Knob), KnobY(Knob)), 15, 1: GoTo ChooseRotation
        End If
    Next

    ' Rotate Clockwise
    If _MouseX > 803 And _MouseX < 943 And _MouseY > 370 And _MouseY < 510 And _MouseButton(1) = -1 Then GoSub ReleaseButton: Rotation = 1: GoTo Rotation

    ' Rotate Counter Clockwise
    If _MouseX > 1107 And _MouseX < 1247 And _MouseY > 370 And _MouseY < 510 And _MouseButton(1) = -1 Then GoSub ReleaseButton: Rotation = 2: GoTo Rotation

    ' Restart Puzzle
    If _MouseX > 853 And _MouseX < 1009 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else SetupPuzzle: DisplayPuzzle: GoTo ChooseKnob
    End If

    ' New Puzzle
    If _MouseX > 1040 And _MouseX < 1197 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob
        For Z = 1 To 24: Tile(Z) = 0: Next: GoTo Puzzle
    End If

    ' Exit Puzzle
    If _MouseX > 759 And _MouseX < 915 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else System
    End If

    ' Load Puzzle
    If _MouseX > 947 And _MouseX < 1103 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else GoTo LoardPuzzle
    End If

    ' Save Puzzle
    If _MouseX > 1135 And _MouseX < 1291 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: GoTo SavePuzzle
    End If

Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseRotation

Rotation:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (930, 685), Space$(250): _UPrintString (890, 713), Space$(250)

RotateTiles Knob, Rotation

' Rest Knob Color
Paint (KnobX(Knob), KnobY(Knob)), 3, 1

' Chect if Ending Pattern is Complete
If CheckTiles(EndCard) = 1 Then

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (800, 685), "You have Completed this Puzzle in " + Str$(Moves) + " Moves"
    _PrintString (870, 713), "Solve Another Puzzle?  Y or N"

    YorN: A$ = UCase$(InKey$): If A$ = "" GoTo YorN
    If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    If A$ = "Y" Then Run
    If A$ = "N" Then System
    GoTo YorN

End If

' Start Next Move
Moves = Moves + 1: GoTo GameLoop

ReleaseButton:
Do While _MouseInput
    If _MouseButton(1) = 0 Then Return
Loop

GoTo ReleaseButton

NoPuzzle:

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (885, 685), "There are No Saved Puzzles": _UPrintString (890, 713), "Press <ENTER> to Continee"

Enter: A$ = InKey$: If A$ = "" GoTo Enter Else If Asc(A$) <> 13 GoTo Enter

_UPrintString (885, 685), Space$(300): _UPrintString (890, 713), Space$(300)

GoTo ChooseKnob

LoardPuzzle:

On Error GoTo NoPuzzle
Open "TwizzleData" For Input As #1
Input #1, Level, StartCard, EndCard, Moves
For Z = 1 To 24: Input #1, Tile(Z): Next
Close #1
DisplayPuzzle

GoTo ChooseKnob

SavePuzzle:

Open "TwizzleData" For Output As #1
Write #1, Level, StartCard, EndCard, Moves
For Z = 1 To 24: Write #1, Tile(Z): Next
Close #1
PuzzleMessage

GoTo ChooseKnob

Sub DrawCard (X, Y, Card)

    Dim As _Byte R, S, V, W, Z: V = LevelColor(Level)
    Dim As Integer T, U

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Circle (X - 69, Y - 69), 10, V, 1.3, 3.3: Circle (X + 69, Y - 69), 10, V, 0, 1.8: Circle (X - 69, Y + 69), 10, V, 2.9, 4.8: Circle (X + 69, Y + 69), 10, V, 4.4, 0
    Line (X - 69, Y - 79)-(X + 69, Y - 79), V: Line (X - 69, Y + 79)-(X + 69, Y + 79), V: Line (X - 79, Y - 69)-(X - 79, Y + 69), V: Line (X + 79, Y - 69)-(X + 79, Y + 69), V: Paint (X, Y), V


    Circle (X - 65, Y - 65), 7, 15, 1.3, 3.3: Circle (X + 65, Y - 65), 7, 15, 0, 1.8: Circle (X - 65, Y + 65), 7, 15, 2.9, 4.8: Circle (X + 65, Y + 65), 7, 15, 4.4, 0
    Line (X - 65, Y - 72)-(X + 65, Y - 72), 15: Line (X - 65, Y + 72)-(X + 65, Y + 72), 15: Line (X - 72, Y - 65)-(X - 72, Y + 65), 15: Line (X + 72, Y - 65)-(X + 72, Y + 65), 15: Paint (X, Y), 15

    Circle (X, Y - 67), 3, V: Paint (X, Y - 67), V
    Circle (X - 67, Y - 6), 3, V: Paint (X - 67, Y - 6), V: Circle (X - 67, Y + 6), 3, V: Paint (X - 67, Y + 6), V
    Circle (X, Y + 67), 3, V: Paint (X, Y + 67), V: Circle (X - 12, Y + 67), 3, V: Paint (X - 12, Y + 67), V: Circle (X + 12, Y + 67), 3, V: Paint (X + 12, Y + 67), V
    Circle (X + 67, Y - 6), 3, V: Paint (X + 67, Y - 6), V: Circle (X + 67, Y + 6), 3, V: Paint (X + 67, Y + 6), V: Circle (X + 67, Y - 18), 3, V: Paint (X + 67, Y - 18), V: Circle (X + 67, Y + 18), 3, V: Paint (X + 67, Y + 18), V

    Circle (X - 30, Y - 30), 30, 0, 1.3, 3.3: Circle (X + 30, Y - 30), 30, 0, 0, 1.8: Circle (X - 30, Y + 30), 30, 0, 2.9, 4.8: Circle (X + 30, Y + 30), 30, 0, 4.4, 0
    Line (X - 30, Y - 60)-(X + 30, Y - 60), 0: Line (X - 30, Y + 60)-(X + 30, Y + 60), 0: Line (X - 60, Y - 30)-(X - 60, Y + 30), 0: Line (X + 60, Y - 30)-(X + 60, Y + 30), 0: Paint (X, Y), 0

    U = Y - 51: W = 0
    For Z = 1 To 7
        T = X - 51
        For V = 1 To 7
            If Z = 1 Or Z = 3 Or Z = 5 Or Z = 7 Then
                If V = 2 Or V = 4 Or V = 6 Then
                    W = W + 1: S = CardPattern(Card, W): R = LevelColor(S)
                    If S > 0 Then Circle (T, U + 15), 20, R, .82, 2.33: Circle (T, U - 15), 20, R, 3.97, 5.454: Paint (T, U), R
                End If
            Else
                If V = 1 Or V = 3 Or V = 5 Or V = 7 Then
                    W = W + 1: S = CardPattern(Card, W): R = LevelColor(S)
                    If S > 0 Then Circle (T + 15, U), 20, R, 2.36, 3.93: Circle (T - 15, U), 20, R, 5.5, .771: Paint (T, U), R
                End If
            End If
            T = T + 17:
        Next
        U = U + 17
    Next

End Sub

Sub DrawButtons

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 15, 0: font& = _LoadFont(BoldFont$, 30): _Font font&

    ' Restart Puzzle
    Circle (873, 561), 21, 0, 1.4, 4.8: Circle (989, 561), 21, 0, 4.4, 1.6: Line (873, 540)-(989, 540), 0: Line (873, 582)-(989, 582), 0: Paint (873, 561), 0
    _UPrintString (888, 548), "Restart"

    ' Change Puzzle
    Circle (1061, 561), 21, 0, 1.4, 4.8: Circle (1177, 561), 21, 0, 4.4, 1.6: Line (1061, 540)-(1177, 540), 0: Line (1061, 582)-(1177, 582), 0: Paint (1061, 561), 0
    _UPrintString (1088, 548), "New"

    ' Exit Puzzle
    Circle (779, 634), 21, 0, 1.4, 4.8: Circle (895, 634), 21, 0, 4.4, 1.6: Line (779, 613)-(895, 613), 0: Line (779, 655)-(895, 655), 0: Paint (779, 634), 0
    _UPrintString (811, 621), "Exit"

    ' Load Puzzle
    Circle (967, 634), 21, 0, 1.4, 4.8: Circle (1083, 634), 21, 0, 4.4, 1.6: Line (967, 613)-(1083, 613), 0: Line (967, 655)-(1083, 655), 0: Paint (967, 634), 0
    _UPrintString (997, 621), "Load"

    ' Save Puzzle
    Circle (1155, 634), 21, 0, 1.4, 4.8: Circle (1271, 634), 21, 0, 4.4, 1.6: Line (1155, 613)-(1271, 613), 0: Line (1155, 655)-(1271, 655), 0: Paint (1155, 634), 0
    _UPrintString (1187, 621), "Save"

End Sub

Sub RotateTiles (Knob, Rotation)

    Dim As _Byte Temp

    Select Case Knob

        Case 1
            If Rotation = 1 Then

                Temp = Tile(1):
                Tile(1) = Tile(4): Paint (TileX(1), TileY(1)), LevelColor(Tile(1)), 1
                Tile(4) = Tile(8): Paint (TileX(4), TileY(4)), LevelColor(Tile(4)), 1
                Tile(8) = Tile(5): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(5) = Temp: Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
            Else
                Temp = Tile(1):
                Tile(1) = Tile(5): Paint (TileX(1), TileY(1)), LevelColor(Tile(1)), 1
                Tile(5) = Tile(8): Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
                Tile(8) = Tile(4): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(4) = Temp: Paint (TileX(4), TileY(4)), LevelColor(Tile(4)), 1
            End If

        Case 2

            If Rotation = 1 Then
                Temp = Tile(2):
                Tile(2) = Tile(5): Paint (TileX(2), TileY(2)), LevelColor(Tile(2)), 1
                Tile(5) = Tile(9): Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
                Tile(9) = Tile(6): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(6) = Temp: Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
            Else
                Temp = Tile(2):
                Tile(2) = Tile(6): Paint (TileX(2), TileY(2)), LevelColor(Tile(2)), 1
                Tile(6) = Tile(9): Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
                Tile(9) = Tile(5): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(5) = Temp: Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
            End If

        Case 3

            If Rotation = 1 Then
                Temp = Tile(3):
                Tile(3) = Tile(6): Paint (TileX(3), TileY(3)), LevelColor(Tile(3)), 1
                Tile(6) = Tile(10): Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
                Tile(10) = Tile(7): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(7) = Temp: Paint (TileX(7), TileY(7)), LevelColor(Tile(7)), 1
            Else
                Temp = Tile(3):
                Tile(3) = Tile(7): Paint (TileX(3), TileY(3)), LevelColor(Tile(3)), 1
                Tile(7) = Tile(10): Paint (TileX(7), TileY(7)), LevelColor(Tile(7)), 1
                Tile(10) = Tile(6): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(6) = Temp: Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
            End If

        Case 4

            If Rotation = 1 Then
                Temp = Tile(8):
                Tile(8) = Tile(11): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(11) = Tile(15): Paint (TileX(11), TileY(11)), LevelColor(Tile(11)), 1
                Tile(15) = Tile(12): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(12) = Temp: Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
            Else
                Temp = Tile(8):
                Tile(8) = Tile(12): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(12) = Tile(15): Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
                Tile(15) = Tile(11): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(11) = Temp: Paint (TileX(11), TileY(11)), LevelColor(Tile(11)), 1
            End If

        Case 5

            If Rotation = 1 Then
                Temp = Tile(9):
                Tile(9) = Tile(12): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(12) = Tile(16): Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
                Tile(16) = Tile(13): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(13) = Temp: Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
            Else
                Temp = Tile(9):
                Tile(9) = Tile(13): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(13) = Tile(16): Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
                Tile(16) = Tile(12): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(12) = Temp: Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
            End If

        Case 6

            If Rotation = 1 Then
                Temp = Tile(10):
                Tile(10) = Tile(13): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(13) = Tile(17): Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
                Tile(17) = Tile(14): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(14) = Temp: Paint (TileX(14), TileY(14)), LevelColor(Tile(14)), 1
            Else
                Temp = Tile(10):
                Tile(10) = Tile(14): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(14) = Tile(17): Paint (TileX(14), TileY(14)), LevelColor(Tile(14)), 1
                Tile(17) = Tile(13): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(13) = Temp: Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
            End If

        Case 7

            If Rotation = 1 Then
                Temp = Tile(15):
                Tile(15) = Tile(18): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(18) = Tile(22): Paint (TileX(18), TileY(18)), LevelColor(Tile(18)), 1
                Tile(22) = Tile(19): Paint (TileX(22), TileY(22)), LevelColor(Tile(22)), 1
                Tile(19) = Temp: Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
            Else
                Temp = Tile(15):
                Tile(15) = Tile(19): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(19) = Tile(22): Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
                Tile(22) = Tile(18): Paint (TileX(22), TileY(22)), LevelColor(Tile(22)), 1
                Tile(18) = Temp: Paint (TileX(18), TileY(18)), LevelColor(Tile(18)), 1
            End If

        Case 8

            If Rotation = 1 Then
                Temp = Tile(16):
                Tile(16) = Tile(19): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(19) = Tile(23): Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
                Tile(23) = Tile(20): Paint (TileX(23), TileY(23)), LevelColor(Tile(23)), 1
                Tile(20) = Temp: Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
            Else
                Temp = Tile(16):
                Tile(16) = Tile(20): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(20) = Tile(23): Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
                Tile(23) = Tile(19): Paint (TileX(23), TileY(23)), LevelColor(Tile(23)), 1
                Tile(19) = Temp: Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
            End If

        Case 9

            If Rotation = 1 Then
                Temp = Tile(17):
                Tile(17) = Tile(20): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(20) = Tile(24): Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
                Tile(24) = Tile(21): Paint (TileX(24), TileY(24)), LevelColor(Tile(24)), 1
                Tile(21) = Temp: Paint (TileX(21), TileY(21)), LevelColor(Tile(21)), 1
            Else
                Temp = Tile(17):
                Tile(17) = Tile(21): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(21) = Tile(24): Paint (TileX(21), TileY(21)), LevelColor(Tile(21)), 1
                Tile(24) = Tile(20): Paint (TileX(24), TileY(24)), LevelColor(Tile(24)), 1
                Tile(20) = Temp: Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
            End If

    End Select

End Sub

Function CheckTiles (Card)

    Dim As _Byte X, Z: X = 0

    For Z = 1 To 24
        If Tile(Z) = CardPattern(Card, Z) Then X = X + 1
    Next

    If X = 24 Then CheckTiles = 1 Else CheckTiles = 0

End Function

Function EndPuzzle

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (860, 685), Space$(250): _UPrintString (870, 713), "     End this Puzzle?  Y or N    "

    YorN: A$ = UCase$(InKey$): If A$ = "" Then GoTo YorN
    If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    If A$ = "Y" Then EndPuzzle = 1: GoTo EndSub
    If A$ = "N" Then EndPuzzle = 0: GoTo EndSub
    GoTo YorN

    EndSub: Color 0, 15: _UPrintString (870, 713), Space$(250)

End Function

Sub SetupPuzzle

    For Z = 1 To 24: Tile(Z) = CardPattern(StartCard, Z): Next: Moves = 0

End Sub

Sub DisplayPuzzle

    Dim As _Byte Z: Dim As Integer X

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 25): _Font font&
    If Level = 1 Then _UPrintString (883, 60), "L E V E L  1:  B E G I N N E R"
    If Level = 2 Then _UPrintString (850, 60), "L E V E L  2:  I N T E R M E D I A T E"
    If Level = 3 Then _UPrintString (883, 60), "L E V E L  3:  A D V A N C E D"
    If Level = 4 Then _UPrintString (905, 60), "L E V E L  4:  E X P E R T"

    Line (795, 110)-(955, 270), 15, BF: DrawCard 875, 190, StartCard
    Line (1097, 110)-(1257, 270), 15, BF: DrawCard 1177, 190, EndCard

    If Moves < 10 Then X = 970 Else X = 935
    Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 120): _Font font&: _UPrintString (X, 410), Str$(Moves)

    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(Tile(Z)), 2: Next

End Sub

Sub PuzzleMessage

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (885, 685), "Your Puzzle has been Saved": _UPrintString (890, 713), "Press <ENTER> to Continee"

    Enter2: A$ = InKey$: If A$ = "" GoTo Enter2 Else If Asc(A$) <> 13 GoTo Enter2

    _UPrintString (885, 685), Space$(300): _UPrintString (890, 713), Space$(300)

End Sub

While experimenting with your game, I found that eliminating line330(Goto ChooseRrotation) made it easier to play - clicking the circles to rotate, rotated the disc 90 degreees each time, with no need to use rotation buttons. Not sure what else is affected, but... worth a look?


RE: Twizzle Logic Puzzle Game - Donald Foster - 05-29-2025

PhilOfPerth, the purpose of line 330 in continue the input loop back to the top of the loop. I gets input from the mouse and keyboard. I removed it and it bypassed the input question to choose the rotation.

bplus, _UPrintString did help fix the top of the characters were trimmed on top portion, flattening it. Thanks for the suggestion. Also, the left rotation arrow was being chopped into because I needed to add LTRIM and move the number over some.

Here is the updated code:
Code: (Select All)
_Title "Twizzle Logic Puzzle"

Screen _NewImage(1324, 737, 256): Randomize Timer

Randomize Timer

_PaletteColor 1, _RGB32(1) ' Black
_PaletteColor 2, _RGB32(50) ' Black
_PaletteColor 3, _RGB32(100) ' Black
_PaletteColor 4, _RGB32(0, 185, 0) ' Green
_PaletteColor 5, _RGB32(0, 159, 255) ' Blue
_PaletteColor 6, _RGB32(129, 0, 125) ' Purple
_PaletteColor 7, _RGB32(225, 0, 0) ' Red

Dim As _Byte U, Y, Z, Selected, Selection, Position, Knob, Rotation
Dim As Integer V, W, X
Dim As Integer LevelY(4), KnobX(9), KnobY(9), CardX(10), CardY(10), Rotate1X, Rotate1Y, Rotate2X, Rotate2Y
Dim Shared As _Byte StartCard, EndCard, Level, Moves, LevelColor(4), Tile(24), CardPattern(40, 24)
Dim Shared As Integer TileX(24), TileY(24)

LevelColor(0) = 0: LevelColor(1) = 4: LevelColor(2) = 5: LevelColor(3) = 6: LevelColor(4) = 7

'Setup Card Patterns
Data 0,0,0,0,1,1,0,0,0,0,3,2,2,3,0,0,0,0,4,4,0,0,0,0: ' Card 01
Data 0,0,0,4,3,1,2,0,0,0,0,0,0,0,0,0,0,2,1,3,4,0,0,0: ' Card 02
Data 4,0,3,1,0,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,3,1,0,4: ' Card 03
Data 2,0,3,2,0,0,3,0,0,0,0,0,0,0,0,0,0,4,0,0,1,4,0,1: ' Card 04
Data 0,0,0,0,1,1,0,2,0,3,0,0,0,0,2,0,3,0,4,4,0,0,0,0: ' Card 05
Data 0,0,0,0,1,3,0,2,0,4,0,0,0,0,3,0,1,0,4,2,0,0,0,0: ' Card 06
Data 0,0,0,0,0,0,0,2,4,3,1,0,0,1,2,4,3,0,0,0,0,0,0,0: ' Card 07
Data 0,4,0,0,0,0,0,0,4,0,1,1,2,2,0,3,0,0,0,0,0,0,3,0: ' Card 08
Data 0,0,1,0,0,2,2,0,0,1,0,0,0,0,4,0,0,3,3,0,0,4,0,0: ' Card 09
Data 0,0,0,0,0,2,0,3,2,0,0,3,4,0,0,1,4,0,1,0,0,0,0,0: ' Card 10
Data 0,3,0,1,3,3,2,0,0,0,1,0,0,2,0,0,0,1,4,4,2,0,4,0: ' Card 11
Data 1,1,1,4,0,0,3,0,0,0,4,0,0,3,0,0,0,4,0,0,3,2,2,2: ' Card 12
Data 2,1,2,3,0,0,4,0,0,0,4,0,0,3,0,0,0,3,0,0,4,1,2,1: ' Card 13
Data 2,2,2,0,4,3,0,0,0,0,0,4,3,0,0,0,0,0,4,3,0,1,1,1: ' Card 14
Data 0,0,0,0,1,4,0,1,1,4,0,3,4,0,3,2,2,0,3,2,0,0,0,0: ' Card 15
Data 0,0,0,0,3,4,0,1,1,1,0,3,4,0,2,2,2,0,3,4,0,0,0,0: ' Card 16
Data 3,0,3,2,0,0,1,0,3,0,0,2,1,0,0,4,0,2,0,0,1,4,0,4: ' Card 17
Data 0,3,0,0,1,1,0,2,0,4,4,0,0,2,2,0,4,0,3,3,0,0,1,0: ' Card 18
Data 4,0,2,1,3,3,1,2,0,4,0,0,0,0,0,3,0,0,4,2,0,0,1,0: ' Card 19
Data 3,0,0,4,4,0,0,3,3,0,0,4,1,0,0,2,2,0,0,1,1,0,0,2: ' Card 20
Data 4,4,4,1,4,4,2,1,0,2,1,0,0,2,1,0,2,1,3,3,2,3,3,3: ' Card 21
Data 3,3,3,4,4,1,1,3,0,3,4,0,0,1,2,0,2,4,4,1,1,2,2,2: ' Card 22
Data 4,3,1,2,1,2,2,4,0,3,1,0,0,4,2,0,1,3,3,4,3,4,2,1: ' Card 23
Data 4,3,1,2,1,2,2,4,0,3,1,0,0,4,2,0,1,3,3,4,3,4,2,1: ' Card 24
Data 4,2,4,2,3,3,1,1,0,2,1,0,0,4,2,0,3,3,1,2,1,4,3,4: ' card 25
Data 3,2,2,3,2,0,2,0,2,4,3,3,4,4,3,1,0,1,0,1,4,1,1,4: ' Card 26
Data 2,2,0,3,2,2,0,3,2,4,3,3,4,4,3,1,4,0,1,1,4,0,1,1: ' Card 27
Data 3,0,1,4,1,4,3,2,2,2,0,1,4,0,3,3,3,4,1,4,2,2,0,1: ' Card 28
Data 1,0,3,1,1,2,4,1,2,4,0,2,4,0,2,4,3,2,4,3,3,1,0,3: ' Card 29
Data 4,0,2,4,4,2,2,4,4,2,0,1,2,0,1,3,3,1,1,3,3,1,0,3: ' Card 30
Data 1,1,1,4,4,3,3,1,1,1,4,4,3,3,2,2,2,4,4,3,3,2,2,2: ' Card 31
Data 1,1,1,2,3,3,1,3,3,3,2,4,3,1,4,4,4,2,4,4,1,2,2,2: ' Card 32
Data 2,1,2,4,1,1,3,3,1,4,3,3,4,4,3,2,4,4,2,2,3,1,2,1: ' Card 33
Data 4,2,2,1,4,2,2,1,4,2,3,1,4,2,3,1,4,3,3,1,4,3,3,1: ' Card 34
Data 3,3,3,4,1,1,3,2,2,2,4,1,1,3,2,2,2,4,1,1,3,4,4,4: ' Card 35
Data 1,1,1,4,2,1,3,4,4,4,4,2,1,3,3,3,3,4,2,1,3,2,2,2: ' Card 36
Data 2,2,2,4,3,3,1,1,3,4,4,1,4,1,1,2,4,4,2,2,1,3,3,3: ' Card 37
Data 3,3,3,3,3,1,1,3,1,1,2,2,1,1,2,2,4,2,2,4,4,4,4,4: ' Card 38
Data 3,3,2,3,3,2,2,3,3,2,1,1,2,2,1,4,4,1,1,4,4,1,4,4: ' Card 39
Data 1,1,1,3,1,1,4,3,1,4,3,3,4,4,3,2,4,3,2,2,4,2,2,2: ' Card 40
For Z = 1 To 40: For Y = 1 To 24: Read CardPattern(Z, Y): Next: Next


LevelCursor$ = "R389D55L389U55H1R391D57L391U57"
CardCursor$ = "R165D165L165U165H1R167D167L167U167H1R169D169"

Puzzle: Cls , 15

' Draw Board
Circle (170, 170), 160, 2, 1.4, 3.3: Circle (567, 170), 160, 2, 0, 1.8: Circle (170, 567), 160, 2, 2.9, 4.8: Circle (567, 567), 160, 2, 4.4, 0
Line (170, 10)-(567, 10), 2: Line (170, 727)-(567, 727), 2: Line (10, 170)-(10, 567), 2: Line (727, 170)-(727, 567), 2: Paint (170, 170), 2
X = 70: W = 0: U = 0
For Z = 1 To 7
    V = 70
    For Y = 1 To 7
        If Z = 1 Or Z = 3 Or Z = 5 Or Z = 7 Then
            If Y = 2 Or Y = 4 Or Y = 6 Then
                Circle (V, X + 100), 138, 1, .81, 2.34: Circle (V, X - 100), 138, 1, 3.96, 5.455: Paint (V, X), 0, 1
                Tile(U) = 0: U = U + 1: TileX(U) = V: TileY(U) = X
            End If
        Else
            If Y = 1 Or Y = 3 Or Y = 5 Or Y = 7 Then
                Circle (V + 100, X), 138, 1, 2.36, 3.93: Circle (V - 100, X), 138, 1, 5.5, .771: Paint (V, X), 0, 1
                Tile(U) = 0: U = U + 1: TileX(U) = V: TileY(U) = X
            End If
            If Y = 2 Or Y = 4 Or Y = 6 Then Circle (V, X), 50, 1: Paint (V, X), 3, 1: W = W + 1: KnobX(W) = V: KnobY(W) = X
        End If
        V = V + 100
    Next
    X = X + 100
Next

BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

Color 0, 15: font& = _LoadFont(BoldFont$, 30): _Font font&: _UPrintString (820, 10), "T W I Z Z L E   L O G I C   P U Z Z L E"

font& = _LoadFont(BoldFont$, 25): _Font font&:

X = 220
For Z = 1 To 4
    Color LevelColor(Z), 15
    If Z = 1 Then _UPrintString (883, X), "L E V E L  1:  B E G I N N E R"
    If Z = 2 Then _UPrintString (850, X), "L E V E L  2:  I N T E R M E D I A T E"
    If Z = 3 Then _UPrintString (883, X), "L E V E L  3:  A D V A N C E D"
    If Z = 4 Then _UPrintString (905, X), "L E V E L  4:  E X P E R T"
    LevelY(Z) = X: X = X + 100
Next

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), "Choose a Level to Play"

ChooseLevel:
Do While _MouseInput
    For Z = 1 To 4
        If _MouseX > 830 And _MouseY < 1219 And _MouseY > LevelY(Z) - 20 And _MouseY < LevelY(Z) + 35 Then Selected = 1 Else Selected = 0
        If Selected = 1 Then PSet (830, LevelY(Z) - 20), 0: Draw LevelCursor$ Else PSet (830, LevelY(Z) - 20), 15: Draw LevelCursor$
        If _MouseButton(1) = -1 And Selected = 1 Then GoSub ReleaseButton: Level = Z: GoTo ClearLevels
    Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseLevel

ClearLevels:
Line (828, 198)-(1220, 560), 15, BF: Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), Space$(300)

Color 0, 15: _UPrintString (905, 320), "Choose Cards Randomly": _UPrintString (915, 420), "Choose Cards Yourself"

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), "Choose Cards Selection"

ChooseCardSelection:
Do While _MouseInput
    For Z = 1 To 2
        If _MouseX > 830 And _MouseY < 1219 And _MouseY > LevelY(Z + 1) - 20 And _MouseY < LevelY(Z + 1) + 35 Then Selected = 1 Else Selected = 0
        If Selected = 1 Then PSet (830, LevelY(Z + 1) - 20), 0: Draw LevelCursor$ Else PSet (830, LevelY(Z + 1) - 20), 15: Draw LevelCursor$
        If _MouseButton(1) = -1 And Selected = 1 Then GoSub ReleaseButton: Selection = Z: GoTo ChooseCards
    Next
Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseCardSelection

ChooseCards:
Line (828, 198)-(1220, 560), 15, BF: Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (920, 713), Space$(300)

If Selection = 2 Then

    If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31

    X = 118: Position = 1
    For Z = 1 To 4
        If Z = 4 Then W = 1: V = 1025 Else W = 3: V = 857
        For Y = 1 To W
            DrawCard V, X, Card: CardX(Position) = V: CardY(Position) = X
            Card = Card + 1: Position = Position + 1: V = V + 168
        Next
        X = X + 168
    Next

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose a Starting Card"

    StartingCard:
    Do While _MouseInput
        If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31
        For Z = 1 To 10
            If _MouseX > CardX(Z) - 80 And _MouseX < CardX(Z) + 80 And _MouseY > CardY(Z) - 80 And _MouseY < CardY(Z) + 80 And _MouseButton(1) = -1 Then
                GoSub ReleaseButton: StartCard = Card: Position = Z: GoTo PlaceStartCard
            End If
            Card = Card + 1
        Next
    Loop
    A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    GoTo StartingCard

    PlaceStartCard:
    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(CardPattern(StartCard, Z)), 1: Tile(Z) = CardPattern(StartCard, Z): Next

    Line (CardX(Position) - 80, CardY(Position) - 80)-(CardX(Position) + 80, CardY(Position) + 80), 15, BF

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose an Ending Card"

    EndingCard:
    Do While _MouseInput
        If Level = 1 Then Card = 1 Else If Level = 2 Then Card = 11 Else If Level = 3 Then Card = 21 Else Card = 31
        For Z = 1 To 10
            If _MouseX > CardX(Z) - 80 And _MouseX < CardX(Z) + 80 And _MouseY > CardY(Z) - 80 And _MouseY < CardY(Z) + 80 And _MouseButton(1) = -1 Then
                If Z <> Position Then GoSub ReleaseButton: EndCard = Card: GoTo ClearCards
            End If
            Card = Card + 1
        Next
    Loop
    A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    GoTo EndingCard

    ClearCards: Line (777, 38)-(1290, 737), 15, BF

Else

    Card1 = Int(Rnd * 10) + 1
    If Level = 1 Then StartCard = Card1 Else If Level = 2 Then StartCard = Card1 + 10 Else If Level = 3 Then StartCard = Card1 + 20 Else If Level = 4 Then StartCard = Card1 + 30

    GetCard2: card2 = Int(Rnd * 10) + 1: If card2 = Card1 GoTo GetCard2
    If Level = 1 Then EndCard = card2 Else If Level = 2 Then EndCard = card2 + 10 Else If Level = 3 Then EndCard = card2 + 20 Else If Level = 4 Then EndCard = card2 + 30

    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(CardPattern(StartCard, Z)), 1: Tile(Z) = CardPattern(StartCard, Z): Next

End If

' Display Level
Color LevelColor(Level), 15
If Level = 1 Then _UPrintString (883, 60), "L E V E L  1:  B E G I N N E R"
If Level = 2 Then _UPrintString (850, 60), "L E V E L  2:  I N T E R M E D I A T E"
If Level = 3 Then _UPrintString (883, 60), "L E V E L  3:  A D V A N C E D"
If Level = 4 Then _UPrintString (905, 60), "L E V E L  4:  E X P E R T"

' Display Cards
DrawCard 873, 190, StartCard: DrawCard 1177, 190, EndCard: PSet (980, 190), 0: Draw "D30R30D30E60H60D30L30D30BR10P0,0"
Color 0, 15: _UPrintString (825, 280), "STARTING": Color 0, 15: _UPrintString (830, 305), "PATTERN"
Color 0, 15: _UPrintString (1135, 280), "ENDING": Color 0, 15: _UPrintString (1130, 305), "PATTERN"

' Display Rotation Arrows
Circle (873, 440), 70, 0, 1.5, 0: Circle (873, 440), 50, 0, 1.5, 0: PSet (873, 370), 0: Draw "U20F30G30U20BD50BR50R20BG10P0,0"
Circle (1177, 440), 70, 0, 3.1, 1.6: Circle (1177, 440), 50, 0, 3.1, 1.6: PSet (1177, 370), 0: Draw "U20G30F30U20BD50BL50L20BF10P0,0"

Color 0, 15: font& = _LoadFont(BoldFont$, 35): _Font font&: _UPrintString (955, 370), "M O V E S": Moves = 0

' Display Buttons
DrawButtons

GameLoop:
' Display Move
If Moves < 10 Then X = 995 Else X = 960
Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 120): _Font font&: _UPrintString (X, 410), LTrim$(Str$(Moves))

ChooseKnob:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), "Choose Knob to Rotate"

ChooseKnobInput:
Do While _MouseInput

    ' Select Knob
    For Z = 1 To 9
        If _MouseX > KnobX(Z) - 50 And _MouseX < KnobX(Z) + 50 And _MouseY > KnobY(Z) - 50 And _MouseY < KnobY(Z) + 50 And _MouseButton(1) = -1 Then
            GoSub ReleaseButton: Knob = Z: GoTo SelectKnob
        End If
    Next

    ' Restart Puzzle
    If _MouseX > 853 And _MouseX < 1009 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else SetupPuzzle: DisplayPuzzle: GoTo ChooseKnob
    End If

    ' New Puzzle
    If _MouseX > 1040 And _MouseX < 1197 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob
        For Z = 1 To 24: Tile(Z) = 0: Next: GoTo Puzzle
    End If

    ' Exit Puzzle
    If _MouseX > 759 And _MouseX < 915 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else System
    End If

    ' Load Puzzle
    If _MouseX > 947 And _MouseX < 1103 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else GoTo LoardPuzzle
    End If

    ' Save Puzzle
    If _MouseX > 1135 And _MouseX < 1291 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: GoTo SavePuzzle
    End If

Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseKnobInput

SelectKnob:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (910, 713), Space$(250)

' Show Selected Knob
Paint (KnobX(Knob), KnobY(Knob)), 15, 1

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (930, 685), "Choose a Direction": _UPrintString (890, 713), "or Choose a Different Knob"

ChooseRotation:
Do While _MouseInput

    ' Choose Different Knob
    For Z = 1 To 9
        If _MouseX > KnobX(Z) - 50 And _MouseX < KnobX(Z) + 50 And _MouseY > KnobY(Z) - 50 And _MouseY < KnobY(Z) + 50 And _MouseButton(1) = -1 Then
            GoSub ReleaseButton: Paint (KnobX(Knob), KnobY(Knob)), 3, 1: Knob = Z:: Paint (KnobX(Knob), KnobY(Knob)), 15, 1: GoTo ChooseRotation
        End If
    Next

    ' Rotate Clockwise
    If _MouseX > 803 And _MouseX < 943 And _MouseY > 370 And _MouseY < 510 And _MouseButton(1) = -1 Then GoSub ReleaseButton: Rotation = 1: GoTo Rotation

    ' Rotate Counter Clockwise
    If _MouseX > 1107 And _MouseX < 1247 And _MouseY > 370 And _MouseY < 510 And _MouseButton(1) = -1 Then GoSub ReleaseButton: Rotation = 2: GoTo Rotation

    ' Restart Puzzle
    If _MouseX > 853 And _MouseX < 1009 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else SetupPuzzle: DisplayPuzzle: GoTo ChooseKnob
    End If

    ' New Puzzle
    If _MouseX > 1040 And _MouseX < 1197 And _MouseY > 520 And _MouseY < 602 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob
        For Z = 1 To 24: Tile(Z) = 0: Next: GoTo Puzzle
    End If

    ' Exit Puzzle
    If _MouseX > 759 And _MouseX < 915 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else System
    End If

    ' Load Puzzle
    If _MouseX > 947 And _MouseX < 1103 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: If EndPuzzle = 0 GoTo ChooseKnob Else GoTo LoardPuzzle
    End If

    ' Save Puzzle
    If _MouseX > 1135 And _MouseX < 1291 And _MouseY > 613 And _MouseY < 653 And _MouseButton(1) = -1 Then
        GoSub ReleaseButton: GoTo SavePuzzle
    End If

Loop
A$ = InKey$: If A$ <> "" Then If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
GoTo ChooseRotation

Rotation:
Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (930, 685), Space$(250): _UPrintString (890, 713), Space$(250)

RotateTiles Knob, Rotation

' Rest Knob Color
Paint (KnobX(Knob), KnobY(Knob)), 3, 1

' Chect if Ending Pattern is Complete
If CheckTiles(EndCard) = 1 Then

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (800, 685), "You have Completed this Puzzle in " + Str$(Moves) + " Moves"
    _PrintString (870, 713), "Solve Another Puzzle?  Y or N"

    YorN: A$ = UCase$(InKey$): If A$ = "" GoTo YorN
    If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    If A$ = "Y" Then Run
    If A$ = "N" Then System
    GoTo YorN

End If

' Start Next Move
Moves = Moves + 1: GoTo GameLoop

ReleaseButton:
Do While _MouseInput
    If _MouseButton(1) = 0 Then Return
Loop

GoTo ReleaseButton

NoPuzzle:

Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (885, 685), "There are No Saved Puzzles": _UPrintString (890, 713), "Press <ENTER> to Continee"

Enter: A$ = InKey$: If A$ = "" GoTo Enter Else If Asc(A$) <> 13 GoTo Enter

_UPrintString (885, 685), Space$(300): _UPrintString (890, 713), Space$(300)

GoTo ChooseKnob

LoardPuzzle:

On Error GoTo NoPuzzle
Open "TwizzleData" For Input As #1
Input #1, Level, StartCard, EndCard, Moves
For Z = 1 To 24: Input #1, Tile(Z): Next
Close #1
DisplayPuzzle

GoTo ChooseKnob

SavePuzzle:

Open "TwizzleData" For Output As #1
Write #1, Level, StartCard, EndCard, Moves
For Z = 1 To 24: Write #1, Tile(Z): Next
Close #1
PuzzleMessage

GoTo ChooseKnob

Sub DrawCard (X, Y, Card)

    Dim As _Byte R, S, V, W, Z: V = LevelColor(Level)
    Dim As Integer T, U

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Circle (X - 69, Y - 69), 10, V, 1.3, 3.3: Circle (X + 69, Y - 69), 10, V, 0, 1.8: Circle (X - 69, Y + 69), 10, V, 2.9, 4.8: Circle (X + 69, Y + 69), 10, V, 4.4, 0
    Line (X - 69, Y - 79)-(X + 69, Y - 79), V: Line (X - 69, Y + 79)-(X + 69, Y + 79), V: Line (X - 79, Y - 69)-(X - 79, Y + 69), V: Line (X + 79, Y - 69)-(X + 79, Y + 69), V: Paint (X, Y), V


    Circle (X - 65, Y - 65), 7, 15, 1.3, 3.3: Circle (X + 65, Y - 65), 7, 15, 0, 1.8: Circle (X - 65, Y + 65), 7, 15, 2.9, 4.8: Circle (X + 65, Y + 65), 7, 15, 4.4, 0
    Line (X - 65, Y - 72)-(X + 65, Y - 72), 15: Line (X - 65, Y + 72)-(X + 65, Y + 72), 15: Line (X - 72, Y - 65)-(X - 72, Y + 65), 15: Line (X + 72, Y - 65)-(X + 72, Y + 65), 15: Paint (X, Y), 15

    Circle (X, Y - 67), 3, V: Paint (X, Y - 67), V
    Circle (X - 67, Y - 6), 3, V: Paint (X - 67, Y - 6), V: Circle (X - 67, Y + 6), 3, V: Paint (X - 67, Y + 6), V
    Circle (X, Y + 67), 3, V: Paint (X, Y + 67), V: Circle (X - 12, Y + 67), 3, V: Paint (X - 12, Y + 67), V: Circle (X + 12, Y + 67), 3, V: Paint (X + 12, Y + 67), V
    Circle (X + 67, Y - 6), 3, V: Paint (X + 67, Y - 6), V: Circle (X + 67, Y + 6), 3, V: Paint (X + 67, Y + 6), V: Circle (X + 67, Y - 18), 3, V: Paint (X + 67, Y - 18), V: Circle (X + 67, Y + 18), 3, V: Paint (X + 67, Y + 18), V

    Circle (X - 30, Y - 30), 30, 0, 1.3, 3.3: Circle (X + 30, Y - 30), 30, 0, 0, 1.8: Circle (X - 30, Y + 30), 30, 0, 2.9, 4.8: Circle (X + 30, Y + 30), 30, 0, 4.4, 0
    Line (X - 30, Y - 60)-(X + 30, Y - 60), 0: Line (X - 30, Y + 60)-(X + 30, Y + 60), 0: Line (X - 60, Y - 30)-(X - 60, Y + 30), 0: Line (X + 60, Y - 30)-(X + 60, Y + 30), 0: Paint (X, Y), 0

    U = Y - 51: W = 0
    For Z = 1 To 7
        T = X - 51
        For V = 1 To 7
            If Z = 1 Or Z = 3 Or Z = 5 Or Z = 7 Then
                If V = 2 Or V = 4 Or V = 6 Then
                    W = W + 1: S = CardPattern(Card, W): R = LevelColor(S)
                    If S > 0 Then Circle (T, U + 15), 20, R, .82, 2.33: Circle (T, U - 15), 20, R, 3.97, 5.454: Paint (T, U), R
                End If
            Else
                If V = 1 Or V = 3 Or V = 5 Or V = 7 Then
                    W = W + 1: S = CardPattern(Card, W): R = LevelColor(S)
                    If S > 0 Then Circle (T + 15, U), 20, R, 2.36, 3.93: Circle (T - 15, U), 20, R, 5.5, .771: Paint (T, U), R
                End If
            End If
            T = T + 17:
        Next
        U = U + 17
    Next

End Sub

Sub DrawButtons

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 15, 0: font& = _LoadFont(BoldFont$, 30): _Font font&

    ' Restart Puzzle
    Circle (873, 561), 21, 0, 1.4, 4.8: Circle (989, 561), 21, 0, 4.4, 1.6: Line (873, 540)-(989, 540), 0: Line (873, 582)-(989, 582), 0: Paint (873, 561), 0
    _UPrintString (888, 548), "Restart"

    ' Change Puzzle
    Circle (1061, 561), 21, 0, 1.4, 4.8: Circle (1177, 561), 21, 0, 4.4, 1.6: Line (1061, 540)-(1177, 540), 0: Line (1061, 582)-(1177, 582), 0: Paint (1061, 561), 0
    _UPrintString (1088, 548), "New"

    ' Exit Puzzle
    Circle (779, 634), 21, 0, 1.4, 4.8: Circle (895, 634), 21, 0, 4.4, 1.6: Line (779, 613)-(895, 613), 0: Line (779, 655)-(895, 655), 0: Paint (779, 634), 0
    _UPrintString (811, 621), "Exit"

    ' Load Puzzle
    Circle (967, 634), 21, 0, 1.4, 4.8: Circle (1083, 634), 21, 0, 4.4, 1.6: Line (967, 613)-(1083, 613), 0: Line (967, 655)-(1083, 655), 0: Paint (967, 634), 0
    _UPrintString (997, 621), "Load"

    ' Save Puzzle
    Circle (1155, 634), 21, 0, 1.4, 4.8: Circle (1271, 634), 21, 0, 4.4, 1.6: Line (1155, 613)-(1271, 613), 0: Line (1155, 655)-(1271, 655), 0: Paint (1155, 634), 0
    _UPrintString (1187, 621), "Save"

End Sub

Sub RotateTiles (Knob, Rotation)

    Dim As _Byte Temp

    Select Case Knob

        Case 1
            If Rotation = 1 Then

                Temp = Tile(1):
                Tile(1) = Tile(4): Paint (TileX(1), TileY(1)), LevelColor(Tile(1)), 1
                Tile(4) = Tile(8): Paint (TileX(4), TileY(4)), LevelColor(Tile(4)), 1
                Tile(8) = Tile(5): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(5) = Temp: Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
            Else
                Temp = Tile(1):
                Tile(1) = Tile(5): Paint (TileX(1), TileY(1)), LevelColor(Tile(1)), 1
                Tile(5) = Tile(8): Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
                Tile(8) = Tile(4): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(4) = Temp: Paint (TileX(4), TileY(4)), LevelColor(Tile(4)), 1
            End If

        Case 2

            If Rotation = 1 Then
                Temp = Tile(2):
                Tile(2) = Tile(5): Paint (TileX(2), TileY(2)), LevelColor(Tile(2)), 1
                Tile(5) = Tile(9): Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
                Tile(9) = Tile(6): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(6) = Temp: Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
            Else
                Temp = Tile(2):
                Tile(2) = Tile(6): Paint (TileX(2), TileY(2)), LevelColor(Tile(2)), 1
                Tile(6) = Tile(9): Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
                Tile(9) = Tile(5): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(5) = Temp: Paint (TileX(5), TileY(5)), LevelColor(Tile(5)), 1
            End If

        Case 3

            If Rotation = 1 Then
                Temp = Tile(3):
                Tile(3) = Tile(6): Paint (TileX(3), TileY(3)), LevelColor(Tile(3)), 1
                Tile(6) = Tile(10): Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
                Tile(10) = Tile(7): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(7) = Temp: Paint (TileX(7), TileY(7)), LevelColor(Tile(7)), 1
            Else
                Temp = Tile(3):
                Tile(3) = Tile(7): Paint (TileX(3), TileY(3)), LevelColor(Tile(3)), 1
                Tile(7) = Tile(10): Paint (TileX(7), TileY(7)), LevelColor(Tile(7)), 1
                Tile(10) = Tile(6): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(6) = Temp: Paint (TileX(6), TileY(6)), LevelColor(Tile(6)), 1
            End If

        Case 4

            If Rotation = 1 Then
                Temp = Tile(8):
                Tile(8) = Tile(11): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(11) = Tile(15): Paint (TileX(11), TileY(11)), LevelColor(Tile(11)), 1
                Tile(15) = Tile(12): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(12) = Temp: Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
            Else
                Temp = Tile(8):
                Tile(8) = Tile(12): Paint (TileX(8), TileY(8)), LevelColor(Tile(8)), 1
                Tile(12) = Tile(15): Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
                Tile(15) = Tile(11): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(11) = Temp: Paint (TileX(11), TileY(11)), LevelColor(Tile(11)), 1
            End If

        Case 5

            If Rotation = 1 Then
                Temp = Tile(9):
                Tile(9) = Tile(12): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(12) = Tile(16): Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
                Tile(16) = Tile(13): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(13) = Temp: Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
            Else
                Temp = Tile(9):
                Tile(9) = Tile(13): Paint (TileX(9), TileY(9)), LevelColor(Tile(9)), 1
                Tile(13) = Tile(16): Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
                Tile(16) = Tile(12): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(12) = Temp: Paint (TileX(12), TileY(12)), LevelColor(Tile(12)), 1
            End If

        Case 6

            If Rotation = 1 Then
                Temp = Tile(10):
                Tile(10) = Tile(13): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(13) = Tile(17): Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
                Tile(17) = Tile(14): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(14) = Temp: Paint (TileX(14), TileY(14)), LevelColor(Tile(14)), 1
            Else
                Temp = Tile(10):
                Tile(10) = Tile(14): Paint (TileX(10), TileY(10)), LevelColor(Tile(10)), 1
                Tile(14) = Tile(17): Paint (TileX(14), TileY(14)), LevelColor(Tile(14)), 1
                Tile(17) = Tile(13): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(13) = Temp: Paint (TileX(13), TileY(13)), LevelColor(Tile(13)), 1
            End If

        Case 7

            If Rotation = 1 Then
                Temp = Tile(15):
                Tile(15) = Tile(18): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(18) = Tile(22): Paint (TileX(18), TileY(18)), LevelColor(Tile(18)), 1
                Tile(22) = Tile(19): Paint (TileX(22), TileY(22)), LevelColor(Tile(22)), 1
                Tile(19) = Temp: Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
            Else
                Temp = Tile(15):
                Tile(15) = Tile(19): Paint (TileX(15), TileY(15)), LevelColor(Tile(15)), 1
                Tile(19) = Tile(22): Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
                Tile(22) = Tile(18): Paint (TileX(22), TileY(22)), LevelColor(Tile(22)), 1
                Tile(18) = Temp: Paint (TileX(18), TileY(18)), LevelColor(Tile(18)), 1
            End If

        Case 8

            If Rotation = 1 Then
                Temp = Tile(16):
                Tile(16) = Tile(19): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(19) = Tile(23): Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
                Tile(23) = Tile(20): Paint (TileX(23), TileY(23)), LevelColor(Tile(23)), 1
                Tile(20) = Temp: Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
            Else
                Temp = Tile(16):
                Tile(16) = Tile(20): Paint (TileX(16), TileY(16)), LevelColor(Tile(16)), 1
                Tile(20) = Tile(23): Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
                Tile(23) = Tile(19): Paint (TileX(23), TileY(23)), LevelColor(Tile(23)), 1
                Tile(19) = Temp: Paint (TileX(19), TileY(19)), LevelColor(Tile(19)), 1
            End If

        Case 9

            If Rotation = 1 Then
                Temp = Tile(17):
                Tile(17) = Tile(20): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(20) = Tile(24): Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
                Tile(24) = Tile(21): Paint (TileX(24), TileY(24)), LevelColor(Tile(24)), 1
                Tile(21) = Temp: Paint (TileX(21), TileY(21)), LevelColor(Tile(21)), 1
            Else
                Temp = Tile(17):
                Tile(17) = Tile(21): Paint (TileX(17), TileY(17)), LevelColor(Tile(17)), 1
                Tile(21) = Tile(24): Paint (TileX(21), TileY(21)), LevelColor(Tile(21)), 1
                Tile(24) = Tile(20): Paint (TileX(24), TileY(24)), LevelColor(Tile(24)), 1
                Tile(20) = Temp: Paint (TileX(20), TileY(20)), LevelColor(Tile(20)), 1
            End If

    End Select

End Sub

Function CheckTiles (Card)

    Dim As _Byte X, Z: X = 0

    For Z = 1 To 24
        If Tile(Z) = CardPattern(Card, Z) Then X = X + 1
    Next

    If X = 24 Then CheckTiles = 1 Else CheckTiles = 0

End Function

Function EndPuzzle

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (860, 685), Space$(250): _UPrintString (870, 713), "     End this Puzzle?  Y or N    "

    YorN: A$ = UCase$(InKey$): If A$ = "" Then GoTo YorN
    If Asc(A$) = 27 And FullScreen = 0 Then FullScreen = -1: _FullScreen _SquarePixels , _Smooth Else If Asc(A$) = 27 Then FullScreen = 0: _FullScreen _Off
    If A$ = "Y" Then EndPuzzle = 1: GoTo EndSub
    If A$ = "N" Then EndPuzzle = 0: GoTo EndSub
    GoTo YorN

    EndSub: Color 0, 15: _UPrintString (870, 713), Space$(250)

End Function

Sub SetupPuzzle

    For Z = 1 To 24: Tile(Z) = CardPattern(StartCard, Z): Next: Moves = 0

End Sub

Sub DisplayPuzzle

    Dim As _Byte Z: Dim As Integer X

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 25): _Font font&
    If Level = 1 Then _UPrintString (883, 60), "L E V E L  1:  B E G I N N E R"
    If Level = 2 Then _UPrintString (850, 60), "L E V E L  2:  I N T E R M E D I A T E"
    If Level = 3 Then _UPrintString (883, 60), "L E V E L  3:  A D V A N C E D"
    If Level = 4 Then _UPrintString (905, 60), "L E V E L  4:  E X P E R T"

    Line (795, 110)-(955, 270), 15, BF: DrawCard 875, 190, StartCard
    Line (1097, 110)-(1257, 270), 15, BF: DrawCard 1177, 190, EndCard

    If Moves < 10 Then X = 970 Else X = 935
    Color LevelColor(Level), 15: font& = _LoadFont(BoldFont$, 120): _Font font&: _UPrintString (X, 410), Str$(Moves)

    For Z = 1 To 24: Paint (TileX(Z), TileY(Z)), LevelColor(Tile(Z)), 2: Next

End Sub

Sub PuzzleMessage

    BoldFont$ = Environ$("SYSTEMROOT") + "\fonts\Calibrib.ttf"

    Color 0, 15: font& = _LoadFont(BoldFont$, 25): _Font font&: _UPrintString (885, 685), "Your Puzzle has been Saved": _UPrintString (890, 713), "Press <ENTER> to Continee"

    Enter2: A$ = InKey$: If A$ = "" GoTo Enter2 Else If Asc(A$) <> 13 GoTo Enter2

    _UPrintString (885, 685), Space$(300): _UPrintString (890, 713), Space$(300)

End Sub



RE: Twizzle Logic Puzzle Game - PhilOfPerth - 05-30-2025

(05-29-2025, 10:36 PM)Donald Foster Wrote: PhilOfPerth, the purpose of line 330 in continue the input loop back to the top of the loop. I gets input from the mouse and keyboard. I removed it and it bypassed the input question to choose the rotation.

Hi Donald.
That's what I was trying to say... it removes the need to press the rotate-directions buttons, and the need to re-select the group for each rotation. Personally, I found it easier to play with this change.  Smile



RE: Twizzle Logic Puzzle Game - bplus - 05-30-2025

+1 I think you are speaking of same issue I had playing the game and always having to reset which dial to rotate. They should toggle with mouse click when you want to change the white circle signal.