RocketRobotz 

Creator envisioning to create random things.

Forums

Post Reply
Forum Home > Visual Basic Codes *Archive > Tic Tac Toe 2 player mode

RocketRobotz
Site Owner
Posts: 8

http://www.youtube.com/watch?v=XWIyY0CTd0A

4th VB vid ;D

where # is a number except #2

Methods: 1 or #2

Declarations

Dim Turn as integer

#2

dim turn as boolean

Form1 Load

turn = 1

draw.start

#2

draw.start

NOTE: (METHOD 2) AS THE FORM LOADS ANY ARTIFICIAL BOOLEANS ARE EQUAL TO FALSE!

Button# click code

if turn = 1 then

'Puts X

button#.text = "X"

'this is a switching the turn:D

label#.text = "O" 

turn += 1

elseif turn = 2 then

button#.text = "O"

label#.text = "X"

turn  -= 1

end if

button#.enabled = false

call whowins()

#2

if turn = false then

button#.text = "X"

label#.text = "O"

turn = True

elseif turn = true  then

button#.text = "O"

label#.text = "X"

turn = false

end if

reset()

button#.text = nothing

button#.enabled = true

whowins()

'HORIZONTAL COMBI: 123 456 789

'VERTICAL COMBI: 147 258 369

'DIAGONAL COMBI: 159 357

'JUST COPY AND PASTE AND CHANGE THE "X" TO "O" FOR THE O SIDE

If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Or Button4.Text = "X" And Button5.Text = "X" And _ Button6.Text = "X"  Or Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Or Button1.Text = "X" And_ Button4.Text = "X" And  Button7.Text = "X"  Or Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Or _ Button3.Text = "X" And Button6.Text = "X"  And  Button9.Text = "X" Or Button1.Text = "X" And Button5.Text = "X" And _ Button9.Text = "X" Or  Button3.Text = "X"  And Button5.Text = "X" And Button7.Text = "X" Then

MsgBox("X win")

Label5.Text += 1

Turn = 1

Label2.Text = "X"

reset()

bug.start()

End If

DRAW_TICK

If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _

And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _

And Button9.Enabled = False Then

DRAW.Stop()

MsgBox("Its draw!!!")

reset()

bug.Start()

DRAW.Start()

End If

bug_tick

reset()

bug.stop

reset button

reset()

bug.Start()

Turn = 1 #2 false

Label#Text = "X"


'Ill be Making a Computer Mode sooner or later its a lot harder


--

Creator envisioning stuff. Random stuff.

~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o

Go to the forums here

Go to my Youtube Channel here or Subscribe

~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o~o


May 27, 2011 at 5:48 AM Flag Quote & Reply

You must login to post.