Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Yahtzee Clone
#1
I've been writing Yahtzee type games since I was 13 (I'm 61 now), this is my latest written in qb64pe: (Download the zip below to get all the resource files)

Code: (Select All)

$ExeIcon:'./yahtzee.ico'
_Title "Yahtzee by David Coterel"
Screen _NewImage(664, 766, 32)
x = _DesktopWidth * .5 - 332: y = _DesktopHeight * .5 - 383
_ScreenMove x, y

Randomize (-Timer)

f& = _LoadFont("ydcdata\yont.ytz", 16) 'normal style
_Font f&

yh& = _LoadImage("YDCData\YHelp1.ytz", 32)
i1 = _LoadImage("YDCData\yscore.ytz", 32)
d(1) = _LoadImage("YDCData\D1.ytz", 32)
d(2) = _LoadImage("YDCData\D2.ytz", 32)
d(3) = _LoadImage("YDCData\D3.ytz", 32)
d(4) = _LoadImage("YDCData\D4.ytz", 32)
d(5) = _LoadImage("YDCData\D5.ytz", 32)
d(6) = _LoadImage("YDCData\D6.ytz", 32)
i2 = _LoadImage("YDCData\clear.ytz", 32)
i3 = _LoadImage("YDCData\end.ytz", 32)
r(1) = _LoadImage("YDCData\roll1.ytz", 32)
r(2) = _LoadImage("YDCData\roll2.ytz", 32)
r(3) = _LoadImage("YDCData\roll3.ytz", 32)
rll = _LoadImage("YDCData\roll.ytz", 32)
go = _LoadImage("YDCData\go.ytz", 32)
dice& = _SndOpen("YDCData\dice.ytz")
bep& = _SndOpen("YDCData\Beep.ytz")
er& = _SndOpen("YDCData\error.ytz")
che& = _SndOpen("YDCData\cheer.ytz")
sd1& = _SndOpen("YDCData\sd1.ytz")
sd2& = _SndOpen("YDCData\sd2.ytz")
cli& = _SndOpen("YDCData\click.ytz")
typ& = _SndOpen("YDCData\type.ytz")

Dim x(6), y(21), A$(12), S(6, 23), di(5)
Data 257,326,395,464,533,602
Data 103,129,155,181,207,233,259,285,311
Data 363,389,415,441,467,493,519,545,571,597,623,649
For t = 1 To 6: Read (x(t)): Next t
For t = 1 To 21: Read (y(t)): Next t
A$(0) = "R10U1L10U1R10L2U7R1D6R1U7L10U1R10U1L10D9R1U6R1D6"
A$(1) = "r10U1L10U1R10L4U10L1D9L1U9L2D1R1D1L1"
A$(2) = "R10U1L10U1R10L10U1R2U1L2U1R10U1L10U1R10U1L2U1R2U1L10U1R10U1L10"
A$(3) = "R10U1L10U1R10U1L2U1R2U1L5U1R5U1L5R3U1R2U1L2U1R2L10U1R10U1L10"
A$(4) = "BR8R2U1L2U1R2U1L2U1R2U1L10U1R10U1L10U5R1D4R1U4BR6R2D1L2D1R2D1L2D1R2"
A$(5) = "R10U1L10U1R10U1L2U1R2U1L10U1R10U1L10U1R2U1L2U1R10U1L10U1R10"
A$(6) = "R10U1L10U1R10U1L2U1R2U1L10D1R2D1L2U3R10U1L10U5R1D4R1U4"
A$(7) = "BR8R2U1L2U1R2U1L2U1R2U1L2U1R2U1L2U1R2U1L2U1R2L10U1R10U1L10D3R2"
A$(8) = "R10U1L10U1R10U1L2U1R2U1L10U1R10U1L10R10U1L2U1R2U1L10U1R10U1L10D9R1U6R1D6"
A$(9) = "BR8R2U1L2U1R2U1L2U1R2U1L10U1R10U1L10U1R2U1L2U1R10U1L10U1R10D4L1U1L1D1"
A$(10) = "BR1R10U1L10U1R10U1L10U1R10U1L10U1R10U1L10U1R10U1L10U1R10U1L10U1R10d12l10"
A$(11) = "BR3R2U1R1L4U1L1U1D1R1D1R3U2D2R1U7R1D4U8R1D3"
A$(12) = "BR1R2U1L2R5U1L2R5U1L2R5U1L2R5U1L2R12D1L2R5D1L2R5D1L2R5D1L2R5D1L2U1L3U1L3U1L3U1L3U1L1U1L6U1L3R12"
A$(12) = A$(12) + "U1L2R5U1L2R5U1L2R5U1L2R5U1L2D1L3D1L3D1L3D1L3D1L8U1L5U1R2L5U1R2L5U1R2L5U1R2"

