I made a memory game! here is my code. it is a little n00bish but it was teh first second game i ever made >.>
Code:
-----------------------------------------------------------------------------------
Option Explicit
Const imgBoat As String = "/BOAT.GIF"
Const imgCar As String = "/CAR.JPG"
Const imgHawk As String = "/hawk.jpg"
Const imgZ As String = "/z.JPG"
Const imgDbz As String = "/DBZ.jpg"
Const imgPenny As String = "/PENNY.JPG"
Const imgTile As String = "/TILE.JPG"
Dim Face(12) As String
Dim IntrNd As Integer
Dim IntcoUnt As Integer
Dim strPick1
Dim strPick2
Dim varIndexpick1
Dim varindexpiCk2
Private Sub cmdend_Click()
End
End Sub
Private Sub cmdnewgame_Click()
Call Start_Game
Call Shuffle_Cards
End Sub
Private Sub Form_Load()
Call Start_Game
Call Shuffle_Cards
End Sub
Private Sub Swap_CaRds(Curcard As Integer, rNdCard As Integer)
Dim strtemp As String
strtemp = Face(Curcard)
Face(Curcard) = Face(rNdCard)
Face(rNdCard) = strtemp
End Sub
Private Sub Start_Game()
For IntcoUnt = 0 To 11
Image1(IntcoUnt).Visible = True
Image1(IntcoUnt).Picture = LoadPicture(App.Path & imgTile)
Next IntcoUnt
End Sub
Private Function Shuffle_Cards()
Face(0) = imgBoat
Face(1) = imgBoat
Face(2) = imgCar
Face(3) = imgCar
Face(4) = imgHawk
Face(5) = imgHawk
Face(6) = imgDbz
Face(7) = imgDbz
Face(8) = imgZ
Face(9) = imgZ
Face(10) = imgPenny
Face(11) = imgPenny
For IntcoUnt = 0 To 11
Randomize
IntrNd = Int(Rnd * 12)
Call Swap_CaRds(IntcoUnt, IntrNd)
Next
End Function
Private Sub check_enD_gaMe()
Dim X
Dim over As Boolean
over = True
For X = 0 To 11
If Image1(X).Visible = True Then
over = False
End If
Next
If over = True Then
MsgBox "gameover"
End If
End Sub
Private Sub delay_clIck()
Dim oOoOoOo
For oOoOoOo = 1 To 50000
DoEvents
Next
End Sub
Public Function RandColor(obj As Object)
Dim c(2) As Byte
Dim X As Integer
For X = 0 To 2
Randomize
c(X) = Int((255 - 0 + 1) * Rnd + 0)
Next X
obj.BackColor = RGB(c(0), c(1), c(2))
End Function
Private Sub Image1_Click(Index As Integer)
Call RandColor(frmMemory)
Image1(Index).Picture = LoadPicture(App.Path & Face(Index))
If strPick1 = "" Then
strPick1 = Face(Index)
varIndexpick1 = Index
Else
If Index <> varIndexpick1 Then
strPick2 = Face(Index)
varindexpiCk2 = Index
Else
Exit Sub
End If
End If
If strPick2 <> "" Then
If strPick1 = strPick2 Then
Call delay_clIck
Image1(varIndexpick1).Visible = False
Image1(varindexpiCk2).Visible = False
strPick1 = ""
strPick2 = ""
Call check_enD_gaMe
Else
Call delay_clIck
Image1(Index) = LoadPicture(App.Path & imgTile)
Image1(varIndexpick1) = LoadPicture(App.Path & imgTile)
varIndexpick1 = ""
strPick1 = ""
strPick2 = ""
End If
Else
Exit Sub
End If
End Sub
------------------------------------------------------------------------------------------
just follow that and you should find what ever you needed
if you paste it into vb it will be easlier to read