Type num a As Integer b As Integer t As Integer EndType Type players name As String turn As Integer money As Integer dice As num EndType GLOBAL dice1, dice2 DIM player(4) As Players player(0).name = "Player" player(0).money = 100 player(1).name = "Joe" player(1).money = 100 player(2).name = "Jack" player(2).money = 100 player(3).name = "Cucumber" player(3).money = 100 repeat cls set cursor 0, 300 print "wina: ",wina print "winb: ",winb print "winf: ",winf print "result: ",result for p = 0 to 3 text p*100, 0, player(p).name line p*100, 0, p*100, 100 text p*100, 20, "DICE1: " text p*100, 34, "DICE2: " text p*100, 48, "TOTAL: " text p*100, 86, "MONEY: " next p clicked0 = button(10, 110, "ROLL DICE") if clicked0 > 0 and roll0 = 0 then roll0 = 1 if roll0 = 1 roll0 = 2 bet = 20 for f = 0 to 3 if player(f).money <> 0 player(f).money = player(f).money - 5 rollDice(f) : turn = f endif if player(f).money = 0 player(f).dice.a = 0 player(f).dice.b = 0 player(f).dice.t = 0 endif next f endif if clicked0 = 0 then roll0 = 0 if turn = 3 turn = 4 wina = Max2(player(0).dice.t,player(1).dice.t) winb = Max2(player(2).dice.t,player(3).dice.t) if wina > 0 and winb > 0 winf = Max2(wina, winb) if winf > 0 result = winf else result = 0 endif else if wina > 0 and winb = 0 winf = Max2(wina, player(2).dice.t) if winf > 0 result = winf else result = 0 endif else if wina = 0 and winb > 0 winf = Max2(player(0).dice.t, winb) if winf > 0 result = winf else result = 0 endif endif endif endif lastwinner1$ = winner$ for f = 0 to 3 if player(f).money <> 0 if result = player(f).dice.t player(f).money = player(f).money + bet winner$ = player(f).name endif endif if result = 0 player(f).money = player(f).money + 5 winner$ = "NOBODY" endif next f endif if winner$ = "" else if winner$ = "NOBODY" text 100, 186, "NOBODY WINS THIS ROUND THERE IS EQUALITY" else if winner$ = "Player" text 100, 186, "Conguratulations."+ winner$+"! YOU WON THE LAST ROUND." else if winner$ = "Joe" text 100, 186, "Conguratulations."+ winner$+"! YOU WON THE LAST ROUND." else if winner$ = "Jack" text 100, 186, "Conguratulations."+ winner$+"! YOU WON THE LAST ROUND." else if winner$ = "Cucumber" text 100, 186, "Conguratulations."+ winner$+"! YOU WON THE LAST ROUND." endif endif endif endif endif endif for t = 0 to 3 text t*100+text width("DICE1: "), 20, str$(player(t).dice.a) text t*100+text width("DICE1: "), 34, str$(player(t).dice.b) text t*100+text width("TOTAL: "), 48, str$(player(t).dice.t) text t*100+text width("TOTAL: "), 86, str$(player(t).money) next t until returnkey() Function rollDice(n As Integer) player(n).dice.a = INT(RND(5) + 1) player(n).dice.b = INT(RND(5) + 1) player(n).dice.t = player(n).dice.a + player(n).dice.b EndFunction Function button(x As Integer, y As Integer, str As String) ink rgb(220, 20, 20), 0 box x-5, y-5, x+text width(str)+5, y+text height(str)+5 if mousex() > x and mousex() < x+text width(str) and mousey() > y and mousey() < y+text height(str) ink rgb(20, 220, 20), 0 box x, y, x+text width(str), y+text height(str) if mouseclick() and click = 0 then click = 1 if click = 1 click = 2 clicked = 1 ink rgb(20, 180, 20), 0 box x, y, x+text width(str), y+text height(str) endif if mouseclick() = 0 then click = 0 : clicked = 0 else ink rgb(220, 220, 220), 0 box x, y, x+text width(str), y+text height(str) endif ink rgb(220, 20, 20), 0 text x, y, str EndFunction clicked Function Max2(a,b) if a>b res=a else res=b endif if a=b res=0 endif EndFunction res