📄 main.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
BackColor = &H00008000&
BorderStyle = 1 'Fixed Single
Caption = "Hanoi Towers"
ClientHeight = 6180
ClientLeft = 150
ClientTop = 540
ClientWidth = 8085
Icon = "Main.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 412
ScaleMode = 3 'Pixel
ScaleWidth = 539
StartUpPosition = 2 'CenterScreen
Tag = "1"
Begin VB.Timer Timer1
Interval = 1000
Left = 4260
Top = 180
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 285
Left = 0
TabIndex = 0
Top = 5895
Width = 8085
_ExtentX = 14261
_ExtentY = 503
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 4
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 3572
MinWidth = 3572
Text = "Level: 1"
TextSave = "Level: 1"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 3572
MinWidth = 3572
Text = "Time: 00:00:00"
TextSave = "Time: 00:00:00"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 3572
MinWidth = 3572
Text = "Moves: 0"
TextSave = "Moves: 0"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 3572
MinWidth = 3572
Text = "Min. Moves: 7"
TextSave = "Min. Moves: 7"
Key = ""
Object.Tag = ""
EndProperty
EndProperty
End
Begin VB.Label Label2
Caption = "Label2"
Height = 255
Left = 5730
TabIndex = 2
Top = 90
Visible = 0 'False
Width = 585
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Label1"
Height = 195
Left = 5790
TabIndex = 1
Top = 390
Visible = 0 'False
Width = 480
End
Begin VB.Image ImageRez
Height = 510
Left = 3390
Picture = "Main.frx":0442
Tag = "-1"
Top = 180
Visible = 0 'False
Width = 435
End
Begin VB.Image Image3
Height = 360
Index = 7
Left = 2820
Picture = "Main.frx":1034
Top = 4740
Width = 2400
End
Begin VB.Image Image3
Height = 360
Index = 6
Left = 2940
Picture = "Main.frx":3D76
Top = 4395
Width = 2160
End
Begin VB.Image Image3
Height = 360
Index = 5
Left = 3060
Picture = "Main.frx":6638
Top = 4050
Width = 1920
End
Begin VB.Image Image3
Height = 360
Index = 4
Left = 3180
Picture = "Main.frx":8A7A
Top = 3705
Width = 1680
End
Begin VB.Image Image3
Height = 360
Index = 3
Left = 3300
Picture = "Main.frx":AA3C
Top = 3360
Width = 1440
End
Begin VB.Image Image3
Height = 360
Index = 2
Left = 3420
Picture = "Main.frx":C57E
Top = 3015
Width = 1200
End
Begin VB.Image Image3
Height = 360
Index = 1
Left = 3555
Picture = "Main.frx":DC40
Top = 2670
Width = 960
End
Begin VB.Image Image3
Height = 360
Index = 0
Left = 3660
Picture = "Main.frx":EE82
Top = 2325
Width = 720
End
Begin VB.Image Image2
Height = 3600
Index = 2
Left = 6300
Picture = "Main.frx":FC44
Top = 1500
Width = 240
End
Begin VB.Image Image2
Height = 3600
Index = 1
Left = 3900
Picture = "Main.frx":12986
Top = 1500
Width = 240
End
Begin VB.Image Image2
Height = 3600
Index = 0
Left = 1500
Picture = "Main.frx":156C8
Top = 1500
Width = 240
End
Begin VB.Image Image1
Height = 510
Left = 1410
Picture = "Main.frx":1840A
Tag = "-1"
Top = 690
Width = 435
End
Begin VB.Menu mnuGame
Caption = "&Game"
Begin VB.Menu mnuNew
Caption = "&New game F2"
End
Begin VB.Menu mnuRestart
Caption = "&Restart level F3"
End
Begin VB.Menu mnuSep
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "E&xit"
End
End
Begin VB.Menu mnuTop
Caption = "&Top Scores"
End
Begin VB.Menu solut
Caption = "&Solution"
End
Begin VB.Menu mnuHelp
Caption = "&Help"
Begin VB.Menu mnuInst
Caption = "&Instruction F1"
End
Begin VB.Menu mnuSep1
Caption = "-"
End
Begin VB.Menu mnuAbout
Caption = "&About"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Dim topd(7) 'poziciii za crtanje
Dim cen(2) 'poziciii za crtanje
Dim poln(2)
Dim pozicija
Dim teg(2, 8) ' teg(shipka,pozicija na shipka)=golemina na teg
Dim t, t1 'Za ciklusi
Dim level
Dim moves
Dim vreme As Integer
Dim solut_b As Boolean
Private Sub zapisi()
Dim dd As String
dd = ""
For t = 0 To 11
dd = dd + Form5.Label3(t).Caption + Chr(5)
Next t
For t = 0 To 11
dd = dd + Form5.Label4(t).Caption + Chr(5)
Next t
For t = 0 To 11
Form5.Label5(t).Caption = Trim(Str(forma1(Form5.Label5(t).Caption)))
dd = dd + Form5.Label5(t).Caption + Chr(5)
Form5.Label5(t).Caption = Trim(forma(Form5.Label5(t).Caption))
Next t
Dim filenum As Integer
filenum = FreeFile
Open "C:\Windows\rezultati.DAT" For Output As filenum
Print #filenum, dd
Close filenum
End Sub
Private Sub solve(nn As Integer, a As Integer, C As Integer, B As Integer)
Dim dede
If nn = 1 Then
dede = pozicija - a
If dede = 1 Or dede = -2 Then
Call Form_KeyDown(37, 0)
Else
If dede = -1 Or dede = 2 Then Call Form_KeyDown(39, 0)
End If
Call Form_KeyDown(32, 0)
DoEvents
Sleep 250
dede = a - C
If dede = 1 Or dede = -2 Then
Call Form_KeyDown(37, 0)
Else
If dede = -1 Or dede = 2 Then Call Form_KeyDown(39, 0)
End If
DoEvents
Sleep 350
Call Form_KeyDown(32, 0)
Else
DoEvents
Call solve(nn - 1, a, B, C)
DoEvents
Call solve(1, a, C, B)
DoEvents
Call solve(nn - 1, B, C, a)
DoEvents
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Not solut_b Then solut.Enabled = False
'F1 112
If KeyCode = 112 Then Call mnuInst_Click
'F2 113
If KeyCode = 113 Then Call mnuNew_Click
'F3 114
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -