查看: 1663|回复: 0
|
[请教] 有谁会用 vb.net 制作西洋棋游戏吗?
[复制链接]
|
|
我的final project 是要在 pocket pc 作一个西洋棋游戏. 我是用 vs.net 里的 vb.net编辑游戏! 但没有一个很好的concept 或 logic..所以不知道怎样接下去, 请各位提点提点!
我现在处于混乱状态,不知道怎样作一个board 和 棋子如何被知道它的位子???
1. 用 control array
code:
Dim board(7,7) As PictureBox
Sub BoardShow()
Dim xAxis As Integer, yAxis As Integer
Dim i As Integer = 20, j As Integer = 20
For yAxis = 0 To 7
For xAxis = 0 To 7
Board(xAxis, yAxis) = New PictureBox
Board(xAxis, yAxis).Size = New Size(25, 25)
Board(xAxis, yAxis).Location = New Point(20 + (xAxis * 25), 20 + (yAxis * 25))
Board(xAxis, yAxis).Text = "P" & xAxis & yAxis
Me.Controls().Add(Board(xAxis, yAxis))
If (xAxis + yAxis) Mod 2 = 0 Then
Board(xAxis, yAxis).Image = New Bitmap(ApplicationLocation() & "\whiteTile.jpg")
ElseIf (xAxis + yAxis) Mod 2 <> 0 Then
Board(xAxis, yAxis).Image = New Bitmap(ApplicationLocation() & "\silverTile.jpg")
End If
AddHandler Board(xAxis, yAxis).Click, AddressOf PictureBoxClick
Next
Next
End Sub
虽然可以用control array create picture box 但当run time user click 随便一个picturebox 时, 要如何才可以知道哪一个picturebox 被click ( Location )?? 例如:user click picturebox "p23" (board(2,3))时, 如何知道它是 board(2,3)?? 因为board是用code create 的!!
到底该怎么办?
2. drag and drop picturebox 到 form 里,在design form 里加图片. 但picturebox 不可以用control array, 所以当user click 时,怎样知道它的 location??
有谁能够帮帮忙, 给些意见?有什么其他方法作西洋棋游戏吗? |
|
|
|
|
|
|
| |
本周最热论坛帖子
|