您的位置:广东在线游戏网 > 游戏攻略 > 用VB制作拼图游戏-用VB制作拼图游戏,求代码

用VB制作拼图游戏-用VB制作拼图游戏,求代码

作者:广东在线游戏网日期:

返回目录:游戏攻略


Dim a(0 To 5) As Integer

Private Sub crearnd() '随机分配分割后的图片
Randomize '注意这里放在循e5a48de588b67a64337环是不同的,可是注意这里有时候图片放不满
For i = 0 To 5
a(i) = Int(Rnd * 6)
If i >= 2 Then
For j = 0 To i - 1
If a(j) = a(i) Then
i = i - 1 '注意这里可以控制i的值,也就是说可以控制For i = 0 To 5里i的值
End If
Next
End If
Next
End Sub

Private Sub Form_Load() '为什么把Picture2(i).Width 改为Picture2(i).scaleWidth不行?
For i = 0 To 5
Picture2(i).Width = Picture1.Width / 3
Picture2(i).Height = Picture1.Height / 2
Next i
End Sub

Private Sub spi_CLICK() 'imagebox没有paintpicture方法
crearnd
Picture2(a(0)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(1)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(2)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(3)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(4)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(5)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(0).Move Picture1.Width, 0
Picture2(1).Left = Picture1.Width + Picture2(0).Width: Picture2(1).Top = 0
Picture2(2).Left = Picture1.Width + Picture2(0).Width + Picture2(1).Width: Picture2(2).Top = 0
Picture2(3).Left = Picture1.Width: Picture2(3).Top = Picture2(0).Height
Picture2(4).Left = Picture1.Width + Picture2(3).Width: Picture2(4).Top = Picture2(1).Height
Picture2(5).Left = Picture1.Width + Picture2(3).Width + Picture2(4).Width: Picture2(5).Top = Picture2(2).Height
End Sub

Private Sub Picture2_DragDrop(index As Integer, Source As Control, X As Single, Y As Single) '注意这里用Picture2(index)_DragDrop是错误的,这里可以自动识别index,比如在窗体加一个text,则会显示对象的值
Dim PIC As StdPicture
Set PIC = Source.Image
Set Source.Picture = Picture2(index).Image
Set Picture2(index).Picture = PIC '为什么把picture换为image就不行

End Sub

要工程文件的话给个邮箱

Private Declare Function SetParent Lib ″user32″ _(ByVal hWndChild As Long,ByVal hWndNewParent As Long) As Long '利用api函数setparent实现控件的移动
Private Sub Command1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)
Static w 'w为picture1控件数组的索引号(即index)
If w = 3 Then w = -1
w = w + 1
Select Case w
Case 0 '把command1从第一个7a686964616fe59b9ee7ad94334图片框移到第二个内
Call SetParent(Command1.hWnd,Picture1(1).hWnd)
Case 1 '把command1从第二个图片框移到第三个内
Call SetParent(Command1.hWnd,Picture1(2).hWnd)
Case 2 '把command1从第三个图片框移到第四个内
Call SetParent(Command1.hWnd,Picture1(3).hWnd)
Case 3 '把command1从第四个图片框移到第一个内
Call SetParent(Command1.hWnd,Picture1(0).hWnd)
End Select
End Sub
首先这是个非常复杂的编程,其次636f70797a686964616f339是这个编程很复杂,最后是这是个很艰难的决定。
应该是这样,代码如下:
Private Sub DadiZs()
Dim t As Double, Itp As Double, X0 As Double, N As Double, L0 As Double
Dim V As Double, ll As Double, W As Double, M As Double
Lat = Radian(Lat)
Lon = Radian(Lon)
L0 = Radian(Lo)
If Tq = 0 Then
a = 6378245
b = 6356863.01877305
ep = 0.006693421622966
ep1 = 0.006738525414683
f = (a - b) / a
c = a ^ 2 / b
d = b ^ 2 / a
X0 = 111134.8611 * (Lat * 180# / Pi) - (32005.7799 * Sin(Lat) + 133.9238 * (Sin(Lat)) ^ 3 + 0.6973 * (Sin(Lat)) ^ 5 + 0.0039 * (Sin(Lat)) ^ 7) * Cos(Lat)
'X0 = 111134.8611 * (Lat * 180# / Pi) - (32005.7798 * Sin(Lat) + 133.9238 * (Sin(Lat)) ^ 3 + 0.6972 * (Sin(Lat)) ^ 5 + 0.0039 * (Sin(Lat)) ^ 7) * Cos(Lat)

Else
a = 6378140
b = 6356755.28815753
ep = 0.006694384999588
ep1 = 0.006739501819473
f = (a - b) / a
c = a ^ 2 / b
d = b ^ 2 / a
X0 = 111133.0047 * (Lat * 180 / Pi) - (32009.8575 * Sin(Lat) + 133.9602 * (Sin(Lat)) ^ 3 + 0.6976 * (Sin(Lat)) ^ 5 + 0.0039 * (Sin(Lat)) ^ 7) * Cos(Lat)
End If
ll = Lon - L0
t = Tan(Lat)
Itp = ep1 * Cos(Lat) ^ 2
W = Sqr(1 - ep * Sin(Lat) ^ 2)
V = Sqr(1 + ep1 * Cos(Lat) ^ 2)
M = c / V ^ 3
N = a / W
'x = X0 + N * t * (Cos(Lat)) ^ 2 * ll ^ 2 / 2 + N * t * (5 - t * t + 9 * Itp + 4 * Itp * Itp) * (Cos(Lat)) ^ 4 * ll ^ 4 / 24 + N * t * (61 - 58 * t ^ 2 + t ^ 4 + 270 * Itp - 330 * t ^ 2 * Itp) * (Cos(Lat)) ^ 6 * ll ^ 6 / 720 + N * t * (1385 - 3111 * t ^ 2 + 543 * t ^ 4 - t ^ 6) * Cos(Lat) ^ 8 * ll ^ 8 / 40320
x = X0 + N * t * (Cos(Lat)) ^ 2 * ll ^ 2 / 2 + N * t * (5 - t * t + 9 * Itp ^ 2 + 4 * Itp ^ 4) * (Cos(Lat)) ^ 4 * ll ^ 4 / 24 + N * t * (61 - 58 * t ^ 2 + t ^ 4 + 270 * Itp ^ 2 - 330 * t ^ 2 * Itp ^ 2) * (Cos(Lat)) ^ 6 * ll ^ 6 / 720 + N * t * (1385 - 3111 * t ^ 2 + 543 * t ^ 4 - t ^ 6) * Cos(Lat) ^ 8 * ll ^ 8 / 40320

y = N * Cos(Lat) * ll + N * (1 - t * t + Itp) * (Cos(Lat)) ^ 3 * ll ^ 3 / 6 + N * (5 - 18 * t * t + t ^ 4 + 14 * Itp - 58 * Itp * t * t) * (Cos(Lat)) ^ 5 * ll ^ 5 / 120 + N * (61 - 479 * t ^ 2 + 179 * t ^ 4 - t ^ 6) * Cos(Lat) ^ 7 * ll ^ 7 / 5040
r = Sin(Lat) * ll + Sin(Lat) * (Cos(Lat)) ^ 2 * ll ^ 3 * (1 + 3 * Itp + 2 * Itp ^ 2) / 3 + Sin(Lat) * (Cos(Lat)) ^ 4 * ll ^ 5 * (2 - t * t) / 15
r = Degree(r)
y = y + 500000#
End Sub

Private Sub DadiFs()
Dim t As Double, Itp As Double, X0 As Double, Bf As Double, N As Double
Dim v As Double, ll As Double, W As Double, M As Double, L0 As Double
L0 = Radian(Lo)
X0 = x * 0.000001
y = y - 500000#
If Tq = 0 Then
a = 6378245
b = 6356863.01877305
ep = 0.006693421622966
ep1 = 0.006738525414683
f = (a - b) / a
c = a ^ 2 / b
d = b ^ 2 / a
If X0 < 3 Then
Bf = 9.04353301294 * X0 - 0.00000049604 * X0 ^ 2 - 0.00075310733 * X0 ^ 3 - 0.00000084307 * X0 ^ 4 - 0.00000426055 * X0 ^ 5 - 0.00000010148 * X0 ^ 6
ElseIf X0 < 6 Then
Bf = 27.11115372595 + 9.02468257083 * (X0 - 3) - 0.00579740442 * (X0 - 3) ^ 2 - 0.00043532572 * (X0 - 3) ^ 3 + 0.00004857285 * (X0 - 3) ^ 4 + 0.00000215727 * (X0 - 3) ^ 5 - 0.00000019399 * (X0 - 3) ^ 6
End If
Else
a = 6378140
b = 6356755.28815753
ep = 0.006694384999588
ep1 = 0.006739501819473
f = (a - b) / a
c = a ^ 2 / b
d = b ^ 2 / a
If X0 < 3 Then
Bf = 9.04369066313 * X0 - 0.00000049618 * X0 ^ 2 - 0.00075325505 * X0 ^ 3 - 0.0000008433 * X0 ^ 4 - 0.00000426157 * X0 ^ 5 - 0.0000001015 * X0 ^ 6
ElseIf X0 < 6 Then
Bf = 27.11162289465 + 9.02483657729 * (X0 - 3) - 0.00579850656 * (X0 - 3) ^ 2 - 0.00043540029 * (X0 - 3) ^ 3 + 0.00004858357 * (X0 - 3) ^ 4 + 0.00000215769 * (X0 - 3) ^ 5 - 0.00000019404 * (X0 - 3) ^ 6
End If
End If
Bf = Bf * Pi / 180#
t = Tan(Bf)
Itp = ep1 * Cos(Bf) ^ 2
W = Sqr(1 - ep * Sin(Bf) ^ 2)
v = Sqr(1 + ep1 * Cos(Bf) ^ 2)
M = c / v ^ 3
N = a / W
Lat = Bf - 0.5 * v ^ 2 * t * ((y / N) ^ 2 - (5 + 3 * t * t + Itp - 9 * Itp * t * t) * (y / N) ^ 4 / 12 + (61 + 90 * t * t + 45 * t ^ 4) * (y / N) ^ 6 / 360)
ll = ((y / N) - (1 + 2 * t * t + Itp) * (y / N) ^ 3 / 6 + (5 + 28 * t * t + 24 * t ^ 4 + 6 * Itp + 8 * Itp * t * t) * (y / N) ^ 5 / 120) / Cos(Bf)
r = y * t / N - y ^ 3 * t * (1 + t * t - Itp) / (3 * N ^ 3) + y ^ 5 * t * (2 + 5 * t * t + 3 * t ^ 4) / (15 * N ^ 5)
Lat = Degree(Lat)
Lon = Degree(L0 + ll)
r = Degree(r)
End Sub
Public Const Pi = 3.149, p = 206264.806
Public Cktq As String

Public Function Radian(a As Double) As Double
Dim Ro As Double
Dim c As Double
Dim Fs As Double
Dim Ib As Integer
Dim Ic As Integer
If a < 0 Then a = -a: t = 1
Ro = Pi / 180#
Ib = Int(a)
c = (a - Ib) * 100#
Ic = Int(c + 0.000000000001)
Fs = (c - Ic) * 100#
If t = 1 Then Radian = -(Ib + Ic / 60# + Fs / 3600#) * Ro Else Radian = (Ib + Ic / 60# + Fs / 3600#) * Ro
End Function
Public Function Degree(a As Double) As Double
Dim Bo As Double
Dim Fs As Double
Dim Im As Integer
Dim Id As Integer
If a < 0 Then a = -a: t = 1
Bo = a
Call DMS(Bo, Id, Im, Fs)
If t = 1 Then Degree = -(Id + Im / 100# + Fs / 10000#) Else Degree = Id + Im / 100# + Fs / 10000#
End Function
Public Sub DMS(a As Double, Id As Integer, Im As Integer, Fs As Double)
Dim Bo As Double
Dim c As Double
c = a
c = 180# / Pi * c
Id = Int(c)
Bo = (c - Id) * 60
Im = Int(Bo)
Fs = (Bo - Im) * 60
End Sub
Public Function Qw(a As Double, Ws As Integer) As Double
Qw = Int(a * 10 ^ Ws + 0.5) / 10 ^ Ws
End Function

Dim a(0 To 5) As Integer

Private Sub crearnd() '随机分配分636f7079e799bee5baa6e79fa5e98193330割后的图片
Randomize
For i = 0 To 5
a(i) = Int(Rnd * 6)
If i >= 2 Then
For j = 0 To i - 1
If a(j) = a(i) Then
i = i - 1
End If
Next
End If
Next
End Sub

Private Sub Form_Load()
For i = 0 To 5
Picture2(i).Width = Picture1.Width / 3
Picture2(i).Height = Picture1.Height / 2
Next i
End Sub

Private Sub spi_CLICK()
crearnd
Picture2(a(0)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(1)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(2)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(3)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(4)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(5)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(0).Move Picture1.Width, 0
Picture2(1).Left = Picture1.Width + Picture2(0).Width: Picture2(1).Top = 0
Picture2(2).Left = Picture1.Width + Picture2(0).Width + Picture2(1).Width: Picture2(2).Top = 0
Picture2(3).Left = Picture1.Width: Picture2(3).Top = Picture2(0).Height
Picture2(4).Left = Picture1.Width + Picture2(3).Width: Picture2(4).Top = Picture2(1).Height
Picture2(5).Left = Picture1.Width + Picture2(3).Width + Picture2(4).Width: Picture2(5).Top = Picture2(2).Height
End Sub

Private Sub Picture2_DragDrop(index As Integer, Source As Control, X As Single, Y As Single)
Dim PIC As StdPicture
Set PIC = Source.Image
Set Source.Picture = Picture2(index).Image
Set Picture2(index).Picture = PIC
End Sub
在窗体上建立一个picture1和一个picture2(index)控件数组,总共包含6个图片框,然后给所有的图片框的autoredraw属性设置为true,就ok了,费了我好的劲,有问题再给我说
至于你要求的界面,我没看见你的图啊

已经发送,请查收

相关阅读

关键词不能为空

标签导航

DNF疲劳药水可以用几次 DNF抗疲劳药水一天能吃几个? 亲,地下城与勇士一天可以用几次疲劳药呢?最好的疲劳药一个能补... DNF疲劳药每天最多可以用几个 杨过和小龙女是怎么中情花毒的 《神雕侠侣》中的小龙女跳下悬崖后,情花毒是怎样被解的? 《神雕侠侣》里小龙女跳下悬崖16年以后杨过的左手为啥无敌... 《神雕侠侣》中小龙女跳崖后的十六年里面,杨过是怎么过的?他都... xbox360荒野大镖客r星过后就黑屏打不开 xbox360荒野大镖客不只有缘为什么一进去就失败了 XBOX360玩荒野大镖客救赎读取时卡住了 XBOX360 荒野大镖客怎么保存 英雄联盟牛头怎么连招具体怎么用 LOL牛头技能W和Q怎样才能连放? lol牛头连招技巧? 英雄联盟牛头酋长怎么玩?怎么放连招 用VB制作拼图游戏 求VB编写拼图游戏的代码 vb拼图游戏源码 【急】如何用VB制作拼图游戏 小游戏:梦幻西游快乐大冒险怎么走到一个地方就动不了了 这里有一个关于梦幻西游快乐大冒险小游戏的问题!!! 梦幻西游快乐大冒险 梦幻西游快乐大冒险的结局 找电影!!!!日本动画!! 找日本动画片! 找三部日本漫画(动画)!!!!!!!!! 找好看的日本动画片 LOL男枪出装攻略推荐 LOL男枪怎么玩 lol求男枪对线攻略 LOL上单男枪怎么打 Lol 男枪攻略 注册网络公司需要什么条件???? IP网是什么?就是互联网吗? 谈谈对网络的看法 家里宽带被人蹭网如何修改密码? 宠物小精灵伊布进化图,完整 伊布进化仙精灵的图片及属性 神奇宝贝中的伊布的进化图 伊布一共有几种进化?这图是真的吗? 求男主是间谍杀手之类的,有目的的接近女主最后相恋的电影或电视... 超胆侠女主角到底死了没有? 夜魔侠结尾时主角看到的盲文项链是谁送的啊 求一本小说:男主角好像特工还是雇佣兵之类的,有一次完成任务的... lol末日使者的曾经的技能数据 英雄联盟末日使者技能 LOL邪恶小法师、末日使者技能详细介绍,可以复制不要网址 lol求大神:末日使者的技能我看不懂啊!求解释(尤其是q)! 皮皮岛有什么好玩的地方,皮皮岛旅游攻略 泰国皮皮岛上有哪些可玩的地方?最适合待几天 泰国皮皮岛有什么好玩的吗? 皮皮岛旅游住哪里最合适 神武 1个小精灵能刷出35点属性吗 神武小精灵有什么用?