Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,614 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 953 people online right now. Registration is fast and FREE... Join Now!




snake and ladder game

 
Reply to this topicStart new topic

snake and ladder game, snake and ladder its a game...for at a max of 4 players

abitrapi
post 12 Jul, 2008 - 05:28 AM
Post #1


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 3

'form1 code:




vb
Private Sub Combo1_DropDown()
Command2.Enabled = True
End Sub

Private Sub Command2_Click()
Form1.Visible = False
Form2.Visible = True

End Sub





===========================================




'form2 code


Private Sub Command1_Click()

Command6.Enabled = True 'unlockn the dice



If Val(Label6(0).Caption) = 1 And Val(Label8(0).Caption) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6



Y: q = Val(Command6.Caption)




mov = move1(0, 0, 1, 1, 0)


If Val(Label2(0).Caption) = 8 Then snk = move1(0, 0, 1, 2, 4) 'snake data--------------
If Val(Label2(0).Caption) = 18 Then snk = move1(0, 0, 1, 2, 1) '
If Val(Label2(0).Caption) = 26 Then snk = move1(0, 0, 1, 2, 10) '
If Val(Label2(0).Caption) = 39 Then snk = move1(0, 0, 1, 2, 5) '
If Val(Label2(0).Caption) = 51 Then snk = move1(0, 0, 1, 2, 6) '
If Val(Label2(0).Caption) = 54 Then snk = move1(0, 0, 1, 2, 36)
If Val(Label2(0).Caption) = 56 Then snk = move1(0, 0, 1, 2, 1)
If Val(Label2(0).Caption) = 60 Then snk = move1(0, 0, 1, 2, 23)
If Val(Label2(0).Caption) = 75 Then snk = move1(0, 0, 1, 2, 28)
If Val(Label2(0).Caption) = 83 Then snk = move1(0, 0, 1, 2, 45)
If Val(Label2(0).Caption) = 85 Then snk = move1(0, 0, 1, 2, 59)
If Val(Label2(0).Caption) = 90 Then snk = move1(0, 0, 1, 2, 48)
If Val(Label2(0).Caption) = 92 Then snk = move1(0, 0, 1, 2, 25)
If Val(Label2(0).Caption) = 97 Then snk = move1(0, 0, 1, 2, 87)
If Val(Label2(0).Caption) = 99 Then snk = move1(0, 0, 1, 2, 63) 'snake data---------------------





If Val(Label2(0).Caption) = 3 Then snk = move1(0, 0, 1, 3, 20) 'ladder data-------------------
If Val(Label2(0).Caption) = 6 Then snk = move1(0, 0, 1, 3, 14) '
If Val(Label2(0).Caption) = 11 Then snk = move1(0, 0, 1, 3, 28) '
If Val(Label2(0).Caption) = 15 Then snk = move1(0, 0, 1, 3, 34) '
If Val(Label2(0).Caption) = 17 Then snk = move1(0, 0, 1, 3, 74) '
If Val(Label2(0).Caption) = 22 Then snk = move1(0, 0, 1, 3, 37)
If Val(Label2(0).Caption) = 38 Then snk = move1(0, 0, 1, 3, 59)
If Val(Label2(0).Caption) = 49 Then snk = move1(0, 0, 1, 3, 67)
If Val(Label2(0).Caption) = 57 Then snk = move1(0, 0, 1, 3, 76)
If Val(Label2(0).Caption) = 61 Then snk = move1(0, 0, 1, 3, 78)
If Val(Label2(0).Caption) = 73 Then snk = move1(0, 0, 1, 3, 86)
If Val(Label2(0).Caption) = 81 Then snk = move1(0, 0, 1, 3, 98)
If Val(Label2(0).Caption) = 88 Then snk = move1(0, 0, 1, 3, 91) 'ladder data---------------------




If Val(Label2(0).Caption) >= 100 Then MsgBox ("player 1 wins ")
If Val(Label2(0).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(0).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(0).Caption) >= 100 Then Unload Me
If Val(Label2(0).Caption) >= 100 Then Form1.Label1.Caption = "play again..."


i: Label4.Caption = "1"
Command1.Enabled = False


Label5(0).Caption = Command6.Caption
If Val(Label5(0).Caption) = 6 Or Val(Label5(0).Caption) = 1 Then Label6(0).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(0).Caption) = 6 Or Val(Label5(0).Caption) = 1 Then Label8(0).Caption = Val(Label8(0).Caption) + 1





End Sub

Private Sub Command2_Click()
Dim a As Long
Command6.Enabled = True

a = Val(Form1.Combo1.Text)

m = Random(1, a)
Command2.Caption = "player" & m & "wins"

Command2.Enabled = False
If m = 1 Then Command1.Enabled = True
If m = 2 Then Command3.Enabled = True
If m = 3 Then Command4.Enabled = True
If m = 4 Then Command5.Enabled = True

End Sub

Private Sub Command3_Click()
Command6.Enabled = True 'unlokng the dice


If Val(Label6(1).Caption) = 1 And Val(Label8(0).Caption) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6





