| 
| 
查看: 2554|回复: 5
 | 
如何用visual basic做online tic tac toe game
[复制链接] |  
 |  | 
 
| 各位大大,想请问下 我想做一个给2个人在不同电脑玩的tic tac toe game。。。请问大家有什么提示吗?还是有sample program for 电话的?我要参考用在我的program里面 我用的语言是visual basic
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 
 楼主|
发表于 2-9-2011 07:38 PM
|
显示全部楼层 
| 请问下会很难很大工程吗?我知道要做一个tic tac toe给自己玩很容易 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 5-9-2011 12:08 PM
|
显示全部楼层 
| 逻辑麻烦罢了,不过很多都有做,所以可以抄。。。 
 如果做给电话会很难,因为你是用visual basic。你可以做电脑的。
 
 小工程。。。。看你各人要求罢了
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 
 楼主|
发表于 13-9-2011 07:19 PM
|
显示全部楼层 
| 回复 3# win7qi 可以帮我看看这个loop statement有什么问题吗?我已经走头无路了 这个是我tic tac toe的9个button的code(我只copy四个 因为都一样的)我可以用while吗?希望有人明白我的问题Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 While turn = 1
 If PlayerO.Checked = True Then
 Button1.Text = "O"
 SerialPort.Write(Button1.Text) ‘这个command会把button 1 的text写进serial port
 Label2.Text = "X"
 ElseIf PlayerX.Checked = True Then
 Button1.Text = "X"
 SerialPort.Write(Button1.Text)
 Label2.Text = "O"
 End If
 End While
 turn += 1
 If turn > 2 Then
 turn = 1
 End If
 
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
 
 While turn = 1
 If PlayerO.Checked = True Then
 Button2.Text = "O"
 'SerialPort.Write(Button2.Text)
 Label2.Text = "X"
 ElseIf PlayerX.Checked = True Then
 Button2.Text = "X"
 'SerialPort.Write(Button2.Text)
 Label2.Text = "O"
 End If
 End While
 turn += 1
 If turn > 2 Then
 turn = 1
 End If
 
 
 Call win()
 
 Button2.Enabled = False
 
 
 
 
 
 End Sub
 
 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
 
 While turn = 1
 If PlayerO.Checked = True Then
 Button3.Text = "O"
 'SerialPort.Write(Button3.Text)
 Label2.Text = "X"
 ElseIf PlayerX.Checked = True Then
 Button3.Text = "X"
 'SerialPort.Write(Button3.Text)
 Label2.Text = "O"
 End If
 End While
 turn += 1
 If turn > 2 Then
 turn = 1
 End If
 
 
 Call win()
 
 Button3.Enabled = False
 
 
 
 End Sub
 
 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
 
 While turn = 1
 If PlayerO.Checked = True Then
 Button4.Text = "O"
 'SerialPort.Write(Button4.Text)
 Label2.Text = "X"
 ElseIf PlayerX.Checked = True Then
 Button4.Text = "X"
 'SerialPort.Write(Button4.Text)
 Label2.Text = "O"
 End If
 
 turn += 1
 If turn > 2 Then
 turn = 1
 End If
 End While
 
 Call win()
 
 Button4.Enabled = False
 End Sub
 
 。
 。
 。
 。
 。
 。
 
 Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
 Button1.Text = SerialPort.ReadExisting()   ’这个在我click了button1之后会让另外一个player那边的button出现同样的东西然后那个button不能按
 Button1.Enabled = False
 
 
 麻烦大家救救我啊!!想了一个礼拜还是不知道怎么办
 我现在的问题是 我只能按一次button罢了 好像 我是player1我按了button1 然后player 2那边也按了过后 到player1按button 这个时候 我是player1 然后我按的那些button都没有出东西了 怎么办?是我的loop有问题吗!!?请救我!!
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 14-9-2011 10:38 AM
|
显示全部楼层 
| 回复 4# CristianoRooney 
 
 ><" 我是 JAVA 的。。。 VB 我不会。。。不过你可以尝试这样
 
 switch( Button ){
 
 case 0;
 xxxxx;
 break;
 
 case 1;
 xxxxx;
 break;
 case 2;
 xxxxx;
 break;
 case 3;
 xxxxx;
 break;
 case 4;
 xxxxx;
 break;
 case 0;
 xxxxx;
 break;
 case 5;
 xxxxx;
 break;
 case 6;
 xxxxx;
 break;
 case 7;
 xxxxx;
 break;
 case 8;
 xxxxx;
 break;
 case 9;
 xxxxx;
 break;
 }
 | 
 |  |  |  |
 
|  |  |  
|  |  | 
 |  | 
 
 发表于 23-4-2012 02:03 PM
|
显示全部楼层 
| 回复 4# CristianoRooney 
 
 是mmu 的mini project吗?可以send给我吗?
 | 
 |  |  |  |
 
|  |  |  
|  |  |  |  | 
            本周最热论坛帖子 |