Const RED = _RGB32(255, 0, 0)
Const BLUE = _RGB32(0, 0, 255)
Const BLACK = _RGB32(0, 0, 0)
Const GREEN = _RGB32(61, 200, 44)
Const WHITE = _RGB32(255, 255, 255)
Const PURPLE = _RGB32(155, 0, 222)
Const YELLOW = _RGB32(255, 255, 0)

On Error GoTo 5
Open "i", #2, "YDCData\YGData.ytz"
For x = 1 To 6: For y = 1 To 23: Input #2, S(x, y): Next y, x
For x = 1 To 5: Input #2, di(x): Next x
Input #2, roll
Input #2, n$
Close #2
dr = 1

5 If n$ = "" Then n$ = "Left Click to Enter"
_PutImage (0, 0), i1
For t = 0 To 5: _PutImage (100, 105 + t * 26)-(122, 127 + t * 26), d(t + 1): Next t
_PutImage (575, 692), i2
_PutImage (575, 724), i3
GoSub 1000

10 Rem * Start Game initial Roll of Dice
If dr <> 1 Then rd(1) = 1: rd(2) = 1: rd(3) = 1: rd(4) = 1: rd(5) = 1: roll = 1: GoSub 2000
If dr = 1 Then For t = 1 To 5: _PutImage (11 + ((t - 1) * 60), 698), d(di(t)): Next t
_PutImage (358, 690), r(roll): GoSub 3000

'x = 1: Y = 1: Do: Locate 1, 1: Print x, Y;: PSet (x, Y), _RGB(255, 0, 0): i$ = InKey$: If i$ = "8" Then Y = Y - 1 Else If i$ = "2" Then Y = Y + 1 Else If i$ = "4" Then x = x - 1 Else If i$ = "6" Then x = x + 1
'Loop

20 Rem * Get Mouse Input
Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 394 And m2 < 658 And m3 > 31 And m3 < 50 And m4 = -1 GoTo 100
If go1 = 1 And m2 > 608 And m2 < 665 And m3 > 0 And m3 < 26 And (m4 = -1 Or m5 = -1) Then _SndPlay cli&: GoTo 4000
If go1 = 1 And m2 > 235 And m2 < 651 And (m3 > 102 And m3 < 257 Or m3 > 361 And m3 < 546) And m5 = -1 Then _SndPlay cli&: GoTo 5000
If go1 = 1 And m2 > 237 And m2 < 650 And m3 > 102 And m3 < 257 And m4 = -1 GoTo 200
If go1 = 1 And m2 > 237 And m2 < 650 And m3 > 362 And m3 < 596 And m4 = -1 GoTo 300
If go1 = 1 And m2 > 10 And m2 < 301 And m3 > 697 And m3 < 748 And m4 = -1 GoTo 400
If go1 = 1 And m2 > 10 And m2 < 301 And m3 > 697 And m3 < 748 And m5 = -1 GoTo 500
If go1 = 1 And m2 > 394 And m2 < 406 And m3 > 709 And m3 < 725 And m4 = -1 Then rd(1) = 1: rd(2) = 1: rd(3) = 1: rd(4) = 1: rd(5) = 1: _SndPlay cli&: GoTo 500
If m2 > 574 And m2 < 650 And m3 > 724 And m3 < 753 And m4 = -1 Then _SndPlay cli&: GoTo 600
If m2 > 574 And m2 < 650 And m3 > 692 And m3 < 717 And m4 = -1 Then _SndPlay cli&: GoTo 700
GoTo 20

