QB64 Phoenix Edition
Lesson's 10 Exercise (Partial solution) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Official Links (https://qb64phoenix.com/forum/forumdisplay.php?fid=16)
+--- Forum: Learning Resources and Archives (https://qb64phoenix.com/forum/forumdisplay.php?fid=13)
+---- Forum: Terry Ritchie's Tutorial (https://qb64phoenix.com/forum/forumdisplay.php?fid=14)
+---- Thread: Lesson's 10 Exercise (Partial solution) (/showthread.php?tid=2779)



Lesson's 10 Exercise (Partial solution) - marbac74 - 06-05-2024

Hello everyone,
I'm working on Lesson's 10 assignment...it's definitely more complicated than the previous ones  Sick I'm not finished with it yet, but I wanted to post the intermediate result, because there are a couple of things worth noticing: the exercise is full of tricks so make use of the wiki information...for example at line 49 in the code below...you need to use a semicolon otherwise some of your print statements will disappear from screen and you'll be left wondering why..."they were there ten minutes ago and now they don't show up anymore...but I didn't change anything so how can it be?". If you reach the end of screen you must add a semicolon to the last print statement to prevent...I don't remember the name but in order that everything shows up as it is written. Today I worked on the DrawSymbol subroutine and I'm quite happy with it, it works as expected, but I don't know if there is a more efficient way to code it... Here is the partial solution to the exercise:
Code: (Select All)

SCREEN _NEWIMAGE(340, 340, 32)
_TITLE "Slot Machine"

CONST RED = _RGB32(255, 0, 0)
CONST GREEN = _RGB32(0, 255, 0)
CONST BLUE = _RGB32(0, 0, 255)
CONST PURPLE = _RGB32(255, 0, 255)
CONST YELLOW = _RGB32(255, 255, 0)
CONST CYAN = _RGB32(0, 255, 255)
CONST BLACK = _RGB32(0)
CONST GREY = _RGB32(70)

DIM Score%

Score% = 0

PAINT (170, 170), GREY
_PRINTMODE _KEEPBACKGROUND
LOCATE 1, 16
COLOR YELLOW: PRINT "SLOT MACHINE"

LINE (10, 20)-(110, 120), BLACK, BF
DrawSymbol "DIAMOND", 1
LINE (120, 20)-(220, 120), BLACK, BF
DrawSymbol "DIAMOND", 2
LINE (230, 20)-(330, 120), BLACK, BF
DrawSymbol "DIAMOND", 3

LOCATE 9, 2
COLOR YELLOW: PRINT "ENTER to spin"; SPC(7); Score%; SPC(7); "ESC to exit"
LOCATE 11, 18
PRINT "PAYOUTS"
LOCATE 13, 10
COLOR YELLOW: PRINT "3 Double Circles - 500"
LOCATE 14, 10
COLOR YELLOW: PRINT "3 Squares        -  25"
LOCATE 15, 10
COLOR YELLOW: PRINT "3 Triangles      -  25"
LOCATE 16, 10
COLOR YELLOW: PRINT "3 Circles        -  25"
LOCATE 17, 10
COLOR YELLOW: PRINT "2 Circles        -  10"
LOCATE 18, 10
COLOR YELLOW: PRINT "3 Diamonds      -  10"
LOCATE 19, 10
COLOR YELLOW: PRINT "2 Diamonds      -  5"
LOCATE 20, 10
COLOR YELLOW: PRINT "1 Diamond        -  1";
SLEEP

SUB DrawSymbol (Figure$, Box%)
    IF Figure$ = "SQUARE" AND Box% = 1 THEN
        LINE (20, 30)-(100, 110), BLUE, BF
    ELSEIF Figure$ = "SQUARE" AND Box% = 2 THEN
        LINE (130, 30)-(210, 110), BLUE, BF
    ELSEIF Figure$ = "SQUARE" AND Box% = 3 THEN
        LINE (240, 30)-(320, 110), BLUE, BF
    ELSEIF Figure$ = "CIRCLE" AND Box% = 1 THEN
        CIRCLE (60, 70), 40, RED
        PAINT (60, 70), RED, RED
    ELSEIF Figure$ = "CIRCLE" AND Box% = 2 THEN
        CIRCLE (170, 70), 40, RED
        PAINT (170, 70), RED, RED
    ELSEIF Figure$ = "CIRCLE" AND Box% = 3 THEN
        CIRCLE (280, 70), 40, RED
        PAINT (280, 70), RED, RED
    ELSEIF Figure$ = "SPECIAL" AND Box% = 1 THEN
        CIRCLE (60, 70), 40, CYAN
        PAINT (60, 70), CYAN, CYAN
        CIRCLE (60, 70), 20, BLUE
        PAINT (60, 70), BLUE, BLUE
    ELSEIF Figure$ = "SPECIAL" AND Box% = 2 THEN
        CIRCLE (170, 70), 40, CYAN
        PAINT (170, 70), CYAN, CYAN
        CIRCLE (170, 70), 20, BLUE
        PAINT (170, 70), BLUE, BLUE
    ELSEIF Figure$ = "SPECIAL" AND Box% = 3 THEN
        CIRCLE (280, 70), 40, CYAN
        PAINT (280, 70), CYAN, CYAN
        CIRCLE (280, 70), 20, BLUE
        PAINT (280, 70), BLUE, BLUE
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 1 THEN
        LINE (20, 110)-(100, 110), YELLOW
        LINE -(60, 30), YELLOW
        LINE -(20, 110), YELLOW
        PAINT (60, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 2 THEN
        LINE (130, 110)-(210, 110), YELLOW
        LINE -(170, 30), YELLOW
        LINE -(130, 110), YELLOW
        PAINT (170, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 3 THEN
        LINE (240, 110)-(320, 110), YELLOW
        LINE -(280, 30), YELLOW
        LINE -(240, 110), YELLOW
        PAINT (280, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 1 THEN
        LINE (20, 30)-(100, 30), PURPLE
        LINE -(60, 110), PURPLE
        LINE -(20, 30), PURPLE
        PAINT (60, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 2 THEN
        LINE (130, 30)-(210, 30), PURPLE
        LINE -(170, 110), PURPLE
        LINE -(130, 30), PURPLE
        PAINT (170, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 3 THEN
        LINE (240, 30)-(320, 30), PURPLE
        LINE -(280, 110), PURPLE
        LINE -(240, 30), PURPLE
        PAINT (280, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DIAMOND" AND Box% = 1 THEN
        LINE (60, 110)-(100, 70), GREEN
        LINE -(60, 30), GREEN
        LINE -(20, 70), GREEN
        LINE -(60, 110), GREEN
        PAINT (60, 70), GREEN, GREEN
    ELSEIF Figure$ = "DIAMOND" AND Box% = 2 THEN
        LINE (170, 110)-(210, 70), GREEN
        LINE -(170, 30), GREEN
        LINE -(130, 70), GREEN
        LINE -(170, 110), GREEN
        PAINT (170, 70), GREEN, GREEN
    ELSEIF Figure$ = "DIAMOND" AND Box% = 3 THEN
        LINE (280, 110)-(320, 70), GREEN
        LINE -(280, 30), GREEN
        LINE -(240, 70), GREEN
        LINE -(280, 110), GREEN
        PAINT (280, 70), GREEN, GREEN
    END IF
END SUB



RE: Lesson's 10 Exercise (Partial solution) - TerryRitchie - 06-05-2024

You're on the right track. Your DrawSymbol subroutine is passing two values in a very similar manner as the solution does. You also figured out why I mentioned the use of a semicolon (hint hint) after a PRINT statement may be helpful in the directions.  Keep going!


RE: Lesson's 10 Exercise (Partial solution) - marbac74 - 06-07-2024

(06-05-2024, 04:12 PM)TerryRitchie Wrote: You're on the right track. Your DrawSymbol subroutine is passing two values in a very similar manner as the solution does. You also figured out why I mentioned the use of a semicolon (hint hint) after a PRINT statement may be helpful in the directions.  Keep going!
I'm almost there...it took me many more lines of code in comparison to your solution (240/250 I don't remember exactly now) but that was never a goal. It ALMOST works...I mean it works, but I want some time to check it a little bit more in order to be sure or at least more sure than I am now Smile 
I had a long struggle to understand how to update the Score% variable and print it on screen fresh instead of overwriting the previous value without deleting it and therefore quickly getting unreadable...that issue at least is now solved (but I don't think the solution I found is elegant...I'm pretty sure there are better ways). I'll post the code after a little bit of revision


RE: Lesson's 10 Exercise (Partial solution) - marbac74 - 06-08-2024

Well, that's today's state-of-the-art version. I'm partially happy with this, but not completely. There is no blinking "WINNER" print statement, but that would be a minor detail. It kind of works, but from time to time the second wheel's box gets black without showing the symbol, I can't understand why. The programs makes use of three distinct loops while I saw your solution used one, which makes the code shorter and possibly more efficient. That is my result, not optimal, but I'm gonna stop today and come back maybe in the next days to try to improve it.

PS: At least I found the problem with WHEEL2: It was a misspelling of DOWNTRIANGLE which I wrote as DOWNTRIAMGLE. No surprise that the symbol was not drawn Big Grin
Code: (Select All)
SCREEN _NEWIMAGE(340, 340, 32)
_TITLE "Slot Machine"

CONST RED = _RGB32(255, 0, 0)
CONST GREEN = _RGB32(0, 255, 0)
CONST BLUE = _RGB32(0, 0, 255)
CONST PURPLE = _RGB32(255, 0, 255)
CONST YELLOW = _RGB32(255, 255, 0)
CONST CYAN = _RGB32(0, 255, 255)
CONST BLACK = _RGB32(0)
CONST GREY = _RGB32(70)

DIM SHARED Wheel1$(15)
Wheel1$(0) = "SQUARE": Wheel1$(1) = "CIRCLE": Wheel1$(2) = "DIAMOND": Wheel1$(3) = "UPTRIANGLE"
Wheel1$(4) = "DOWNTRIANGLE": Wheel1$(5) = "SQUARE": Wheel1$(6) = "CIRCLE": Wheel1$(7) = "DIAMOND"
Wheel1$(8) = "UPTRIANGLE": Wheel1$(9) = "DOWNTRIANGLE": Wheel1$(10) = "SQUARE": Wheel1$(11) = "CIRCLE"
Wheel1$(12) = "DIAMOND": Wheel1$(13) = "UPTRIANGLE": Wheel1$(14) = "DOWNTRIANGLE": Wheel1$(15) = "SPECIAL"

DIM SHARED Wheel2$(15)
Wheel2$(0) = "CIRCLE": Wheel2$(1) = "DIAMOND": Wheel2$(2) = "DOWNTRIANGLE": Wheel2$(3) = "SQUARE"
Wheel2$(4) = "UPTRIANGLE": Wheel2$(5) = "CIRCLE": Wheel2$(6) = "DIAMOND": Wheel2$(7) = "DOWNTRIAMGLE"
Wheel2$(8) = "SQUARE": Wheel2$(9) = "UPTRIANGLE": Wheel2$(10) = "CIRCLE": Wheel2$(11) = "DIAMOND"
Wheel2$(12) = "DOWNTRIANGLE": Wheel2$(13) = "SQUARE": Wheel2$(14) = "UPTRIANGLE": Wheel2$(15) = "SPECIAL"

DIM SHARED Wheel3$(15)
Wheel3$(0) = "UPTRIANGLE": Wheel3$(1) = "CIRCLE": Wheel3$(2) = "DIAMOND": Wheel3$(3) = "SQUARE"
Wheel3$(4) = "DOWNTRIANGLE": Wheel3$(5) = "UPTRIANGLE": Wheel3$(6) = "CIRCLE": Wheel3$(7) = "DIAMOND"
Wheel3$(8) = "SQUARE": Wheel3$(9) = "DOWNTRIANGLE": Wheel3$(10) = "UPTRIANGLE": Wheel3$(11) = "CIRCLE"
Wheel3$(12) = "DIAMOND": Wheel3$(13) = "SQUARE": Wheel3$(14) = "DOWNTRIANGLE": Wheel3$(15) = "SPECIAL"

DIM SHARED Outcome$(2)

DIM SHARED Special$(2)
Special$(0) = "SPECIAL": Special$(1) = "SPECIAL": Special$(2) = "SPECIAL"
DIM SHARED Square$(2)
Square$(0) = "SQUARE": Square$(1) = "SQUARE": Square$(2) = "SQUARE"
DIM SHARED Circle$(2)
Circle$(0) = "CIRCLE": Circle$(1) = "CIRCLE": Circle$(2) = "CIRCLE"
DIM SHARED Diamond$(2)
Diamond$(0) = "DIAMOND": Diamond$(1) = "DIAMOND": Diamond$(2) = "DIAMOND"
DIM SHARED UpTriangle$(2)
UpTriangle$(0) = "UPTRIANGLE": UpTriangle$(1) = "UPTRIANGLE": UpTriangle$(2) = "UPTRIANGLE"
DIM SHARED DownTriangle$(2)
DownTriangle$(0) = "DOWNTRIANGLE": DownTriangle$(1) = "DOWNTRIANGLE": DownTriangle$(2) = "DOWNTRIANGLE"

DIM SHARED Score%

CLS , GREY
LINE (10, 20)-(110, 120), BLACK, BF
DrawSymbol "SPECIAL", 1
LINE (120, 20)-(220, 120), BLACK, BF
DrawSymbol "SPECIAL", 2
LINE (230, 20)-(330, 120), BLACK, BF
DrawSymbol "SPECIAL", 3

DO
    _PRINTMODE _KEEPBACKGROUND
    LOCATE 1, 16
    COLOR YELLOW: PRINT "SLOT MACHINE"
    LOCATE 9, 2
    COLOR YELLOW: PRINT "ENTER to spin"; TAB(21); Score%; TAB(32); "ESC to exit"
    LOCATE 11, 18
    PRINT "PAYOUTS"
    LOCATE 13, 10
    COLOR YELLOW: PRINT "3 Double Circles - 250"
    LOCATE 14, 10
    COLOR YELLOW: PRINT "3 Squares        -  25"
    LOCATE 15, 10
    COLOR YELLOW: PRINT "3 Triangles      -  25"
    LOCATE 16, 10
    COLOR YELLOW: PRINT "3 Circles        -  25"
    LOCATE 17, 10
    COLOR YELLOW: PRINT "2 Circles        -  10"
    LOCATE 18, 10
    COLOR YELLOW: PRINT "3 Diamonds      -  10"
    LOCATE 19, 10
    COLOR YELLOW: PRINT "2 Diamonds      -  5"
    LOCATE 20, 10
    COLOR YELLOW: PRINT "1 Diamond        -  1";

    KeyPressed$ = INKEY$
    IF KeyPressed$ = CHR$(13) THEN
        Score% = Score% - 1
        RANDOMIZE TIMER

        Wheel1% = INT(RND * 10 + 10)
        Index% = 0
        FOR C = 0 TO Wheel1%
            IF Index% < 16 THEN
                Outcome$(0) = Wheel1$(Index%)
                LINE (10, 20)-(110, 120), BLACK, BF
                DrawSymbol Wheel1$(Index%), 1
                LINE (120, 20)-(220, 120), BLACK, BF
                DrawSymbol Wheel2$(Index%), 2
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            ELSEIF Index% = 16 THEN
                Index% = 0
                Outcome$(0) = Wheel1$(Index%)
                LINE (10, 20)-(110, 120), BLACK, BF
                DrawSymbol Wheel1$(Index%), 1
                LINE (120, 20)-(220, 120), BLACK, BF
                DrawSymbol Wheel2$(Index%), 2
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            END IF
        NEXT C

        Wheel2% = INT(RND * 20 + 15)
        Index% = 0
        FOR C = 0 TO Wheel2%
            IF Index% < 16 THEN
                Outcome$(1) = Wheel2$(Index%)
                LINE (120, 20)-(220, 120), BLACK, BF
                DrawSymbol Wheel2$(Index%), 2
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            ELSE
                Index% = 0
                Outcome$(1) = Wheel2$(Index%)
                LINE (120, 20)-(220, 120), BLACK, BF
                DrawSymbol Wheel2$(Index%), 2
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            END IF
        NEXT C

        Wheel3% = INT(RND * 20 + 15)
        Index% = 0
        FOR C = 0 TO Wheel3%
            IF Index% < 16 THEN
                Outcome$(2) = Wheel3$(Index%)
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            ELSE
                Index% = 0
                Outcome$(2) = Wheel3$(Index%)
                LINE (230, 20)-(330, 120), BLACK, BF
                DrawSymbol Wheel3$(Index%), 3
                _DELAY .1
                Index% = Index% + 1
            END IF
        NEXT C
        Score% = CalculateScore%
        CLS , GREY
        LINE (10, 20)-(110, 120), BLACK, BF
        DrawSymbol Outcome$(0), 1
        LINE (120, 20)-(220, 120), BLACK, BF
        DrawSymbol Outcome$(1), 2
        LINE (230, 20)-(330, 120), BLACK, BF
        DrawSymbol Outcome$(2), 3
    END IF
LOOP UNTIL KeyPressed$ = CHR$(27)
SYSTEM

SUB DrawSymbol (Figure$, Box%)
    IF Figure$ = "SQUARE" AND Box% = 1 THEN
        LINE (20, 30)-(100, 110), BLUE, BF
    ELSEIF Figure$ = "SQUARE" AND Box% = 2 THEN
        LINE (130, 30)-(210, 110), BLUE, BF
    ELSEIF Figure$ = "SQUARE" AND Box% = 3 THEN
        LINE (240, 30)-(320, 110), BLUE, BF
    ELSEIF Figure$ = "CIRCLE" AND Box% = 1 THEN
        CIRCLE (60, 70), 40, RED
        PAINT (60, 70), RED, RED
    ELSEIF Figure$ = "CIRCLE" AND Box% = 2 THEN
        CIRCLE (170, 70), 40, RED
        PAINT (170, 70), RED, RED
    ELSEIF Figure$ = "CIRCLE" AND Box% = 3 THEN
        CIRCLE (280, 70), 40, RED
        PAINT (280, 70), RED, RED
    ELSEIF Figure$ = "SPECIAL" AND Box% = 1 THEN
        CIRCLE (60, 70), 40, CYAN
        PAINT (60, 70), CYAN, CYAN
        CIRCLE (60, 70), 20, BLUE
        PAINT (60, 70), BLUE, BLUE
    ELSEIF Figure$ = "SPECIAL" AND Box% = 2 THEN
        CIRCLE (170, 70), 40, CYAN
        PAINT (170, 70), CYAN, CYAN
        CIRCLE (170, 70), 20, BLUE
        PAINT (170, 70), BLUE, BLUE
    ELSEIF Figure$ = "SPECIAL" AND Box% = 3 THEN
        CIRCLE (280, 70), 40, CYAN
        PAINT (280, 70), CYAN, CYAN
        CIRCLE (280, 70), 20, BLUE
        PAINT (280, 70), BLUE, BLUE
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 1 THEN
        LINE (20, 110)-(100, 110), YELLOW
        LINE -(60, 30), YELLOW
        LINE -(20, 110), YELLOW
        PAINT (60, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 2 THEN
        LINE (130, 110)-(210, 110), YELLOW
        LINE -(170, 30), YELLOW
        LINE -(130, 110), YELLOW
        PAINT (170, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "UPTRIANGLE" AND Box% = 3 THEN
        LINE (240, 110)-(320, 110), YELLOW
        LINE -(280, 30), YELLOW
        LINE -(240, 110), YELLOW
        PAINT (280, 70), YELLOW, YELLOW
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 1 THEN
        LINE (20, 30)-(100, 30), PURPLE
        LINE -(60, 110), PURPLE
        LINE -(20, 30), PURPLE
        PAINT (60, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 2 THEN
        LINE (130, 30)-(210, 30), PURPLE
        LINE -(170, 110), PURPLE
        LINE -(130, 30), PURPLE
        PAINT (170, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DOWNTRIANGLE" AND Box% = 3 THEN
        LINE (240, 30)-(320, 30), PURPLE
        LINE -(280, 110), PURPLE
        LINE -(240, 30), PURPLE
        PAINT (280, 70), PURPLE, PURPLE
    ELSEIF Figure$ = "DIAMOND" AND Box% = 1 THEN
        LINE (60, 110)-(100, 70), GREEN
        LINE -(60, 30), GREEN
        LINE -(20, 70), GREEN
        LINE -(60, 110), GREEN
        PAINT (60, 70), GREEN, GREEN
    ELSEIF Figure$ = "DIAMOND" AND Box% = 2 THEN
        LINE (170, 110)-(210, 70), GREEN
        LINE -(170, 30), GREEN
        LINE -(130, 70), GREEN
        LINE -(170, 110), GREEN
        PAINT (170, 70), GREEN, GREEN
    ELSEIF Figure$ = "DIAMOND" AND Box% = 3 THEN
        LINE (280, 110)-(320, 70), GREEN
        LINE -(280, 30), GREEN
        LINE -(240, 70), GREEN
        LINE -(280, 110), GREEN
        PAINT (280, 70), GREEN, GREEN
    END IF
END SUB

FUNCTION CalculateScore% ()
    IF Outcome$(0) = Special$(0) AND Outcome$(1) = Special$(1) AND Outcome$(2) = Special$(2) THEN
        CalculateScore% = Score% + 250
    ELSEIF Outcome$(0) = Square$(0) AND Outcome$(1) = Square$(1) AND Outcome$(2) = Square$(2) THEN
        CalculateScore% = Score% + 25
    ELSEIF Outcome$(0) = Circle$(0) AND Outcome$(1) = Circle$(1) AND Outcome$(2) = Circle$(2) THEN
        CalculateScore% = Score% + 25
    ELSEIF Outcome$(0) = UpTriangle$(0) AND Outcome$(1) = UpTriangle$(1) AND Outcome$(2) = UpTriangle$(2) THEN
        CalculateScore% = Score% + 25
    ELSEIF Outcome$(0) = DownTriangle$(0) AND Outcome$(1) = DownTriangle$(1) AND Outcome$(2) = DownTriangle$(2) THEN
        CalculateScore% = Score% + 25
    ELSEIF Outcome$(0) = Diamond$(0) AND Outcome$(1) = Diamond$(1) AND Outcome$(2) = Diamond$(2) THEN
        CalculateScore% = Score% + 10
    ELSEIF Outcome$(0) = Circle$(0) AND Outcome$(1) = Circle$(1) OR Outcome$(0) = Circle$(0) AND Outcome$(2) = Circle$(2) OR Outcome$(1) = Circle$(1) AND Outcome$(2) = Circle$(2) THEN
        CalculateScore% = Score% + 10
    ELSEIF Outcome$(0) = Diamond$(0) AND Outcome$(1) = Diamond$(1) OR Outcome$(0) = Diamond$(0) AND Outcome$(2) = Diamond$(2) OR Outcome$(1) = Diamond$(1) AND Outcome$(2) = Diamond$(2) THEN
        CalculateScore% = Score% + 5
    ELSEIF Outcome$(0) = Diamond$(0) OR Outcome$(1) = Diamond$(1) OR Outcome$(2) = Diamond$(2) THEN
        CalculateScore% = Score% + 1
    ELSE
        CalculateScore% = Score%
    END IF
END FUNCTION



RE: Lesson's 10 Exercise (Partial solution) - TerryRitchie - 06-08-2024

Awesome! Your code ran just fine on my system. I only noticed one quirk while playing. During one of the wheel spins a symbol did not appear in the center window.

No comes the fun part - debugging! Yeah Smile

Your solution is very different from mine but it's supposed to be.

One suggestion that may help. You had to track down a misspelled variable. If you make the very first line of your code:

OPTION _EXPLICIT

that won't happen any longer. Any time you misspell a variable the IDE will warn you. In lesson 2 OPTION _EXPLICIT was explained and how it can be very beneficial to use it.