vb.net小游戏代码 vb游戏代码大全( 六 )


End If
End If
End Sub
Private Sub Command1_Click()
List2.Clear ''清除棋谱
CurrentStep = 1
Call Initial
Call Display
End Sub
Private Sub Command2_Click()
Dim t As Boolean
Command2.Enabled = False
t:
Text1.Text = Str(Search(CurrentPlayer, Val(Text2.Text), True, 0))
Command2.Enabled = True
With BestLocate
t = DownChess(.Initx, .Inity, .ObjX, .ObjY, .x1, .y1)
Call Display
If t = True And IsLine(CurrentPlayer, .ObjX, .ObjY) Then Call MsgBox("我还想再吃一个"): GoTo t ''如果所下之棋还能吃子(连续吃)则再运算
End With
CurrentPlayer = NextCer(CurrentPlayer)
End Sub
Rem 移棋
Rem Sx,Sy:起点棋子Ex,Ey:终点棋子Ax,Ay:被吃子
Rem 如果有吃子则返回True
Private Function DownChess(Sx As Byte, Sy As Byte, ex As Byte, ey As Byte, Ax As Byte, Ay As Byte) As Boolean
ChessBoard(ex, ey) = ChessBoard(Sx, Sy)
ChessBoard(Sx, Sy) = 0
ChessBoard(Ax, Ay) = 0 ''清除被吃子
If Ax0 And Ay0 Then DownChess = True Else DownChess = False
Text3.Text = "第"Str(CurrentStep)"手 "Str(CurrentPlayer) + "方从"Str(Sx) + "," + Str(Sy) + "到" + Str(ex) + "," + Str(ey)_
"吃子 "Str(Ax)","Str(Ay)
CurrentStep = CurrentStep + 1
List2.AddItem Text3.Text
''下句:如果是黑方(101、102)
If Int(ChessBoard(ex, ey) / 100) = 1 Then
''下句:如果走到第一行则棋子变成102,威力加强
If ex = 1 Then ChessBoard(ex, ey) = 102
End If
''下句:如果是红方(201、202)
If Int(ChessBoard(ex, ey) / 100) = 2 Then
''下句:如果走到第八行则棋子变成202,威力加强
If ex = 8 Then ChessBoard(ex, ey) = 202
End If
End Function
Rem 运算一
Private Sub Command3_Click()
CurrentPlayer = 1
Call Command2_Click
End Sub
Rem 运算二
Private Sub Command4_Click()
CurrentPlayer = 2
Call Command2_Click
End Sub
Private Sub Command5_Click()
Call ReDisplay
End Sub
Private Sub Command6_Click()
If 人机模式 = False Then 人机模式 = True Else 人机模式 = False
If 人机模式 = False Then Command6.Caption = " 人机模式": Command6.ToolTipText = "当前模式:人人对战" Else Command6.Caption = " 休息模式": Command6.ToolTipText = "当前模式:人机对战"
End Sub
Private Sub Command7_Click()
End
End Sub
Rem 存谱
Private Sub Command8_Click()
On Error GoTo e
Dim i As Integer
Open InputBox("请输入文件名:") For Output As #1
For i = 0 To List2.ListCount - 1
Print #1, List2.List(i)
Next i
Close #1
Exit Sub
e:
Call MsgBox("存储错误!", vbOKOnly + 32, "提示:")
Err.Clear
Exit Sub
End Sub
Private Sub Form_Load()
人机模式 = False
cSel = 0
CurrentPlayer = 1
Call Command1_Click
End Sub
模块代码:
Type CHESSER
Chess As Byte''为何棋,在BestLocate则标明为何数组
Initx As Byte''起初棋的位置
Inity As Byte
ObjX As Byte''经运算后的落棋点
ObjY As Byte
x1 As Byte
y1 As Byte
Allow As Boolean''是否允许
End Type
vb.net小游戏代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb游戏代码大全、vb.net小游戏代码的信息别忘了在本站进行查找喔 。

推荐阅读