06-09-2024, 03:26 AM
Try #2: I think this matches the color scheme fairly well, and it replaces the missing reverse triangle which I'd overlooked. (One color doesn't seem to match 100%, and that's the Purple. I'm using the HTML purple, but the shade seems off from whatever you used for your own purple. Without looking at your source, I don't think I'll be able to get the _RGB32 values to match perfectly.)
As I mentioned, taking all the fancy math out of CircleFill here reduced this down to now being 100-line program -- and that's even after adding in the logic for the missing reverse triangle.
Also read the instructions a little better. This now should also follow the same odds as what your game had -- 3 in 16 chance for 5 pieces to show up, 1 in 16 chance for that last double circle to appear.
Code: (Select All)
SCREEN _NEWIMAGE(340, 340, 32)
_TITLE "Slot Machine!"
RANDOMIZE TIMER
$COLOR:32
COLOR White, 0
Money = 300
DIM AS _FLOAT spin1, spin2, spin3
DO
CLS , DarkGray
CenterText 10, "ENTER TO SPIN! (You have $" + STR$(Money) + ")"
CenterText 140, "PAYOUTS"
CenterText 160, "Three Double Circles -- 500"
CenterText 180, "Three Squares -- 25"
CenterText 200, "Three Triangles -- 25"
CenterText 220, "Three Circles -- 25"
CenterText 240, "Two Circles -- 10"
CenterText 260, "Three Diamonds -- 10"
CenterText 280, "Two Diamonds -- 5"
CenterText 300, "One Diamond -- 1"
DO: a$ = INPUT$(1): LOOP UNTIL a$ = CHR$(13) OR a$ = CHR$(27)
IF a$ = CHR$(27) THEN SYSTEM
LINE (0, 0)-(340, 340), DarkGray, BF
spin1 = TIMER + RND * 2 + 1: spin2 = RND * 2 + 1 + spin1: spin3 = RND * 2 + 1 + spin2
DO
finished = -1
IF spin1 > TIMER THEN slot1 = Slot(INT(RND * 16)): DrawSlot 0, slot1
IF spin2 > TIMER THEN slot2 = Slot(INT(RND * 16)): DrawSlot 1, slot2
IF spin3 > TIMER THEN slot3 = Slot(INT(RND * 16)): DrawSlot 2, slot3: finished = 0
_LIMIT 10
_DISPLAY
LOOP UNTIL finished
_AUTODISPLAY
win = -10 'the "ante" of $10 to spin.
IF slot1 = slot2 AND slot2 = slot3 THEN 'three of a kind!
SELECT CASE slot1
CASE 1: win = 250 '3 circles
CASE 2: win = 250 '3 triangles
CASE 3: win = 100 '3 diamonds
CASE 4: win = 100 '3 reverse triangles
CASE 5: win = 250 '3 squares
CASE 6: win = 5000 '3 double circles
END SELECT
END IF
diamond = 0: circles = 0
IF slot1 = 3 THEN diamond = diamond + 1 ELSE IF slot1 = 1 THEN circles = circles + 1
IF slot2 = 3 THEN diamond = diamond + 1 ELSE IF slot2 = 1 THEN circles = circles + 1
IF slot3 = 3 THEN diamond = diamond + 1 ELSE IF slot3 = 1 THEN circles = circles + 1
IF diamond = 1 THEN win = 10 ELSE IF diamond = 2 THEN win = 50 '1 diamond or 2 diamond
IF circles = 2 THEN win = 100 '2 circles
IF win < 0 THEN CenterText 250, "Sorry. No Match. You lose." ELSE CenterText 250, "Congrats! You win!"
Money = Money + win
_KEYCLEAR: SLEEP: _DELAY .5: _KEYCLEAR
LOOP
SUB DrawSlot (where, what)
LINE (10 + 110 * where, 50)-STEP(100, 100), Black, BF
w = 110 * where
SELECT CASE what
CASE 1: CircleFill 60 + w, 100, 50, Red 'circle
CASE 2: FillTriangle 60 + w, 50, 10 + w, 150, 110 + w, 150, Yellow 'up triangle
CASE 3: FillQuad 60 + w, 50, 10 + w, 100, 60 + w, 150, 110 + w, 100, Green 'diamond
CASE 4: FillTriangle 60 + w, 150, 10 + w, 50, 110 + w, 50, Purple 'down triangle
CASE 5: LINE (20 + 110 * where, 60)-STEP(80, 80), Blue, BF: 'square
CASE 6: CircleFill 60 + w, 100, 50, Cyan: CircleFill 60 + w, 100, 25, Blue 'double circle
END SELECT
END SUB
FUNCTION Slot (roll AS INTEGER)
SELECT CASE roll
CASE 0 TO 2: Slot = 1
CASE 3 TO 5: Slot = 2
CASE 6 TO 8: Slot = 3
CASE 9 TO 11: Slot = 4
CASE 13 TO 15: Slot = 5
CASE ELSE: Slot = 6
END SELECT
END FUNCTION
SUB CenterText (y, text$)
l = _PRINTWIDTH(text$)
w = _WIDTH
x = (w - l) \ 2
_PRINTSTRING (x, y), text$
END SUB
SUB FillTriangle (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
STATIC a&, m AS _MEM
IF a& = 0 THEN a& = _NEWIMAGE(1, 1, 32): m = _MEMIMAGE(a&)
_MEMPUT m, m.OFFSET, K
_MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
END SUB
SUB FillQuad (x1, y1, x2, y2, x3, y3, x4, y4, K AS _UNSIGNED LONG)
FillTriangle x1, y1, x2, y2, x3, y3, K
FillTriangle x3, y3, x4, y4, x1, y1, K
END SUB
SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
CIRCLE (CX, CY), R, C
PAINT (CX, CY), C
END SUB
As I mentioned, taking all the fancy math out of CircleFill here reduced this down to now being 100-line program -- and that's even after adding in the logic for the missing reverse triangle.
Also read the instructions a little better. This now should also follow the same odds as what your game had -- 3 in 16 chance for 5 pieces to show up, 1 in 16 chance for that last double circle to appear.