Y: q = Val(Command6.Caption)

mov = move1(1, 2, 3, 1, 0)


If Val(Label2(2).Caption) = 8 Then snk = move1(1, 2, 3, 2, 4) 'snake data--------------
If Val(Label2(2).Caption) = 18 Then snk = move1(1, 2, 3, 2, 1) '
If Val(Label2(2).Caption) = 26 Then snk = move1(1, 2, 3, 2, 10) '
If Val(Label2(2).Caption) = 39 Then snk = move1(1, 2, 3, 2, 5) '
If Val(Label2(2).Caption) = 51 Then snk = move1(1, 2, 3, 2, 6) '
If Val(Label2(2).Caption) = 54 Then snk = move1(1, 2, 3, 2, 36)
If Val(Label2(2).Caption) = 56 Then snk = move1(1, 2, 3, 2, 1)
If Val(Label2(2).Caption) = 60 Then snk = move1(1, 2, 3, 2, 23)
If Val(Label2(2).Caption) = 75 Then snk = move1(1, 2, 3, 2, 28)
If Val(Label2(2).Caption) = 83 Then snk = move1(1, 2, 3, 2, 45)
If Val(Label2(2).Caption) = 85 Then snk = move1(1, 2, 3, 2, 59)
If Val(Label2(2).Caption) = 90 Then snk = move1(1, 2, 3, 2, 48)
If Val(Label2(2).Caption) = 92 Then snk = move1(1, 2, 3, 2, 25)
If Val(Label2(2).Caption) = 97 Then snk = move1(1, 2, 3, 2, 87)
If Val(Label2(2).Caption) = 99 Then snk = move1(1, 2, 3, 2, 63) 'snake data---------------------




If Val(Label2(2).Caption) = 3 Then snk = move1(1, 2, 3, 3, 20) 'ladder data--------------
If Val(Label2(2).Caption) = 6 Then snk = move1(1, 2, 3, 3, 14) '
If Val(Label2(2).Caption) = 11 Then snk = move1(1, 2, 3, 3, 28) '
If Val(Label2(2).Caption) = 15 Then snk = move1(1, 2, 3, 3, 34) '
If Val(Label2(2).Caption) = 17 Then snk = move1(1, 2, 3, 3, 74) '
If Val(Label2(2).Caption) = 22 Then snk = move1(1, 2, 3, 3, 37)
If Val(Label2(2).Caption) = 38 Then snk = move1(1, 2, 3, 3, 59)
If Val(Label2(2).Caption) = 49 Then snk = move1(1, 2, 3, 3, 67)
If Val(Label2(2).Caption) = 57 Then snk = move1(1, 2, 3, 3, 76)
If Val(Label2(2).Caption) = 61 Then snk = move1(1, 2, 3, 3, 78)
If Val(Label2(2).Caption) = 73 Then snk = move1(1, 2, 3, 3, 86)
If Val(Label2(2).Caption) = 81 Then snk = move1(1, 2, 3, 3, 98)
If Val(Label2(2).Caption) = 88 Then snk = move1(1, 2, 3, 3, 91) 'ladder data---------------------



If Val(Label2(2).Caption) >= 100 Then MsgBox ("player 2 wins ")
If Val(Label2(2).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(2).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(2).Caption) >= 100 Then Unload Me
If Val(Label2(2).Caption) >= 100 Then Form1.Label1.Caption = "play again..."



i: Label4.Caption = "2"
Command3.Enabled = False



Label5(1).Caption = Command6.Caption
If Val(Label5(1).Caption) = 6 Or Val(Label5(1).Caption) = 1 Then Label6(1).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(1).Caption) = 6 Or Val(Label5(1).Caption) = 1 Then Label8(1).Caption = Val(Label8(1).Caption) + 1




End Sub

Private Sub Command4_Click()
Command6.Enabled = True 'unlockng the dice


If Val(Label6(2).Caption) = 1 And Val(Label8(2)) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6





Y: q = Val(Command6.Caption)

mov = move1(2, 4, 5, 1, 0) ' function to move the player it also moves the player in case of snake bite and ladder



If Val(Label2(4).Caption) = 8 Then snk = move1(2, 4, 5, 2, 4) 'snake data--------------
If Val(Label2(4).Caption) = 18 Then snk = move1(2, 4, 5, 2, 1) '
If Val(Label2(4).Caption) = 26 Then snk = move1(2, 4, 5, 2, 10) '
If Val(Label2(4).Caption) = 39 Then snk = move1(2, 4, 5, 2, 5) '
If Val(Label2(4).Caption) = 51 Then snk = move1(2, 4, 5, 2, 6) '
If Val(Label2(4).Caption) = 54 Then snk = move1(2, 4, 5, 2, 36) '
If Val(Label2(4).Caption) = 56 Then snk = move1(2, 4, 5, 2, 1) '
If Val(Label2(4).Caption) = 60 Then snk = move1(2, 4, 5, 2, 23)
If Val(Label2(4).Caption) = 75 Then snk = move1(2, 4, 5, 2, 28)
If Val(Label2(4).Caption) = 83 Then snk = move1(2, 4, 5, 2, 45)
If Val(Label2(4).Caption) = 85 Then snk = move1(2, 4, 5, 2, 59)
If Val(Label2(4).Caption) = 90 Then snk = move1(2, 4, 5, 2, 48)
If Val(Label2(4).Caption) = 92 Then snk = move1(2, 4, 5, 2, 25)
If Val(Label2(4).Caption) = 97 Then snk = move1(2, 4, 5, 2, 87)
If Val(Label2(4).Caption) = 99 Then snk = move1(2, 4, 5, 2, 63) 'snake data---------------------




