tick tack toe game
tick tack toe game
tick tack toe game
tick tack toe game
tick tack toe game
tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game
tick tack toe game tick tack toe game
tick tack toe game
Go Back  Xtreme Visual Basic Talk > > > tick tack toe game


Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2004, 11:26 AM
zeroflightless1 zeroflightless1 is offline
Newcomer
 
Join Date: Jan 2004
Posts: 11
Default tick tack toe game


Im makeing a tic tac toe game for fun each spot where u make ur mark is a frame with 2 cmd butons one is x and the other is o then there is lable that when u clikc the command button u click will have th appropriate mark come up. what i want to know is should i use the lbl or sum thin else(what?) and i dotnt know what kind of code i should use to make each command button activate a diff pic.Any and all suggestions are worth while
plz help

Ps what is the code for refreshing a form to its origonal state?

Reply With Quote
  #2  
Old 01-08-2004, 12:51 PM
Iceplug's Avatar
Iceplugtick tack toe game Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

"the command button "
are you using VB6 or VB.NET?

I would suppose that you can just declare a Boolean variable in your Form class and, in the label's Click event, if this Boolean variable is True, then make an X, otherwise make an O.
Then, invert the Boolean value with the Not operator.

For refreshing a form, just create a new instance of it.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 01-09-2004, 10:17 AM
zeroflightless1 zeroflightless1 is offline
Newcomer
 
Join Date: Jan 2004
Posts: 11
Default

im using vb 6.0

what do i do to have the 2 differant marks come up and fill the same space?
Reply With Quote
  #4  
Old 01-09-2004, 11:12 AM
CAlex CAlex is offline
Junior Contributor
 
Join Date: Nov 2003
Posts: 373
Default

Quote:
Originally Posted by zeroflightless1
im using vb 6.0

what do i do to have the 2 differant marks come up and fill the same space?


*confused*
two marks fill up the same space?
like two lines on a circle?
Code:
'if you are using buttons then private sub command1_click() if command1.caption="" then if x then command1.caption="x" else command1.caption="o" end if end if end sub
Reply With Quote
  #5  
Old 01-09-2004, 12:52 PM
passel's Avatar
passeltick tack toe game passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

My personal opinion is that it is better to learn Visual Basic to write a
game, than to write a game to learn Visual Basic.
Start with any of the basic controls and learn what it does and how you
might use it. You can write a simple Tic-Tac-Toe game just using
command buttons, but you may prefer picture boxes, or just drawing
on the form directly.

So start with the basics.
What does a label control do?
What does a picture control do?
What does a command button do?
What methods are available to draw with?
Investigate the Line method, and the Circle method.
How does the MouseDown event handler work, and what can I do with it?
Etc…
Once you know some of the tools, the fun comes in deciding how to
apply them to solve your task.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #6  
Old 01-09-2004, 03:45 PM
CAlex CAlex is offline
Junior Contributor
 
Join Date: Nov 2003
Posts: 373
Default

My personal opinion is that it is better to learn Visual Basic and write programs at the same time, when you have a problem, just ask or search, it's fast, you learn all the practical things, and fun too.
I learned vb like that, and i didn't even have a decent tutorial, but i found a good tutorial recently
http://graphicsmagician.com/vbcourse/index.htm
Reply With Quote
  #7  
Old 01-09-2004, 04:47 PM
hedgehog24's Avatar
hedgehog24 hedgehog24 is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Surrey, UK
Posts: 309
Default

Quote:
Originally Posted by CAlex
My personal opinion is that it is better to learn Visual Basic and write programs at the same time, when you have a problem, just ask or search, it's fast, you learn all the practical things, and fun too.
I learned vb like that, and i didn't even have a decent tutorial, but i found a good tutorial recently
http://graphicsmagician.com/vbcourse/index.htm



I don't think passel was suggesting you didn't write programs while learning if that's that what you were suggesting, just that you didn't write games as even simple games are likely to require a solid understanding of the principles of programming and a good understanding of the language you are writing the game in.

I think the idea is to write programs (otherwise you cannot learn) but keep them simple until you understand the language/control etc that you are using fully.
__________________
D'oh
Reply With Quote
  #8  
Old 03-11-2004, 04:02 AM
abcdefghijkl abcdefghijkl is offline
Newcomer
 
Join Date: Mar 2004
Posts: 11
Default

what luck. I know I'm 4 months late, but I'm sure there will still be beginners reading this now. I was bored too and made a Tic Tac Toe game a couple of nights ago. On the form I have 9 "command buttons", and three labels for keeping track of who's winning. The top three buttons are tagged 00,01,02. Middle Row is 10,11,12. Last Row is 20,21,22. (Row means horizontal for the braindead people out there) Note: this is in Visual Basic .Net. Shouldnt be too much of a problem, but just a warning. Heres the code:

Code:
Windows Form Designer Blah Blah Goes Here
Dim ttt(2, 2) As Char 'this is a global vari
    Sub button_handling(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click
        Dim temp As Button = sender 'basically creates a copy of the button clicked
        Static chrplayer As Char = "x"
        If temp.Text <> Nothing Then 'if button has already been selected
            Exit Sub
        End If
        temp.Text = chrplayer
        Dim index As String
        index = temp.Tag 'gets which button was clicked. Remember, First Row First Button
'is 00, First Row Second Button is 01, so this is an effective way to get which
'button was clicked in a numerical form.
        Dim intx As Integer = Val(index.Chars(0))
        Dim inty As Integer = Val(index.Chars(1))
        storemove(intx, inty, chrplayer, ttt)
        If iswinner(ttt) = "x" Then
            MessageBox.Show("Winner!")
            lblx.Text = lblx.Text + 1
            newgame()
            Exit Sub
        ElseIf iswinner(ttt) = "o" Then
            MessageBox.Show("Winner!")
            lblo.Text = lblo.Text + 1
            newgame()
            Exit Sub
        Else
            isfull(ttt)
            If chrplayer = "x" Then
                chrplayer = "o"
            Else
                chrplayer = "x"
            End If
        End If
    End Sub
    Sub storemove(ByVal intX As Integer, ByVal intY As Integer, ByVal chrPlayer As Char, ByRef ttt(,) As Char)
        ttt(intX, intY) = chrPlayer
    End Sub
    Function isfull(ByVal ttt(,) As Char) As Boolean
        If ttt(0, 0) <> Nothing And ttt(0, 1) <> Nothing And ttt(0, 2) <> Nothing And ttt(1, 0) <> Nothing And ttt(1, 1) <> Nothing And ttt(1, 2) <> Nothing And ttt(2, 0) <> Nothing And ttt(2, 1) <> Nothing And ttt(2, 2) <> Nothing Then
'probably inefficent, but it works.
            MsgBox("Tie!")
            lblcat.Text = lblcat.Text + 1
            newgame()
        End If
    End Function
    Sub newgame()
        Button1.Text = Nothing
        Button2.Text = Nothing
        Button3.Text = Nothing
        Button4.Text = Nothing
        Button5.Text = Nothing
        Button6.Text = Nothing
        Button7.Text = Nothing
        Button8.Text = Nothing
        Button9.Text = Nothing
        Dim a As Integer
        For a = 0 To 2
            ttt(a, 0) = ""
            ttt(a, 1) = ""
            ttt(a, 2) = ""
        Next a
    End Sub
    Function iswinner(ByRef ttt(,) As Char) As Char
        If ttt(0, 0) = "x" And ttt(1, 1) = "x" And ttt(2, 2) = "x" Then
            Return "x"
        End If
        If ttt(0, 0) = "o" And ttt(1, 1) = "o" And ttt(2, 2) = "o" Then
            Return "o"
        End If
        If ttt(0, 0) = "x" And ttt(0, 1) = "x" And ttt(0, 2) = "x" Then
            Return "x"
        End If
        If ttt(0, 0) = "o" And ttt(0, 1) = "o" And ttt(0, 2) = "o" Then
            Return "o"
        End If
        If ttt(1, 0) = "x" And ttt(1, 1) = "x" And ttt(1, 2) = "x" Then
            Return "x"
        End If
        If ttt(1, 0) = "o" And ttt(1, 1) = "o" And ttt(1, 2) = "o" Then
            Return "o"
        End If
        If ttt(2, 0) = "x" And ttt(2, 1) = "x" And ttt(2, 2) = "x" Then
            Return "x"
        End If
        If ttt(2, 0) = "o" And ttt(2, 1) = "o" And ttt(2, 2) = "o" Then
            Return "o"
        End If
        If ttt(2, 0) = "x" And ttt(1, 1) = "x" And ttt(0, 2) = "x" Then
            Return "x"
        End If
        If ttt(2, 0) = "o" And ttt(1, 1) = "o" And ttt(0, 2) = "o" Then
            Return "o"
        End If
        If ttt(0, 0) = "x" And ttt(1, 0) = "x" And ttt(2, 0) = "x" Then
            Return "x"
        End If
        If ttt(0, 0) = "o" And ttt(1, 0) = "o" And ttt(2, 0) = "o" Then
            Return "o"
        End If
        If ttt(0, 1) = "x" And ttt(1, 1) = "x" And ttt(2, 1) = "x" Then
            Return "x"
        End If
        If ttt(0, 1) = "o" And ttt(1, 1) = "o" And ttt(2, 1) = "o" Then
            Return "o"
        End If
        If ttt(0, 2) = "x" And ttt(1, 2) = "x" And ttt(2, 2) = "x" Then
            Return "x"
        End If
        If ttt(0, 2) = "o" And ttt(1, 2) = "o" And ttt(2, 2) = "o" Then
            Return "o"
        End If
    End Function
I know this is probably the most inefficient, bad programming styled, uncommented thing you have ever seen, but hey, its better than nothing right?

Last edited by abcdefghijkl; 03-11-2004 at 04:35 AM.
Reply With Quote
  #9  
Old 03-11-2004, 12:53 PM
spike4366 spike4366 is offline
Newcomer
 
Join Date: Feb 2004
Posts: 23
Default

Well I'm doing the same thing in my visual basic class i'm making it so you drag and drop the X's and O's in desired box dont know if thats what you did but i'll post the code when i finish
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
10 Steps to Designing a Game Chrono23 Game Programming 91 10-17-2010 10:46 PM
Game Loop Tutorial Optikal Tutors' Corner 0 03-12-2003 10:19 PM
SolarQuest game project jsharbour Game Programming 53 01-10-2003 05:21 PM
Warbirds 1944: Complete WinAPI/DirectX Game jsharbour Game Programming 21 09-10-2002 05:42 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
tick tack toe game
tick tack toe game
tick tack toe game tick tack toe game
tick tack toe game
tick tack toe game
tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game tick tack toe game
tick tack toe game
tick tack toe game
 
tick tack toe game
tick tack toe game
 
-->