100 Rem * Enter Name
Color PURPLE, WHITE
n1$ = "": _SndPlay typ&: Locate 3, 460: Print "                          ";: Do Until InKey$ = "": Loop
110 Locate 3, 460: Print n1$; "?  ";: a$ = InKey$: If a$ <> "" Then 120
_Delay .2: Locate 3, 460: Print n1$; "  ";: a$ = InKey$: If a$ <> "" Then 120
_Delay .2: GoTo 110
120 Locate 3, 460: Print n1$; "  ";
If a$ >= "a" And a$ <= "z" And Len(n1$) < 20 Then n1$ = n1$ + a$: _SndPlay typ&: GoTo 110
If a$ >= "A" And a$ <= "Z" And Len(n1$) < 20 Then n1$ = n1$ + a$: _SndPlay typ&: GoTo 110
If a$ >= "0" And a$ <= "9" And Len(n1$) < 20 Then n1$ = n1$ + a$: _SndPlay typ&: GoTo 110
If a$ = " " And Len(n1$) < 20 Then n1$ = n1$ + " ": _SndPlay typ&: GoTo 110
If a$ = Chr$(8) And Len(n1$) > 0 Then n1$ = Left$(n1$, Len(n1$) - 1): _SndPlay typ&: GoTo 110
If a$ <> Chr$(13) GoTo 110
_SndPlay typ&: If Len(n1$) = 0 Then GoSub 1000: GoTo 20
n$ = n1$: GoSub 1000
GoTo 20

200 Rem * Upper Entry
x = Int((m2 - 238) / 69) + 1
y = Int((m3 - 103) / 26) + 1
For t = 1 To 6: d1(t) = 0: Next t
For t = 1 To 5: d1(di(t)) = d1(di(t)) + 1: Next t
If d1(y) = 0 And S(x, y) = 0 Then S(x, y) = -1: _SndPlay er&: GoSub 1000: roll = 1: dr = 0: GoTo 10
If S(x, y) = 0 Then S(x, y) = d1(y) * y: _SndPlay bep&: GoSub 1000: roll = 1: dr = 0: GoTo 10
GoTo 20

300 Rem * Lower Entry
x = Int((m2 - 238) / 69) + 1
y = Int((m3 - 363) / 26) + 10
For t = 1 To 6: d1(t) = 0: Next t: d1 = 0
For t = 1 To 5: d1(di(t)) = d1(di(t)) + 1: d1 = d1 + di(t): Next t
On y - 9 GOTO 310, 320, 330, 340, 350, 360, 370, 360, 360
310 If (d1(1) > 2 Or d1(2) > 2 Or d1(3) > 2 Or d1(4) > 2 Or d1(5) > 2 Or d1(6) > 2) And S(x, y) = 0 Then S(x, y) = d1: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
If S(x, y) = 0 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
320 If (d1(1) > 3 Or d1(2) > 3 Or d1(3) > 3 Or d1(4) > 3 Or d1(5) > 3 Or d1(6) > 3) And S(x, y) = 0 Then S(x, y) = d1: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
If S(x, y) = 0 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
330 d1 = 0: If d1(1) = 2 Or d1(2) = 2 Or d1(3) = 2 Or d1(4) = 2 Or d1(5) = 2 Or d1(6) = 2 Then d1 = 1
If d1(1) = 3 Or d1(2) = 3 Or d1(3) = 3 Or d1(4) = 3 Or d1(5) = 3 Or d1(6) = 3 Then d1 = d1 + 1
If d1 = 2 And S(x, y) = 0 Then S(x, y) = 25: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
If S(x, y) = 0 And d1 <> 2 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
340 d1 = 0: If d1(1) > 0 And d1(2) > 0 And d1(3) > 0 And d1(4) > 0 Then d1 = 1
If d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 Then d1 = 1
If d1(3) > 0 And d1(4) > 0 And d1(5) > 0 And d1(6) > 0 Then d1 = 1
If d1 = 1 And S(x, y) = 0 Then S(x, y) = 30: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
If d1 = 0 And S(x, y) = 0 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
350 d1 = 0: If d1(1) > 0 And d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 Then d1 = 1
If d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 And d1(6) > 0 Then d1 = 1
If d1 = 1 And S(x, y) = 0 Then S(x, y) = 40: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
If d1 = 0 And S(x, y) = 0 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
360 If y > 16 Then y = 15: If S(x, y) < 1 Then 20
d1 = 0: If d1(1) = 5 Or d1(2) = 5 Or d1(3) = 5 Or d1(4) = 5 Or d1(5) = 5 Or d1(6) = 5 Then d1 = 1
If d1 = 1 And S(x, y) = 0 Then S(x, y) = 50: roll = 1: dr = 0: _SndPlay che&: GoSub 1000: _Delay 2.5: GoTo 10
If d1 = 1 And S(x, y) = 50 And S(x, 17) <> 3 And (S(x, 1) = 0 Or S(x, 2) = 0 Or S(x, 3) = 3 Or S(x, 4) = 4 Or S(x, 5) = 0 Or S(x, 6) = 0 Or S(x, 10) = 0 Or S(x, 11) = 0 Or S(x, 12) = 0 Or S(x, 13) = 0 Or S(x, 14) = 0 Or S(x, 16) = 0) Then S(x, 17) = S(x, 17) + 1: roll = 1: dr = 0: _SndPlay che&: GoSub 1000: _Delay 2.5: GoTo 10
If d1 = 0 And S(x, y) = 0 Then S(x, y) = -1: roll = 1: dr = 0: _SndPlay er&: GoSub 1000: GoTo 10
GoTo 20
370 If S(x, y) = 0 Then S(x, y) = d1: roll = 1: dr = 0: _SndPlay bep&: GoSub 1000: GoTo 10
GoTo 20

