佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 2554|回复: 5

如何用visual basic做online tic tac toe game

[复制链接]
发表于 2-9-2011 05:12 PM | 显示全部楼层 |阅读模式
各位大大,想请问下 我想做一个给2个人在不同电脑玩的tic tac toe game。。。请问大家有什么提示吗?还是有sample program for 电话的?我要参考用在我的program里面
我用的语言是visual basic
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 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给我吗?
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 31-10-2025 11:57 AM , Processed in 0.106633 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表