If Val(Label2(4).Caption) = 3 Then snk = move1(2, 4, 5, 3, 20) 'ladder data--------------
If Val(Label2(4).Caption) = 6 Then snk = move1(2, 4, 5, 3, 14) '
If Val(Label2(4).Caption) = 11 Then snk = move1(2, 4, 5, 3, 28) '
If Val(Label2(4).Caption) = 15 Then snk = move1(2, 4, 5, 3, 34) '
If Val(Label2(4).Caption) = 17 Then snk = move1(2, 4, 5, 3, 74) '
If Val(Label2(4).Caption) = 22 Then snk = move1(2, 4, 5, 3, 37)
If Val(Label2(4).Caption) = 38 Then snk = move1(2, 4, 5, 3, 59)
If Val(Label2(4).Caption) = 49 Then snk = move1(2, 4, 5, 3, 67)
If Val(Label2(4).Caption) = 57 Then snk = move1(2, 4, 5, 3, 76)
If Val(Label2(4).Caption) = 61 Then snk = move1(2, 4, 5, 3, 78)
If Val(Label2(4).Caption) = 73 Then snk = move1(2, 4, 5, 3, 86)
If Val(Label2(4).Caption) = 81 Then snk = move1(2, 4, 5, 3, 98)
If Val(Label2(4).Caption) = 88 Then snk = move1(2, 4, 5, 3, 91) 'ladder data---------------------





If Val(Label2(4).Caption) >= 100 Then MsgBox ("player 3 wins ")
If Val(Label2(4).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(4).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(4).Caption) >= 100 Then Unload Me
If Val(Label2(4).Caption) >= 100 Then Form1.Label1.Caption = "play again..."


i: Label4.Caption = "3"
Command4.Enabled = False



Label5(2).Caption = Command6.Caption
If Val(Label5(2).Caption) = 6 Or Val(Label5(2).Caption) = 1 Then Label6(2).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(2).Caption) = 6 Or Val(Label5(2).Caption) = 1 Then Label8(2).Caption = Val(Label8(2).Caption) + 1




End Sub

Private Sub Command5_Click()
Command6.Enabled = True 'unlockng the dice


If Val(Label6(3).Caption) = 1 And Val(Label8(3)) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6



Y: q = Val(Command6.Caption)

mov = move1(3, 5, 6, 1, 0) ' function to move the player it also moves the player in case of snake bite and ladder



If Val(Label2(6).Caption) = 8 Then snk = move1(3, 5, 6, 2, 4) 'snake data--------------
If Val(Label2(6).Caption) = 18 Then snk = move1(3, 5, 6, 2, 1) '
If Val(Label2(6).Caption) = 26 Then snk = move1(3, 5, 6, 2, 10) '
If Val(Label2(6).Caption) = 39 Then snk = move1(3, 5, 6, 2, 5) '
If Val(Label2(6).Caption) = 51 Then snk = move1(3, 5, 6, 2, 6) '
If Val(Label2(6).Caption) = 54 Then snk = move1(3, 5, 6, 2, 36) '
If Val(Label2(6).Caption) = 56 Then snk = move1(3, 5, 6, 2, 1) '
If Val(Label2(6).Caption) = 60 Then snk = move1(3, 5, 6, 2, 23)
If Val(Label2(6).Caption) = 75 Then snk = move1(3, 5, 6, 2, 28)
If Val(Label2(6).Caption) = 83 Then snk = move1(3, 5, 6, 2, 45)
If Val(Label2(6).Caption) = 85 Then snk = move1(3, 5, 6, 2, 59)
If Val(Label2(6).Caption) = 90 Then snk = move1(3, 5, 6, 2, 48)
If Val(Label2(6).Caption) = 92 Then snk = move1(3, 5, 6, 2, 25)
If Val(Label2(6).Caption) = 97 Then snk = move1(3, 5, 6, 2, 87)
If Val(Label2(6).Caption) = 99 Then snk = move1(3, 5, 6, 2, 63) 'snake data---------------------





