Fps Haxers
Please Login to view the forums. Thank you.


Game Enhancements. Free, Safe, Working and Trusted.
 
HomePortalFAQRegisterLog in
Welcome! Come join our Great Community. We are looking for Mods and Coders!
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Share | 
 

 [Tutorial}vb2008 Tic Tac Tow with comp settings

Go down 
AuthorMessage
KodeKing
New Member
New Member


Warning Bar :
Posts : 4
Join date : 2009-09-08

PostSubject: [Tutorial}vb2008 Tic Tac Tow with comp settings   Tue Sep 08, 2009 9:36 pm

Hello this is a Step-By-Step tutorial by: Kode King
i did not steal this tutorial from proworksproductions i am the same person
Tic Tac Toe with play vs Computer setting

===============================
Step 1
===============================
Create 13 Labels;
Create 10 buttons;
Create 1 Check Box;
Create 4 lines;
Create 3 Timers;

===============================
Step 2
===============================
Label button 10 "Play Again"
Put the text of label 3 to "Turn:"
Label The Checkbox "Play vs Computer"

===============================
Step 3
===============================
Place the 4 lines into the board for Tic Tac Toe
-|-|-
-|-|-

ok now place
Right colum:
Button 7 in bottom right corner
Button 1 above 7
Button 2 above 1

Middle Colum:
Button 3 on top
Button 4 in middle
Button 8 below 4

Left Colum:
Button 9 in bottom left corner
Button 6 above 9
Button 5 above 6
===============================
Step 4
===============================
Placing Labels:

Right Colum:
Place Label 10 over Button 7
Place Label 6 over Button 1
Place Label 5 over Button 2

Middle Colum:
Place Label 13 over Button 3
Place Label 8 over Button 4
Place Label 9 over Button 8

Left Colum:
Place Label 11 over Button 9
Place Label 7 over Button 6
Place Label 12 over Button 5

Not on Tic Tac Toe Playing Board:
Place Label Turn: Anywhere
Place Label4 to the right of Turn:

===============================
Step 5
===============================
Ok It's Time To Start Coding

Double Click on your form;

You now have this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
(Coding Goes Here)
End Sub

Code:
Label4.Text = "X"

All this does is Change The text of Label4 to X when the form opens
===============================
Step 6
===============================
Double Click Button 7

You now have this:
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
(Coding Goes Here)
End Sub

Code:

If Label4.Text = "X" Then
Label10.Text = "X"
Label4.Text = "O"
Else
Label10.Text = "O"
Label4.Text = "X"
End If
Button7.Visible = False

This Means That if you click the button and Label4's text is X then change the Text of Label 10 to X,(label 10 is the label over Button 7)then Change Label4's text to O meaning that its player O's turn

Then the else command comes up
This means That if the conditions of our if command were not true it will do these
Label10.Text = "O"
Label4.Text = "X"
That means instead of the space being a X it becomes an O
then it switches the turn back to X

Our Condition was:
If Label4.Text = "X" Then


This Ends our If Command:
End If
Then Button7.Visible = False
That makes it so the button cannot be clicked again untill the game is reset
===============================
Step 7
===============================
Repeat Step 6 for the Buttons on playing Field (Not the button Play Again)

Remember to change the label numbers
Ex:
Change Label10.Text = "O"
to
Label9.Text = "O"
etc...
Make Sure Its The Label Over The Button
===============================
Step 8
===============================
Reset Button:
Place Anywhere
Coding:
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True

This Resets All the Changes We did in our previous codes
Makes Buttons Visible;
Returns Labels To having No Text
change text on labels before this to have no text except Turn:
(We do this later because it would have made it hard to find what labels were over our buttons)
Back to top Go down
KodeKing
New Member
New Member


Warning Bar :
Posts : 4
Join date : 2009-09-08

PostSubject: Part 2   Tue Sep 08, 2009 9:37 pm

===============================
Step 9
===============================
Win Settings:
Double Click Timer 1, and put all of this

Code:

If Label12.Text = "X" And Label7.Text = "X" And Label11.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label12.Text = "X" And Label13.Text = "X" And Label5.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label7.Text = "X" And Label8.Text = "X" And Label6.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label11.Text = "X" And Label9.Text = "X" And Label10.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label13.Text = "X" And Label8.Text = "X" And Label9.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label5.Text = "X" And Label6.Text = "X" And Label10.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label12.Text = "O" And Label7.Text = "O" And Label11.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label12.Text = "O" And Label13.Text = "O" And Label5.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label7.Text = "O" And Label8.Text = "O" And Label6.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label11.Text = "O" And Label9.Text = "O" And Label10.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label13.Text = "O" And Label8.Text = "O" And Label9.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label5.Text = "O" And Label6.Text = "O" And Label10.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label12.Text = "O" And Label8.Text = "O" And Label10.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label5.Text = "O" And Label8.Text = "O" And Label11.Text = "O" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player O Won")
End If
If Label12.Text = "X" And Label8.Text = "X" And Label10.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If
If Label5.Text = "X" And Label8.Text = "X" And Label11.Text = "X" Then
Label4.Text = "X"
Label12.Text = ""
Label7.Text = ""
Label11.Text = ""
Label9.Text = ""
Label8.Text = ""
Label13.Text = ""
Label5.Text = ""
Label6.Text = ""
Label10.Text = ""
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
MsgBox("Player X Won")
End If

Try To figure That out yourself (just read the coding)if you have trouble ask me below in comments

===============================
Step 10
===============================
Double Click your Checkbox;

Put this:
Timer2.Enabled = True

That turns Timer 2 on when checked

===============================
Step 11
===============================
Ok Now this is the Computer Setting:
Change properties on Timer to Enabled False and interval 1
Double Click Timer 2

Put This Long Code in i will explain after:

A:
Dim rndnumber As Random
Dim number As Integer
rndnumber = New Random
number = rndnumber.Next(1, 9)
If Label4.Text = "O" Then
Button5.Visible = False
Button6.Visible = False
Button9.Visible = False
Button8.Visible = False
Button4.Visible = False
Button3.Visible = False
Button2.Visible = False
Button1.Visible = False
Button7.Visible = False
Else
Button5.Visible = True
Button6.Visible = True
Button9.Visible = True
Button8.Visible = True
Button4.Visible = True
Button3.Visible = True
Button2.Visible = True
Button1.Visible = True
Button7.Visible = True
End If
If number = 1 And Label4.Text = "O" And Label10.Text = "" Then
Label10.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 2 And Label4.Text = "O" And Label6.Text = "" Then
Label6.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 3 And Label4.Text = "O" And Label5.Text = "" Then
Label5.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 4 And Label4.Text = "O" And Label9.Text = "" Then
Label9.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 5 And Label4.Text = "O" And Label8.Text = "" Then
Label8.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 6 And Label4.Text = "O" And Label13.Text = "" Then
Label13.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 7 And Label4.Text = "O" And Label11.Text = "" Then
Label11.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 8 And Label4.Text = "O" And Label7.Text = "" Then
Label7.Text = "O"
Label4.Text = "X"
GoTo A
End If
If number = 9 And Label4.Text = "O" And Label12.Text = "" Then
Label12.Text = "O"
Label4.Text = "X"
GoTo A
End If

Ok What we just did was make a point in the coding (A) so that the code will loop and not just go once.

Ok then we made a Random Number Generator, Dim rndnumber As Random
Dim number As Integer
rndnumber = New Random
number = rndnumber.Next(1, 9)

Number is a Variable that held the value of the Random number We then made an if then statement for each number posibilities and assinged each number to a label basically that way it will change the text of the label its attached to if it is O's turn and the label has not been changed already
===============================
Step 12
===============================
Ok we are almost done double click timer3
Properties of timer 3 are Interval 1, Enabled True

Coding:
If CheckBox1.Checked = False Then
Timer2.Enabled = False
End If

This means that if the cumputer checkbox is unchecked it will go back to player vs player
it does this by disabling timer 2

===============================
Step 13
===============================
Change all buttons to flat (except Play Again button)
the flat properties and put border size to 0 then remove the text from them

This makes the buttons invisible

===============================
Tutorial By: KodeKing
Do Not redistribute This Tutorial
Video Tutorial will be up when i get a new mic
Post Questions Comments and Concerns below
Back to top Go down
 
[Tutorial}vb2008 Tic Tac Tow with comp settings
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Fps Haxers :: Programming :: Programming-
Jump to: