收藏 分销(赏)

VB制作拼图游戏.docx

上传人:s4****5z 文档编号:8925932 上传时间:2025-03-08 格式:DOCX 页数:9 大小:183.66KB 下载积分:10 金币
下载 相关 举报
VB制作拼图游戏.docx_第1页
第1页 / 共9页
VB制作拼图游戏.docx_第2页
第2页 / 共9页


点击查看更多>>
资源描述
《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 Command4.Picture = Command5.Picture Command5.Picture = Command11.Picture End If If Command6.Picture = Command11.Picture Then Command6.Picture = Command5.Picture Command5.Picture = Command11.Picture End If If Command8.Picture = Command11.Picture Then Command8.Picture = Command5.Picture Command5.Picture = Command11.Picture End If End Sub Private Sub Command6_Click() If Command3.Picture = Command11.Picture Then Command3.Picture = Command6.Picture Command6.Picture = Command11.Picture End If If Command5.Picture = Command11.Picture Then Command5.Picture = Command6.Picture Command6.Picture = Command11.Picture End If If Command9.Picture = Command11.Picture Then Command9.Picture = Command6.Picture Command6.Picture = Command11.Picture End If End Sub Private Sub Command7_Click() If Command4.Picture = Command11.Picture Then Command4.Picture = Command7.Picture Command7.Picture = Command11.Picture End If If Command8.Picture = Command11.Picture Then Command8.Picture = Command7.Picture Command7.Picture = Command11.Picture End If End Sub Private Sub Command8_Click() If Command5.Picture = Command11.Picture Then Command5.Picture = Command8.Picture Command8.Picture = Command11.Picture End If If Command7.Picture = Command11.Picture Then Command7.Picture = Command8.Picture Command8.Picture = Command11.Picture End If If Command9.Picture = Command11.Picture Then Command9.Picture = Command8.Picture Command8.Picture = Command11.Picture End If End Sub Private Sub Command9_Click() If Command6.Picture = Command11.Picture Then Command6.Picture = Command9.Picture Command9.Picture = Command11.Picture End If If Command8.Picture = Command11.Picture Then Command8.Picture = Command9.Picture Command9.Picture = Command11.Picture End If End Sub 【应该看得出来,这里的算法只有一个:判断某个按钮相邻的Command显示图片是否为“空白”,若是,则交换图片显示,但要注意,这里还要引入第三个Command当做“中转站”,这其实和C++里面交换某两个变量的值是一个道理,如果没有这个媒介,那么图片交换两次,最终会没有变化。】
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服