VB制作拼图游戏

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《VB制作拼图游戏:简单算法》1、首先按照截图把控件添加好!

(技巧:PS处理322*322的图片,划分切块,形成九个小图片,这里采用的是Jpg格式,然后采用Command按钮来显示这些图片,同学们也可以采用Label,是一样的,重点是鼠标单击事件!注意:添加九个Command按钮,一定要设置每个按钮的Height、Width、Top、Left值来完成对图片的吻合拼接,这样可以使界面看起来美观大方!)

2、界面的设计

这里很多同学习惯更改Command的Caption值来显示某些文本,但要注意,你

这里很可能为了美观会使用自己机子上单独安装的某些字体,这些字体拿到其他机子上是不生效的,那么怎么办呢?这里有个比较“笨拙的方法”——你可以利用Word工具打好想要显示的文本,设置个性字体,然后截图,插入到Command上面,这样的话,无论是什么字体,都可以显示了,因为图片的属性是无法更改的!这个方法同样可以用来美化Label!当然了,自己究竟怎么样设计,就靠想象力了,最终得到的效果是要有一个美观、简洁大方的界面!

3、算法设计(全部代码)

Dim Num As Integer

Private Sub Command1_Click()

If Command2.Picture = Command11.Picture Then

Command2.Picture = Command1.Picture

Command1.Picture = Command11.Picture

End If

If Command4.Picture = Command11.Picture Then

Command4.Picture = Command1.Picture

Command1.Picture = Command11.Picture

End If

End Sub

Private Sub Command11_Click()

MsgBox ("开发者:孔世明" & vbCrLf & "学院:信息科学与技术学院" & vbCrLf & "专业:

软件工程" & vbCrLf & "班级:软件一班" & vbCrLf & "学号:201213040117") End Sub

Private Sub Command12_Click()

Num = Num + 1

If Num = 1 Then

Command9.Picture = Command11.Picture

End If

If Num = 2 Then

MsgBox ("亲~~不能重复开始哦!~")

End If

If Num = 3 Then

MsgBox ("亲~~再说一次,不能重复开始!!")

End If

If Num > 3 Then

MsgBox ("请不要放弃治疗!!!")

End If

End Sub

Private Sub Command2_Click()

If Command1.Picture = Command11.Picture Then

Command1.Picture = Command2.Picture

Command2.Picture = Command11.Picture

End If

If Command3.Picture = Command11.Picture Then Command3.Picture = Command2.Picture Command2.Picture = Command11.Picture

End If

If Command5.Picture = Command11.Picture Then Command5.Picture = Command2.Picture Command2.Picture = Command11.Picture

End If

End Sub

Private Sub Command3_Click()

If Command2.Picture = Command11.Picture Then Command2.Picture = Command3.Picture Command3.Picture = Command11.Picture

End If

If Command6.Picture = Command11.Picture Then Command6.Picture = Command3.Picture Command3.Picture = Command11.Picture

End If

End Sub

Private Sub Command4_Click()

If Command1.Picture = Command11.Picture Then Command1.Picture = Command4.Picture Command4.Picture = Command11.Picture

End If

If Command5.Picture = Command11.Picture Then Command5.Picture = Command4.Picture Command4.Picture = Command11.Picture

End If

If Command7.Picture = Command11.Picture Then Command7.Picture = Command4.Picture Command4.Picture = Command11.Picture

End If

End Sub

Private Sub Command5_Click()

If Command2.Picture = Command11.Picture Then Command2.Picture = Command5.Picture Command5.Picture = Command11.Picture

End If

If Command4.Picture = Command11.Picture Then

相关文档
最新文档