400 Rem * Dice Select/Deselect
If roll = 3 Then 20
d = 0: For t = 1 To 5: If m2 > 10 + ((t - 1) * 60) And m2 < 61 + ((t - 1) * 60) Then d = t
Next t: If d = 0 Then 20
If rd(d) = 1 Then rd(d) = 0 Else rd(d) = 1
If rd(d) = 1 Then _SndPlay sd1&: _PutImage (15 + ((d - 1) * 60), 712), rll
If rd(d) = 0 Then _SndPlay sd2&: _PutImage (11 + ((d - 1) * 60), 698), d(di(d))
GoTo 20

500 Rem * Dice Roll
If roll = 3 Then 20
If rd(1) = 0 And rd(2) = 0 And rd(3) = 0 And rd(4) = 0 And rd(5) = 0 Then 20
roll = roll + 1
GoSub 2000
_PutImage (358, 690), r(roll)
GoTo 20

600 Rem * End Game
Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 572 And m2 < 645 And m3 > 724 And m3 < 753 And m4 = -1 Then _SndPlay cli&: GoTo 610
GoTo 20
610 Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 572 And m2 < 645 And m3 > 724 And m3 < 753 And m4 = -1 Then _SndPlay cli&: _Delay .5: GoTo 620
GoTo 20
620 Rem * Write Files and Exit
Open "o", #2, "YDCData\YGDATA.YTZ"
For x = 1 To 6: For y = 1 To 23: Print #2, S(x, y): Next y, x
For x = 1 To 5: Print #2, di(x): Next x
Print #2, roll
Print #2, n$
Close #2
System

700 Rem * Reset Scoresheet
Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 571 And m2 < 645 And m3 > 692 And m3 < 717 And m4 = -1 Then _SndPlay cli&: GoTo 710
GoTo 20
710 Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 571 And m2 < 645 And m3 > 692 And m3 < 717 And m4 = -1 Then _SndPlay cli&: GoTo 720
GoTo 20
720 For x = 1 To 6: For y = 1 To 21: S(x, y) = 0: Next y, x: n$ = "": roll = 1: GoTo 5

