Hello everyone,
I'm working on Lesson's 10 assignment...it's definitely more complicated than the previous ones 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:
I'm working on Lesson's 10 assignment...it's definitely more complicated than the previous ones 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