Post by ronie on Oct 6, 2010 21:51:25 GMT -5
ng gagawin kong ito ay tungkol sa game na mix number,
mostly sa mga laruan picture ung makikita nyo, pero hindi aq marunong mag lagay ng picture kaya number nlng, haha
una gumawa ng tatlong form
sa unang form ito ung code
ito n ung screen shot ng form 1
at ito ung property
at pra sa help ito ung code
at sa command button
at sa form 2 nmn ito un
ito ung code
at ito ung properties
at sa commandbutton
at finnaly sa form 3:
ito ung code:
at ung properties
at sa commandbutton
timer 1
timer 2
progressbar
at tapos ka na
kung nasunod mo ng mabuti ito ung kinalalabasan
click the enter tapos pwede ka ng mag laro
kung tapos ka na tingnan mo ung move mo kung naka ilaNG move ka paliitan tayo
ito n ung makikita mo
good luck
mostly sa mga laruan picture ung makikita nyo, pero hindi aq marunong mag lagay ng picture kaya number nlng, haha
una gumawa ng tatlong form
sa unang form ito ung code
Dim cont As Integer, higher As String, score As Integer
Dim stri As String
Dim cheat As Boolean
Dim fso As Object
Private Sub b_Click(Index As Integer)
Dim namee As String, score, id As Integer
For k = 0 To 15
If b(k).Caption = "" Then id = k
Next
If id = 4 Or id = 8 Or id = 12 Then
If (Index = id + 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
Exit Sub
End If
If id = 3 Or id = 7 Or id = 11 Then
If (Index = id - 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
Exit Sub
End If
If (Index = id + 1 Or Index = id - 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
For i = 0 To 14
If b(i).Caption = "" & i + 1 & "" Then flag = flag + 1
Next
If flag = 15 Then
MsgBox "You win this game", , "Puzzle"
score = reader()
If score > cont Then
namee = InputBox("Enter your name")
Call store(namee, cont)
End If
Call ng_Click
Else
flag = 0
End If
End Sub
Private Sub b_DragDrop(Index As Integer, Source As Control, x As Single, y As Single)
Dim namee As String
For k = 0 To 15
If b(k).Caption = "" Then id = k
Next
If Index = id Then
b(id).Caption = Source.Caption
Source.Caption = ""
b(Index).Drag 0
End If
For i = 0 To 14
If b(i).Caption = "" & i + 1 & "" Then flag = flag + 1
Next
If flag = 15 Then
MsgBox "You win this game", , "Puzzle"
score = reader()
If score > cont Then
namee = InputBox("Enter your name")
Call store(namee, cont)
End If
Call ng_Click
Else
flag = 0
End If
End Sub
Private Sub b_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim id As Integer
If cheat = True Then b(Index).Drag 1
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
stri = ""
Exit Sub
End If
stri = stri + Chr(KeyAscii)
If stri = "cheater" Then
cheat = Not cheat
End If
End Sub
Private Sub Form_Load()
Call init_num
Moves.SimpleText = "Moves : 0"
KeyPreview = True
cheat = False
End Sub
Public Sub counting()
cont = cont + 1
Moves.SimpleText = "Moves: " & cont
End Sub
Public Sub init_num()
b(0).Caption = 3
b(1).Caption = 10
b(2).Caption = 8
b(3).Caption = 5
b(4).Caption = 14
b(5).Caption = 7
b(6).Caption = 15
b(7).Caption = 1
b(8).Caption = 2
b(9).Caption = 4
b(10).Caption = 12
b(11).Caption = 9
b(12).Caption = 6
b(13).Caption = 11
b(14).Caption = 13
b(15).Caption = ""
End Sub
Private Sub h_Click()
Form2.Visible = True
Unload Me
End Sub
Private Sub ng_Click()
cont = 0
stri = ""
Call init_num
b(0).SetFocus
Moves.SimpleText = "Moves : 0"
cheat = False
End Sub
Public Sub store(strr As String, Moves As Integer)
Dim f As Integer
f = FreeFile
Open App.Path & "\highscore.dat" For Output As f
Write #f, Moves
Write #f, strr
Close #f
End Sub
Public Function reader() As Integer
Dim f As Integer, str As String, exist As Boolean
f = FreeFile
exist = fileexist(App.Path & "\highscore.dat")
If exist = True Then
Open App.Path & "\highscore.dat" For Input As f
Input #f, str
Close #f
reader = Int(str)
Else
reader = 9999
End If
End Function
Public Function fileexist(filename As String) As Boolean
Set fso = CreateObject("scripting.filesystemobject")
'Set f = fso.getfile(App.Path & "\highscore.dat")
If Not (fso.fileexists(filename)) Then
fileexist = False
Else
fileexist = True
End If
End Function
ito n ung screen shot ng form 1
at ito ung property
at pra sa help ito ung code
Dim cont As Integer, higher As String, score As Integer
Dim stri As String
Dim cheat As Boolean
Dim fso As Object
Private Sub b_Click(Index As Integer)
Dim namee As String, score, id As Integer
For k = 0 To 15
If b(k).Caption = "" Then id = k
Next
If id = 4 Or id = 8 Or id = 12 Then
If (Index = id + 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
Exit Sub
End If
If id = 3 Or id = 7 Or id = 11 Then
If (Index = id - 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
Exit Sub
End If
If (Index = id + 1 Or Index = id - 1) Or (Index = id + 4 Or Index = id - 4) Then
b(id).Caption = b(Index).Caption
b(Index).Caption = ""
Call counting
End If
For i = 0 To 14
If b(i).Caption = "" & i + 1 & "" Then flag = flag + 1
Next
If flag = 15 Then
MsgBox "You win this game", , "Puzzle"
score = reader()
If score > cont Then
namee = InputBox("Enter your name")
Call store(namee, cont)
End If
Call ng_Click
Else
flag = 0
End If
End Sub
Private Sub b_DragDrop(Index As Integer, Source As Control, x As Single, y As Single)
Dim namee As String
For k = 0 To 15
If b(k).Caption = "" Then id = k
Next
If Index = id Then
b(id).Caption = Source.Caption
Source.Caption = ""
b(Index).Drag 0
End If
For i = 0 To 14
If b(i).Caption = "" & i + 1 & "" Then flag = flag + 1
Next
If flag = 15 Then
MsgBox "You win this game", , "Puzzle"
score = reader()
If score > cont Then
namee = InputBox("Enter your name")
Call store(namee, cont)
End If
Call ng_Click
Else
flag = 0
End If
End Sub
Private Sub b_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Dim id As Integer
If cheat = True Then b(Index).Drag 1
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
stri = ""
Exit Sub
End If
stri = stri + Chr(KeyAscii)
If stri = "cheater" Then
cheat = Not cheat
End If
End Sub
Private Sub Form_Load()
Call init_num
Moves.SimpleText = "Moves : 0"
KeyPreview = True
cheat = False
End Sub
Public Sub counting()
cont = cont + 1
Moves.SimpleText = "Moves: " & cont
End Sub
Public Sub init_num()
b(0).Caption = 3
b(1).Caption = 10
b(2).Caption = 8
b(3).Caption = 5
b(4).Caption = 14
b(5).Caption = 7
b(6).Caption = 15
b(7).Caption = 1
b(8).Caption = 2
b(9).Caption = 4
b(10).Caption = 12
b(11).Caption = 9
b(12).Caption = 6
b(13).Caption = 11
b(14).Caption = 13
b(15).Caption = ""
End Sub
Private Sub h_Click()
Form2.Visible = True
Unload Me
End Sub
Private Sub ng_Click()
cont = 0
stri = ""
Call init_num
b(0).SetFocus
Moves.SimpleText = "Moves : 0"
cheat = False
End Sub
Public Sub store(strr As String, Moves As Integer)
Dim f As Integer
f = FreeFile
Open App.Path & "\highscore.dat" For Output As f
Write #f, Moves
Write #f, strr
Close #f
End Sub
Public Function reader() As Integer
Dim f As Integer, str As String, exist As Boolean
f = FreeFile
exist = fileexist(App.Path & "\highscore.dat")
If exist = True Then
Open App.Path & "\highscore.dat" For Input As f
Input #f, str
Close #f
reader = Int(str)
Else
reader = 9999
End If
End Function
Public Function fileexist(filename As String) As Boolean
Set fso = CreateObject("scripting.filesystemobject")
'Set f = fso.getfile(App.Path & "\highscore.dat")
If Not (fso.fileexists(filename)) Then
fileexist = False
Else
fileexist = True
End If
End Function
at sa command button
at sa form 2 nmn ito un
ito ung code
Private Sub Command1_Click()
Form1.Visible = True
Unload Me
End Sub
at ito ung properties
at sa commandbutton
at finnaly sa form 3:
ito ung code:
Private Sub Command1_Click()
Form1.Visible = True
Unload Me
End Sub
Private Sub Form_Load()
Image2.Visible = True
End Sub
Private Sub Timer1_Timer()
If Image1.Visible = True Then
Image1.Visible = False
Image2.Visible = True
ElseIf Image2.Visible = True Then
Image2.Visible = False
Image1.Visible = True
End If
End Sub
Private Sub Timer2_Timer()
If ProgressBar1.Value = 100 Then
Timer2.Enabled = False
Else
ProgressBar1.Value = Val(ProgressBar1.Value) + Val(1)
End If
End Sub
at ung properties
at sa commandbutton
timer 1
timer 2
progressbar
at tapos ka na
kung nasunod mo ng mabuti ito ung kinalalabasan
click the enter tapos pwede ka ng mag laro
kung tapos ka na tingnan mo ung move mo kung naka ilaNG move ka paliitan tayo
ito n ung makikita mo
good luck