1000 Rem * Talley Scoresheet and Print to Screen
For t = 1 To 6
    For y = 7 To 9: S(t, y) = 0: Next y
    For y = 18 To 21: S(t, y) = 0: Next y
    Next t: For t = 1 To 6: s1 = 0: s2 = 0
    For y = 1 To 6: If S(t, y) > 0 Then s1 = s1 + S(t, y)
    Next y: S(t, 7) = s1: If s1 > 62 Then S(t, 8) = 35: Else S(t, 8) = 0
    S(t, 9) = S(t, 8) + S(t, 7): S(t, 20) = S(t, 9)
    For y = 10 To 16: If S(t, y) > 0 Then s2 = s2 + S(t, y)
    Next y: S(t, 18) = S(t, 17) * 100: S(t, 19) = S(t, 18) + s2: S(t, 21) = S(t, 20) + S(t, 19)
    Next t: For x = 1 To 6: For y = 1 To 21: If y = 17 Or S(x, y) < 1 Then 1100
        S$ = Str$(S(x, y)): S$ = Right$(S$, Len(S$) - 1): S$ = Left$("  ", 3 - Len(S$)) + S$
        For t = 1 To 3: If Mid$(S$, t, 1) = " " Then 1090
            a = Val(Mid$(S$, t, 1))
            If y < 7 Or (y > 9 And y < 17) Then c$ = Str$(BLUE)
            If y = 7 Or y = 9 Or y = 19 Or y = 20 Then c$ = Str$(GREEN)
            If y = 8 Or y = 17 Or y = 18 Then c$ = Str$(RED)
            If y = 21 Then c$ = Str$(BLACK): PSet (x(x) + 4 + ((t - 1) * 14), y(y) + 19), YELLOW: Draw "c" + Str$(YELLOW) + A$(10) + "c" + c$ + A$(a): GoTo 1090
            PSet (x(x) + 4 + ((t - 1) * 14), y(y) + 19), WHITE: Draw "c" + Str$(WHITE) + A$(10) + "c" + c$ + A$(a)
        1090 Next t
        1100 If S(x, y) = -1 Then PSet (x(x) + 4, y(y) + 19), WHITE: Draw "C" + Str$(RED) + A$(12)
        If y = 17 And S(x, y) > 0 Then For y1 = 1 To S(x, y): PSet (x(x) - 13 + ((y1 - 1) * 23), y(y) + 19), WHITE: Draw "c" + Str$(PURPLE) + A$(11): Next y1
Next y: Next x: Color PURPLE, WHITE: Locate 3, 460: Print n$; " ";
go1 = 0: For t = 1 To 6: For y = 1 To 6: If S(t, y) = 0 Then go1 = 1
        Next y: For y = 10 To 16: If S(t, y) = 0 Then go1 = 1
Next y, t
If go1 = 0 Then _PutImage (127, 201), go
Locate 47, 313: Color BLUE: Print Using "All Games Grand Total: #,### "; S(1, 21) + S(2, 21) + S(3, 21) + S(4, 21) + S(5, 21) + S(6, 21);
Return

2000 Rem * Roll Dice
If go1 = 0 Then Return
_SndPlay dice&: nor = 0: r$ = "": For t = 1 To 5: If rd(t) = 1 Then r$ = r$ + Right$(Str$(t), 1)
    Next t: For y = 1 To 3: t$ = Time$: x = 1
    Do: t = Val(Mid$(r$, x, 1)): di(t) = Int(Rnd(1) * 6) + 1: _PutImage (11 + ((t - 1) * 60), 698), d(di(t)): _PutImage (100, 105 + (di(t) - 1) * 26)-(122, 127 + (di(t) - 1) * 26), d(Int(Rnd(1) * 6) + 1)
        nor = nor + 1: x = x + 1: If x > Len(r$) Then x = 1
    Loop Until t$ <> Time$
Next y: Locate 1, 270: Print "Rolls: "; nor; "  ";
For t = 0 To 5: rd(t) = 0: _PutImage (100, 105 + t * 26)-(122, 127 + t * 26), d(t + 1): Next t

3000 Rem * Put Suggestions on Scoresheet
If go1 = 0 Then Return
For t = 1 To 6: d1(t) = 0: Next t: For t = 1 To 5: d1(di(t)) = d1(di(t)) + 1: Next t
For y = 1 To 6: PSet (245, y(y) + 16), WHITE: If d1(y) > 2 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
Next y: PSet (245, y(10) + 16), WHITE: If d1(1) > 2 Or d1(2) > 2 Or d1(3) > 2 Or d1(4) > 2 Or d1(5) > 2 Or d1(6) > 2 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
PSet (245, y(11) + 16), WHITE: If d1(1) > 3 Or d1(2) > 3 Or d1(3) > 3 Or d1(4) > 3 Or d1(5) > 3 Or d1(6) > 3 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
d1 = 0: If d1(1) = 2 Or d1(2) = 2 Or d1(3) = 2 Or d1(4) = 2 Or d1(5) = 2 Or d1(6) = 2 Then d1 = 1
If d1(1) = 3 Or d1(2) = 3 Or d1(3) = 3 Or d1(4) = 3 Or d1(5) = 3 Or d1(6) = 3 Then d1 = d1 + 1
PSet (245, y(12) + 16), WHITE: If d1 = 2 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
d1 = 0: If d1(1) > 0 And d1(2) > 0 And d1(3) > 0 And d1(4) > 0 Then d1 = 1
If d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 Then d1 = 1
If d1(3) > 0 And d1(4) > 0 And d1(5) > 0 And d1(6) > 0 Then d1 = 1
PSet (245, y(13) + 16), WHITE: If d1 = 1 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
d1 = 0: If d1(1) > 0 And d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 Then d1 = 1
If d1(2) > 0 And d1(3) > 0 And d1(4) > 0 And d1(5) > 0 And d1(6) > 0 Then d1 = 1
PSet (245, y(14) + 16), WHITE: If d1 = 1 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
d1 = 0: If d1(1) = 5 Or d1(2) = 5 Or d1(3) = 5 Or d1(4) = 5 Or d1(5) = 5 Or d1(6) = 5 Then d1 = 1
PSet (245, y(15) + 16), WHITE: If d1 = 1 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
d1 = 0: For t = 1 To 5: d1 = d1 + di(t): Next t
PSet (245, y(16) + 16), WHITE: If d1 > 14 Then Draw "c" + Str$(RED) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1" Else Draw "c" + Str$(WHITE) + "r1u1r1u1r1u1r1u1l1u1l1u1l1u1l1"
Return

