A Klotski game with both computing and analysis.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
9.9 KiB

4 years ago
VERSION 5.00
Begin VB.Form Form_Classic_Cases
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "ѡ�����ݵ����䲼��"
ClientHeight = 5445
ClientLeft = 45
ClientTop = 390
ClientWidth = 6990
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5445
ScaleWidth = 6990
StartUpPosition = 2 '��Ļ����
Begin VB.CommandButton Command_Confirm
Caption = "ȷ��"
Height = 540
Left = 5480
TabIndex = 6
Top = 4780
Width = 1400
End
Begin VB.TextBox Text_Code
Alignment = 2 'Center
BeginProperty Font
Name = "΢���ź�"
4 years ago
Size = 18
4 years ago
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 570
Left = 3180
Locked = -1 'True
TabIndex = 5
Top = 4780
Width = 2175
End
Begin VB.CommandButton Command_Search
Caption = "����"
Height = 255
Left = 2280
4 years ago
TabIndex = 2
4 years ago
Top = 480
Width = 735
End
Begin VB.TextBox Text_Search
Height = 270
Left = 120
4 years ago
TabIndex = 1
4 years ago
Top = 480
Width = 2055
End
Begin VB.TextBox Text_Tip
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 615
Left = 120
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 4
Top = 4780
Width = 2895
End
Begin VB.ComboBox Combo_Cases
Height = 300
Left = 120
Style = 2 'Dropdown List
4 years ago
TabIndex = 0
4 years ago
Top = 120
Width = 2895
End
Begin VB.ListBox List_Cases
Height = 3840
4 years ago
ItemData = "Form_Classic_Cases.frx":0000
4 years ago
Left = 120
4 years ago
List = "Form_Classic_Cases.frx":0002
TabIndex = 3
4 years ago
Top = 840
Width = 2895
End
End
Attribute VB_Name = "Form_Classic_Cases"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim tip As String
4 years ago
Dim Block(0 To 9) As Block_struct
4 years ago
Dim start_x As Integer, start_y As Integer, square_width As Integer, gap As Integer
Private Sub Form_Load()
start_x = 3200
start_y = 135
square_width = 815
gap = 75
Call Get_Cases_title
Combo_Cases.ListIndex = 0
4 years ago
If on_top = True Then
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1 Or 2
Else
SetWindowPos Me.hwnd, -2, 0, 0, 0, 0, 1 Or 2
End If
4 years ago
End Sub
Private Sub Command_Confirm_Click()
change_case = True
change_case_title = Left(List_Cases.Text, Len(List_Cases.Text) - 9)
change_case_code = Text_Code
Unload Form_Classic_Cases
End Sub
Private Sub List_Cases_Click()
Text_Tip = "(" & List_Cases.ListIndex + 1 & "/" & List_Cases.ListCount & ")"
4 years ago
Text_Code = Mid(List_Cases.List(List_Cases.ListIndex), Len(List_Cases.List(List_Cases.ListIndex)) - 7, 7)
4 years ago
Call Analyse_Code(Text_Code)
Call Output_Graph
End Sub
Private Sub Command_Search_Click()
4 years ago
Dim i As Integer, j As Integer, last_select As Integer, searching As Boolean
4 years ago
Dim temp() As String
ReDim temp(0)
If Text_Search = "" Then Exit Sub
last_select = Combo_Cases.ListIndex
searching = False
If Combo_Cases.List(Combo_Cases.ListCount - 1) = "��������" Then
Combo_Cases.RemoveItem Combo_Cases.ListCount - 1
searching = True
End If
For j = 0 To Combo_Cases.ListCount - 1
Combo_Cases.ListIndex = j
If Combo_Cases.Text = "��������" Then Exit For
For i = 0 To List_Cases.ListCount - 1
If InStr(List_Cases.List(i), Text_Search) <> 0 Then
ReDim Preserve temp(UBound(temp) + 1)
temp(UBound(temp)) = List_Cases.List(i)
End If
Next i
Next j
4 years ago
If debug_mode = True Then MsgBox "last_select=" & last_select & vbCrLf & "searching=" & searching & vbCrLf & "temp->" & UBound(temp), , "Debug"
4 years ago
List_Cases.Clear
Combo_Cases.AddItem "��������"
Combo_Cases.ListIndex = Combo_Cases.ListCount - 1
Text_Tip = "���ҵ�" & UBound(temp) & "������"
Text_Code = "": Cls
If UBound(temp) = 0 Then
If searching = False Then
Combo_Cases.RemoveItem Combo_Cases.ListCount - 1
Combo_Cases.ListIndex = last_select
End If
4 years ago
MsgBox "�Ҳ�����", , "> _ <"
4 years ago
Exit Sub
End If
For i = 1 To UBound(temp)
List_Cases.AddItem temp(i)
Next i
List_Cases.ListIndex = 0
Text_Tip = "���ҵ�" & UBound(temp) & "������"
End Sub
Private Sub Combo_Cases_Click()
If Not Combo_Cases.Text = "��������" Then
If Combo_Cases.List(Combo_Cases.ListCount - 1) = "��������" Then
Combo_Cases.RemoveItem Combo_Cases.ListCount - 1
Text_Search = ""
End If
Call Get_Cases(Combo_Cases.ListIndex)
List_Cases.ListIndex = 0
Text_Tip = tip
End If
End Sub
Private Sub Text_Search_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call Command_Search_Click
End Sub
Private Sub Get_Cases(index As Integer)
Dim temp As String, name As String, num As Integer
num = 0
List_Cases.Clear
Open "Classic_Cases.txt" For Input As #1
Do Until EOF(1)
Line Input #1, temp
If temp = "[Cases]" Then
If num = index Then
4 years ago
Line Input #1, temp
Line Input #1, temp
tip = Right(temp, Len(temp) - 4)
Text_Tip = tip
4 years ago
reinput:
If EOF(1) = False Then
Line Input #1, temp
If temp <> "[Cases]" Then
List_Cases.AddItem Right(temp, Len(temp) - 8) & "(" & Left(temp, 7) & ")"
GoTo reinput
End If
End If
End If
num = num + 1
End If
Loop
Close #1
End Sub
Private Sub Get_Cases_title()
Dim temp As String
Open "Classic_Cases.txt" For Input As #1
Do Until EOF(1)
Line Input #1, temp
If temp = "[Cases]" Then
Line Input #1, temp
Combo_Cases.AddItem Right(temp, Len(temp) - 6)
End If
Loop
Close #1
End Sub
Private Sub Output_Graph()
4 years ago
Dim m, X, Y As Integer
4 years ago
Dim width As Integer, height As Integer
Print_Block start_x, start_y, square_width * 4 + gap * 5, square_width * 5 + gap * 6, case_line_width, case_color, case_line_color
For m = 0 To 9
If Block(m).address <> 25 Then
4 years ago
X = (Block(m).address Mod 4) * (square_width + gap) + gap + start_x
Y = Int(Block(m).address / 4) * (square_width + gap) + gap + start_y
4 years ago
If Block(m).style = 0 Or Block(m).style = 1 Then
width = square_width * 2 + gap
Else
width = square_width
End If
If Block(m).style = 0 Or Block(m).style = 2 Then
height = square_width * 2 + gap
Else
height = square_width
End If
4 years ago
Print_Block X, Y, width, height, block_line_width, block_color, block_line_color
4 years ago
End If
Next m
End Sub
Private Sub Print_Block(print_start_x, print_start_y, print_width, print_height, print_line_width, print_color, print_line_color)
If print_width < 0 Or print_height < 0 Then Exit Sub
FillStyle = 0
DrawWidth = print_line_width
FillColor = print_color
Line (print_start_x, print_start_y)-(print_start_x + print_width, print_start_y + print_height), print_color, B
Line (print_start_x, print_start_y)-(print_start_x + print_width, print_start_y + print_height), print_line_color, B
End Sub
4 years ago
Private Sub Analyse_Code(code As String)
4 years ago
On Error Resume Next
Dim temp(1 To 12) As Integer
Dim i, addr, style As Integer
Dim type_1, type_2, type_3 As Integer
Dim Table(0 To 19) As Integer
Dim num As Integer, b1 As Integer, b2 As Integer
Dim dat As String
For i = 1 To 6
4 years ago
dat = Mid(code, i + 1, 1)
4 years ago
If Asc(dat) >= 48 And Asc(dat) <= 57 Then num = Int(dat)
If Asc(dat) >= 65 And Asc(dat) <= 70 Then num = Asc(dat) - 55
b1 = num Mod 4
b2 = (num - b1) / 4 Mod 4
temp(i * 2 - 1) = b2
temp(i * 2) = b1
Next i
type_1 = 0: type_2 = 0: type_3 = 5
For i = 0 To 19
Table(i) = 69
Next i
For i = 0 To 9
Block(i).address = 69
Block(i).style = 69
Next i
4 years ago
dat = Left(code, 1)
4 years ago
If Asc(dat) >= 48 And Asc(dat) <= 57 Then num = Int(dat)
If Asc(dat) >= 65 And Asc(dat) <= 70 Then num = Asc(dat) - 55
Block(0).address = num
Block(0).style = 0
If Block(0).address > 14 Then GoTo err
Table(Block(0).address) = 0
Table(Block(0).address + 1) = 0
Table(Block(0).address + 4) = 0
Table(Block(0).address + 5) = 0
addr = 0
For i = 1 To 11
Do While Table(addr) <> 69
If addr < 19 Then
addr = addr + 1
Else
Exit Do
End If
Loop
style = temp(i)
If style = 0 Then
Table(addr) = 10
ElseIf style = 1 Then
If type_2 < 5 Then type_2 = type_2 + 1
If addr > 18 Then GoTo err
Block(type_2).style = 1
Block(type_2).address = addr
Table(addr) = type_2
Table(addr + 1) = type_2
ElseIf style = 2 Then
If type_2 < 5 Then type_2 = type_2 + 1
If addr > 15 Then GoTo err
Block(type_2).style = 2
Block(type_2).address = addr
Table(addr) = type_2
Table(addr + 4) = type_2
ElseIf style = 3 Then
If type_3 < 9 Then type_3 = type_3 + 1
Block(type_3).style = 3
Block(type_3).address = addr
Table(addr) = type_3
End If
Next i
err:
End Sub