If Val(Label2(6).Caption) = 3 Then snk = move1(3, 5, 6, 3, 20) 'ladder data--------------
If Val(Label2(6).Caption) = 6 Then snk = move1(3, 5, 6, 3, 14) '
If Val(Label2(6).Caption) = 11 Then snk = move1(3, 5, 6, 3, 28) '
If Val(Label2(6).Caption) = 15 Then snk = move1(3, 5, 6, 3, 34) '
If Val(Label2(6).Caption) = 17 Then snk = move1(3, 5, 6, 3, 74) '
If Val(Label2(6).Caption) = 22 Then snk = move1(3, 5, 6, 3, 37)
If Val(Label2(6).Caption) = 38 Then snk = move1(3, 5, 6, 3, 59)
If Val(Label2(6).Caption) = 49 Then snk = move1(3, 5, 6, 3, 67)
If Val(Label2(6).Caption) = 57 Then snk = move1(3, 5, 6, 3, 76)
If Val(Label2(6).Caption) = 61 Then snk = move1(3, 5, 6, 3, 78)
If Val(Label2(6).Caption) = 73 Then snk = move1(3, 5, 6, 3, 86)
If Val(Label2(6).Caption) = 81 Then snk = move1(3, 5, 6, 3, 98)
If Val(Label2(6).Caption) = 88 Then snk = move1(3, 5, 6, 3, 91) 'ladder data---------------------





If Val(Label2(6).Caption) >= 100 Then MsgBox ("player 4 wins ")
If Val(Label2(6).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(6).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(6).Caption) >= 100 Then Unload Me
If Val(Label2(6).Caption) >= 100 Then Form1.Label1.Caption = "play again..."



i: Label4.Caption = "4"
Command5.Enabled = False



Label5(3).Caption = Command6.Caption
If Val(Label5(3).Caption) = 6 Or Val(Label5(3).Caption) = 1 Then Label6(2).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(3).Caption) = 6 Or Val(Label5(3).Caption) = 1 Then Label8(3).Caption = Val(Label8(3).Caption) + 1

End Sub

Private Sub Command6_Click()

q = Random(1, 6)

Command6.Caption = q

Command6.Enabled = False







If Val(Form1.Combo1.Text) = 2 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 2 And Val(Label4.Caption) = 2 Then Command1.Enabled = True

If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 2 Then Command4.Enabled = True
If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 3 Then Command1.Enabled = True

If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 2 Then Command4.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 3 Then Command5.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 4 Then Command1.Enabled = True

End Sub



Private Sub file_Click(Index As Integer)

End Sub

Private Sub Form_Load()
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False











s = Val(Form1.Combo1.Text)
For w = 0 To s - 1
Label1(w).Caption = "P" & w + 1
Label1(w).Visible = True
Next w '
End Sub

Function Random(Lowerbound As Long, Upperbound As Long)
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound

End Function

Function move1(a1 As Integer, a2 As Integer, a3 As Integer, a4 As Integer, a5 As Integer)
Dim q As Integer


If a4 = 1 Then GoTo s Else GoTo s1

s: For q = 1 To (Val(Command6.Caption)) 'simple ahead movement-----------
w = Val(Label2(a2).Caption)

If (w Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top - 940

If (w Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If (w Mod 10) = 0 Then GoTo p




If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left + 940 Else Label1(a1).Left = Label1(a1).Left - 940
p: Label2(a2).Caption = Val(Label2(a2).Caption) + 1
w = Val(Label2(a2).Caption)
Next q





'-------------------------------------------------------------- 'planned snake movement'




s1: If a4 = 2 Then GoTo s2 Else GoTo s3

s2: Label9.Caption = "player " & (a1 + 1) & " got bit by a snake at " & Val(Label2(a2).Caption)
For q = (Val(Label2(a2).Caption)) To a5 + 1 Step -1
w = Val(Label2(a2).Caption)

If ((w - 1) Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top + 940

If ((w - 1) Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If ((w - 1) Mod 10) = 0 Then GoTo p1



If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left - 940 Else Label1(a1).Left = Label1(a1).Left + 940
p1: Label2(a2).Caption = Val(Label2(a2).Caption) - 1
w = Val(Label2(a2).Caption)
Next q





'------------------------------------------------------------ 'ladder movement control




s3: If a4 = 3 Then GoTo s4 Else GoTo s5

s4: Label9.Caption = "player " & (a1 + 1) & " climbed the ladder at " & Val(Label2(a2).Caption)
For q = (Val(Label2(a2).Caption)) To a5 - 1 'simple ladder movement-----------
w = Val(Label2(a2).Caption)

If (w Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top - 940

If (w Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If (w Mod 10) = 0 Then GoTo p2




If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left + 940 Else Label1(a1).Left = Label1(a1).Left - 940
p2: Label2(a2).Caption = Val(Label2(a2).Caption) + 1
w = Val(Label2(a2).Caption)
Next q





s5: End Function

Mod edit: Please code.gif
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 12 Jul, 2008 - 05:32 AM
Post #2


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,439



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


Moved to VB (I think that's right...) smile.gif
User is online!Profile CardPM

Go to the top of the page

abitrapi
post 12 Jul, 2008 - 05:41 AM
Post #3


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 3

vb

'form1 code

=============================



Private Sub Combo1_DropDown()
Command2.Enabled = True
End Sub

Private Sub Command2_Click()
Form1.Visible = False
Form2.Visible = True

End Sub



=======================


'form 2 code




Private Sub Command1_Click()

Command6.Enabled = True 'unlockn the dice



If Val(Label6(0).Caption) = 1 And Val(Label8(0).Caption) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6



Y: q = Val(Command6.Caption)




mov = move1(0, 0, 1, 1, 0)


If Val(Label2(0).Caption) = 8 Then snk = move1(0, 0, 1, 2, 4) 'snake data--------------
If Val(Label2(0).Caption) = 18 Then snk = move1(0, 0, 1, 2, 1) '
If Val(Label2(0).Caption) = 26 Then snk = move1(0, 0, 1, 2, 10) '
If Val(Label2(0).Caption) = 39 Then snk = move1(0, 0, 1, 2, 5) '
If Val(Label2(0).Caption) = 51 Then snk = move1(0, 0, 1, 2, 6) '
If Val(Label2(0).Caption) = 54 Then snk = move1(0, 0, 1, 2, 36)
If Val(Label2(0).Caption) = 56 Then snk = move1(0, 0, 1, 2, 1)
If Val(Label2(0).Caption) = 60 Then snk = move1(0, 0, 1, 2, 23)
If Val(Label2(0).Caption) = 75 Then snk = move1(0, 0, 1, 2, 28)
If Val(Label2(0).Caption) = 83 Then snk = move1(0, 0, 1, 2, 45)
If Val(Label2(0).Caption) = 85 Then snk = move1(0, 0, 1, 2, 59)
If Val(Label2(0).Caption) = 90 Then snk = move1(0, 0, 1, 2, 48)
If Val(Label2(0).Caption) = 92 Then snk = move1(0, 0, 1, 2, 25)
If Val(Label2(0).Caption) = 97 Then snk = move1(0, 0, 1, 2, 87)
If Val(Label2(0).Caption) = 99 Then snk = move1(0, 0, 1, 2, 63) 'snake data---------------------





If Val(Label2(0).Caption) = 3 Then snk = move1(0, 0, 1, 3, 20) 'ladder data-------------------
If Val(Label2(0).Caption) = 6 Then snk = move1(0, 0, 1, 3, 14) '
If Val(Label2(0).Caption) = 11 Then snk = move1(0, 0, 1, 3, 28) '
If Val(Label2(0).Caption) = 15 Then snk = move1(0, 0, 1, 3, 34) '
If Val(Label2(0).Caption) = 17 Then snk = move1(0, 0, 1, 3, 74) '
If Val(Label2(0).Caption) = 22 Then snk = move1(0, 0, 1, 3, 37)
If Val(Label2(0).Caption) = 38 Then snk = move1(0, 0, 1, 3, 59)
If Val(Label2(0).Caption) = 49 Then snk = move1(0, 0, 1, 3, 67)
If Val(Label2(0).Caption) = 57 Then snk = move1(0, 0, 1, 3, 76)
If Val(Label2(0).Caption) = 61 Then snk = move1(0, 0, 1, 3, 78)
If Val(Label2(0).Caption) = 73 Then snk = move1(0, 0, 1, 3, 86)
If Val(Label2(0).Caption) = 81 Then snk = move1(0, 0, 1, 3, 98)
If Val(Label2(0).Caption) = 88 Then snk = move1(0, 0, 1, 3, 91) 'ladder data---------------------




If Val(Label2(0).Caption) >= 100 Then MsgBox ("player 1 wins ")
If Val(Label2(0).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(0).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(0).Caption) >= 100 Then Unload Me
If Val(Label2(0).Caption) >= 100 Then Form1.Label1.Caption = "play again..."


i: Label4.Caption = "1"
Command1.Enabled = False


Label5(0).Caption = Command6.Caption
If Val(Label5(0).Caption) = 6 Or Val(Label5(0).Caption) = 1 Then Label6(0).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(0).Caption) = 6 Or Val(Label5(0).Caption) = 1 Then Label8(0).Caption = Val(Label8(0).Caption) + 1





End Sub

Private Sub Command2_Click()
Dim a As Long
Command6.Enabled = True

a = Val(Form1.Combo1.Text)

m = Random(1, a)
Command2.Caption = "player" & m & "wins"

Command2.Enabled = False
If m = 1 Then Command1.Enabled = True
If m = 2 Then Command3.Enabled = True
If m = 3 Then Command4.Enabled = True
If m = 4 Then Command5.Enabled = True

End Sub

Private Sub Command3_Click()
Command6.Enabled = True 'unlokng the dice


If Val(Label6(1).Caption) = 1 And Val(Label8(0).Caption) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6





Y: q = Val(Command6.Caption)

mov = move1(1, 2, 3, 1, 0)


If Val(Label2(2).Caption) = 8 Then snk = move1(1, 2, 3, 2, 4) 'snake data--------------
If Val(Label2(2).Caption) = 18 Then snk = move1(1, 2, 3, 2, 1) '
If Val(Label2(2).Caption) = 26 Then snk = move1(1, 2, 3, 2, 10) '
If Val(Label2(2).Caption) = 39 Then snk = move1(1, 2, 3, 2, 5) '
If Val(Label2(2).Caption) = 51 Then snk = move1(1, 2, 3, 2, 6) '
If Val(Label2(2).Caption) = 54 Then snk = move1(1, 2, 3, 2, 36)
If Val(Label2(2).Caption) = 56 Then snk = move1(1, 2, 3, 2, 1)
If Val(Label2(2).Caption) = 60 Then snk = move1(1, 2, 3, 2, 23)
If Val(Label2(2).Caption) = 75 Then snk = move1(1, 2, 3, 2, 28)
If Val(Label2(2).Caption) = 83 Then snk = move1(1, 2, 3, 2, 45)
If Val(Label2(2).Caption) = 85 Then snk = move1(1, 2, 3, 2, 59)
If Val(Label2(2).Caption) = 90 Then snk = move1(1, 2, 3, 2, 48)
If Val(Label2(2).Caption) = 92 Then snk = move1(1, 2, 3, 2, 25)
If Val(Label2(2).Caption) = 97 Then snk = move1(1, 2, 3, 2, 87)
If Val(Label2(2).Caption) = 99 Then snk = move1(1, 2, 3, 2, 63) 'snake data---------------------




If Val(Label2(2).Caption) = 3 Then snk = move1(1, 2, 3, 3, 20) 'ladder data--------------
If Val(Label2(2).Caption) = 6 Then snk = move1(1, 2, 3, 3, 14) '
If Val(Label2(2).Caption) = 11 Then snk = move1(1, 2, 3, 3, 28) '
If Val(Label2(2).Caption) = 15 Then snk = move1(1, 2, 3, 3, 34) '
If Val(Label2(2).Caption) = 17 Then snk = move1(1, 2, 3, 3, 74) '
If Val(Label2(2).Caption) = 22 Then snk = move1(1, 2, 3, 3, 37)
If Val(Label2(2).Caption) = 38 Then snk = move1(1, 2, 3, 3, 59)
If Val(Label2(2).Caption) = 49 Then snk = move1(1, 2, 3, 3, 67)
If Val(Label2(2).Caption) = 57 Then snk = move1(1, 2, 3, 3, 76)
If Val(Label2(2).Caption) = 61 Then snk = move1(1, 2, 3, 3, 78)
If Val(Label2(2).Caption) = 73 Then snk = move1(1, 2, 3, 3, 86)
If Val(Label2(2).Caption) = 81 Then snk = move1(1, 2, 3, 3, 98)
If Val(Label2(2).Caption) = 88 Then snk = move1(1, 2, 3, 3, 91) 'ladder data---------------------



If Val(Label2(2).Caption) >= 100 Then MsgBox ("player 2 wins ")
If Val(Label2(2).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(2).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(2).Caption) >= 100 Then Unload Me
If Val(Label2(2).Caption) >= 100 Then Form1.Label1.Caption = "play again..."



i: Label4.Caption = "2"
Command3.Enabled = False



Label5(1).Caption = Command6.Caption
If Val(Label5(1).Caption) = 6 Or Val(Label5(1).Caption) = 1 Then Label6(1).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(1).Caption) = 6 Or Val(Label5(1).Caption) = 1 Then Label8(1).Caption = Val(Label8(1).Caption) + 1




End Sub

Private Sub Command4_Click()
Command6.Enabled = True 'unlockng the dice


If Val(Label6(2).Caption) = 1 And Val(Label8(2)) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6





Y: q = Val(Command6.Caption)

mov = move1(2, 4, 5, 1, 0) ' function to move the player it also moves the player in case of snake bite and ladder



If Val(Label2(4).Caption) = 8 Then snk = move1(2, 4, 5, 2, 4) 'snake data--------------
If Val(Label2(4).Caption) = 18 Then snk = move1(2, 4, 5, 2, 1) '
If Val(Label2(4).Caption) = 26 Then snk = move1(2, 4, 5, 2, 10) '
If Val(Label2(4).Caption) = 39 Then snk = move1(2, 4, 5, 2, 5) '
If Val(Label2(4).Caption) = 51 Then snk = move1(2, 4, 5, 2, 6) '
If Val(Label2(4).Caption) = 54 Then snk = move1(2, 4, 5, 2, 36) '
If Val(Label2(4).Caption) = 56 Then snk = move1(2, 4, 5, 2, 1) '
If Val(Label2(4).Caption) = 60 Then snk = move1(2, 4, 5, 2, 23)
If Val(Label2(4).Caption) = 75 Then snk = move1(2, 4, 5, 2, 28)
If Val(Label2(4).Caption) = 83 Then snk = move1(2, 4, 5, 2, 45)
If Val(Label2(4).Caption) = 85 Then snk = move1(2, 4, 5, 2, 59)
If Val(Label2(4).Caption) = 90 Then snk = move1(2, 4, 5, 2, 48)
If Val(Label2(4).Caption) = 92 Then snk = move1(2, 4, 5, 2, 25)
If Val(Label2(4).Caption) = 97 Then snk = move1(2, 4, 5, 2, 87)
If Val(Label2(4).Caption) = 99 Then snk = move1(2, 4, 5, 2, 63) 'snake data---------------------




If Val(Label2(4).Caption) = 3 Then snk = move1(2, 4, 5, 3, 20) 'ladder data--------------
If Val(Label2(4).Caption) = 6 Then snk = move1(2, 4, 5, 3, 14) '
If Val(Label2(4).Caption) = 11 Then snk = move1(2, 4, 5, 3, 28) '
If Val(Label2(4).Caption) = 15 Then snk = move1(2, 4, 5, 3, 34) '
If Val(Label2(4).Caption) = 17 Then snk = move1(2, 4, 5, 3, 74) '
If Val(Label2(4).Caption) = 22 Then snk = move1(2, 4, 5, 3, 37)
If Val(Label2(4).Caption) = 38 Then snk = move1(2, 4, 5, 3, 59)
If Val(Label2(4).Caption) = 49 Then snk = move1(2, 4, 5, 3, 67)
If Val(Label2(4).Caption) = 57 Then snk = move1(2, 4, 5, 3, 76)
If Val(Label2(4).Caption) = 61 Then snk = move1(2, 4, 5, 3, 78)
If Val(Label2(4).Caption) = 73 Then snk = move1(2, 4, 5, 3, 86)
If Val(Label2(4).Caption) = 81 Then snk = move1(2, 4, 5, 3, 98)
If Val(Label2(4).Caption) = 88 Then snk = move1(2, 4, 5, 3, 91) 'ladder data---------------------





If Val(Label2(4).Caption) >= 100 Then MsgBox ("player 3 wins ")
If Val(Label2(4).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(4).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(4).Caption) >= 100 Then Unload Me
If Val(Label2(4).Caption) >= 100 Then Form1.Label1.Caption = "play again..."


i: Label4.Caption = "3"
Command4.Enabled = False



Label5(2).Caption = Command6.Caption
If Val(Label5(2).Caption) = 6 Or Val(Label5(2).Caption) = 1 Then Label6(2).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(2).Caption) = 6 Or Val(Label5(2).Caption) = 1 Then Label8(2).Caption = Val(Label8(2).Caption) + 1




End Sub

Private Sub Command5_Click()
Command6.Enabled = True 'unlockng the dice


If Val(Label6(3).Caption) = 1 And Val(Label8(3)) > 0 Then GoTo Y Else GoTo i 'test condition for the 1st chance the player cant move till he gets a 6



Y: q = Val(Command6.Caption)

mov = move1(3, 5, 6, 1, 0) ' function to move the player it also moves the player in case of snake bite and ladder



If Val(Label2(6).Caption) = 8 Then snk = move1(3, 5, 6, 2, 4) 'snake data--------------
If Val(Label2(6).Caption) = 18 Then snk = move1(3, 5, 6, 2, 1) '
If Val(Label2(6).Caption) = 26 Then snk = move1(3, 5, 6, 2, 10) '
If Val(Label2(6).Caption) = 39 Then snk = move1(3, 5, 6, 2, 5) '
If Val(Label2(6).Caption) = 51 Then snk = move1(3, 5, 6, 2, 6) '
If Val(Label2(6).Caption) = 54 Then snk = move1(3, 5, 6, 2, 36) '
If Val(Label2(6).Caption) = 56 Then snk = move1(3, 5, 6, 2, 1) '
If Val(Label2(6).Caption) = 60 Then snk = move1(3, 5, 6, 2, 23)
If Val(Label2(6).Caption) = 75 Then snk = move1(3, 5, 6, 2, 28)
If Val(Label2(6).Caption) = 83 Then snk = move1(3, 5, 6, 2, 45)
If Val(Label2(6).Caption) = 85 Then snk = move1(3, 5, 6, 2, 59)
If Val(Label2(6).Caption) = 90 Then snk = move1(3, 5, 6, 2, 48)
If Val(Label2(6).Caption) = 92 Then snk = move1(3, 5, 6, 2, 25)
If Val(Label2(6).Caption) = 97 Then snk = move1(3, 5, 6, 2, 87)
If Val(Label2(6).Caption) = 99 Then snk = move1(3, 5, 6, 2, 63) 'snake data---------------------





If Val(Label2(6).Caption) = 3 Then snk = move1(3, 5, 6, 3, 20) 'ladder data--------------
If Val(Label2(6).Caption) = 6 Then snk = move1(3, 5, 6, 3, 14) '
If Val(Label2(6).Caption) = 11 Then snk = move1(3, 5, 6, 3, 28) '
If Val(Label2(6).Caption) = 15 Then snk = move1(3, 5, 6, 3, 34) '
If Val(Label2(6).Caption) = 17 Then snk = move1(3, 5, 6, 3, 74) '
If Val(Label2(6).Caption) = 22 Then snk = move1(3, 5, 6, 3, 37)
If Val(Label2(6).Caption) = 38 Then snk = move1(3, 5, 6, 3, 59)
If Val(Label2(6).Caption) = 49 Then snk = move1(3, 5, 6, 3, 67)
If Val(Label2(6).Caption) = 57 Then snk = move1(3, 5, 6, 3, 76)
If Val(Label2(6).Caption) = 61 Then snk = move1(3, 5, 6, 3, 78)
If Val(Label2(6).Caption) = 73 Then snk = move1(3, 5, 6, 3, 86)
If Val(Label2(6).Caption) = 81 Then snk = move1(3, 5, 6, 3, 98)
If Val(Label2(6).Caption) = 88 Then snk = move1(3, 5, 6, 3, 91) 'ladder data---------------------





If Val(Label2(6).Caption) >= 100 Then MsgBox ("player 4 wins ")
If Val(Label2(6).Caption) >= 100 Then MsgBox ("gameover")
If Val(Label2(6).Caption) >= 100 Then Form1.Visible = True
If Val(Label2(6).Caption) >= 100 Then Unload Me
If Val(Label2(6).Caption) >= 100 Then Form1.Label1.Caption = "play again..."



i: Label4.Caption = "4"
Command5.Enabled = False



Label5(3).Caption = Command6.Caption
If Val(Label5(3).Caption) = 6 Or Val(Label5(3).Caption) = 1 Then Label6(2).Caption = 1 'condition again checking the 6 for the 1st chance
If Val(Label5(3).Caption) = 6 Or Val(Label5(3).Caption) = 1 Then Label8(3).Caption = Val(Label8(3).Caption) + 1

End Sub

Private Sub Command6_Click()

q = Random(1, 6)

Command6.Caption = q

Command6.Enabled = False







If Val(Form1.Combo1.Text) = 2 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 2 And Val(Label4.Caption) = 2 Then Command1.Enabled = True

If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 2 Then Command4.Enabled = True
If Val(Form1.Combo1.Text) = 3 And Val(Label4.Caption) = 3 Then Command1.Enabled = True

If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 1 Then Command3.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 2 Then Command4.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 3 Then Command5.Enabled = True
If Val(Form1.Combo1.Text) = 4 And Val(Label4.Caption) = 4 Then Command1.Enabled = True

End Sub



Private Sub file_Click(Index As Integer)

End Sub

Private Sub Form_Load()
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False











s = Val(Form1.Combo1.Text)
For w = 0 To s - 1
Label1(w).Caption = "P" & w + 1
Label1(w).Visible = True
Next w '
End Sub

Function Random(Lowerbound As Long, Upperbound As Long)
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound

End Function

Function move1(a1 As Integer, a2 As Integer, a3 As Integer, a4 As Integer, a5 As Integer)
Dim q As Integer


If a4 = 1 Then GoTo s Else GoTo s1

s: For q = 1 To (Val(Command6.Caption)) 'simple ahead movement-----------
w = Val(Label2(a2).Caption)

If (w Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top - 940

If (w Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If (w Mod 10) = 0 Then GoTo p




If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left + 940 Else Label1(a1).Left = Label1(a1).Left - 940
p: Label2(a2).Caption = Val(Label2(a2).Caption) + 1
w = Val(Label2(a2).Caption)
Next q





'-------------------------------------------------------------- 'planned snake movement'




s1: If a4 = 2 Then GoTo s2 Else GoTo s3

s2: Label9.Caption = "player " & (a1 + 1) & " got bit by a snake at " & Val(Label2(a2).Caption)
For q = (Val(Label2(a2).Caption)) To a5 + 1 Step -1
w = Val(Label2(a2).Caption)

If ((w - 1) Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top + 940

If ((w - 1) Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If ((w - 1) Mod 10) = 0 Then GoTo p1



If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left - 940 Else Label1(a1).Left = Label1(a1).Left + 940
p1: Label2(a2).Caption = Val(Label2(a2).Caption) - 1
w = Val(Label2(a2).Caption)
Next q





'------------------------------------------------------------ 'ladder movement control




s3: If a4 = 3 Then GoTo s4 Else GoTo s5

s4: Label9.Caption = "player " & (a1 + 1) & " climbed the ladder at " & Val(Label2(a2).Caption)
For q = (Val(Label2(a2).Caption)) To a5 - 1 'simple ladder movement-----------
w = Val(Label2(a2).Caption)

If (w Mod 10) = 0 Then Label1(a1).Top = Label1(a1).Top - 940

If (w Mod 10) = 0 Then Label2(a3).Caption = Val(Label2(a3).Caption) + 1
If (w Mod 10) = 0 Then GoTo p2




If (Val(Label2(a3)) Mod 2) Then Label1(a1).Left = Label1(a1).Left + 940 Else Label1(a1).Left = Label1(a1).Left - 940
p2: Label2(a2).Caption = Val(Label2(a2).Caption) + 1
w = Val(Label2(a2).Caption)
Next q





s5: End Function
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 12 Jul, 2008 - 06:11 AM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


You have this posted in the Visual Basic forum as well. Please do not start duplicate threads smile.gif

Topics merged
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:49AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month