4000 Rem *Shows Help Screen
oi& = _CopyImage(0): _PutImage (0, 0), yh&
Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2)
Loop Until m4 = -1 Or m5 = -1
_SndPlay cli&: Screen oi&: GoTo 20

5000 Rem *Undo
Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 235 And m2 < 651 And (m3 > 102 And m3 < 257 Or m3 > 361 And m3 < 546) And m5 = -1 Then _SndPlay cli&: GoTo 5010
GoTo 20
5010 Do: m1 = _MouseInput + _MouseButton(1) + _MouseButton(2): Loop Until m1 = 0
Do: m1 = _MouseInput: m2 = _MouseX: m3 = _MouseY: m4 = _MouseButton(1): m5 = _MouseButton(2): Loop Until m4 = -1 Or m5 = -1
If m2 > 235 And m2 < 651 And (m3 > 102 And m3 < 257 Or m3 > 361 And m3 < 546) And m5 = -1 Then _SndPlay cli&: GoTo 5020
GoTo 20
5020 x = Int((m2 - 238) / 69) + 1: y = Int((m3 - 103) / 26) + 1
If y > 10 Then y = y - 1
If S(x, y) = 0 Then 20
If y = 15 And S(x, 17) > 0 Then S(x, 17) = S(x, 17) - 1: Line (238 + ((x - 1) * 69) + (S(x, 17) * 23), 546)-(258 + ((x - 1) * 69) + (S(x, 17) * 23), 570), WHITE, BF: GoTo 5030
S(x, y) = 0
5030 For x = 1 To 6: For y = 1 To 21
        If y <> 17 And y <> 21 Then Line (x(x), y(y) + 2)-(x(x) + 45, y(y) + 24), WHITE, BF
        If y = 21 Then Line (x(x), y(y) + 2)-(x(x) + 45, y(y) + 24), YELLOW, BF
Next y, x
GoSub 1000: _SndPlay er&: GoTo 20


Attached Files
.zip   Yahtzee.zip (Size: 3.27 MB / Downloads: 110)
Reply
#2
+1 @dcoterel  Thanks for sharing your experience with us! 

Might be fun to learn this Yahtzee, I've certainly heard of it. 

Sudoku was great!, 2048 cool, Wordle, Waffle, 21, Alchemy presented by PhilOfPerth, Battleship with Johnno, Snake and Smart Snake AI, Poker, Gin, TTT, Connect 4, even a Chess UI, Brick smashing (I forgot what its called, I have Halloween version), Minesweeper and especially Hexagonal Minesweeper, Asteroids bplus style (or eRATication versions), ALL have been fun to program with QB64. I tend to learn the game or better strategy of play from programming it.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Yoker... A Yahtzee / Poker twist (newest) dcoterel 0 401 07-12-2025, 05:29 AM
Last Post: dcoterel
  Google Breakout Clone aadityap0901 6 1,264 06-11-2025, 05:06 PM
Last Post: aadityap0901
  Asteroids Clone SierraKen 10 1,740 02-05-2025, 04:41 PM
Last Post: Deciheximal
  Zelda 64 (Zelda Clone by Cobalt) SMcNeill 3 1,216 07-21-2024, 12:23 PM
Last Post: Circlotron
  Flappy Bird Clone by Terry Ritchie SMcNeill 0 780 12-24-2023, 04:20 AM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)