Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-30-2004, 12:24 PM   #1 (permalink)
 
True Techie

Join Date: Mar 2004

Posts: 119

Legion2005

Send a message via AIM to Legion2005
Exclamation Memory Game... need help!

Ok, I also have a friend who needs help with a memory program (the flip two cards and match them memory card game)...

"I have the entire game nearly done except for one major problem. I have it so there are 16 cards... 8 matches total. At the form load the cards are randomly shuffled and placed... face down. Now I need to use the flag variable blnFirstTurn to determine when I click a card if it's my first card or second card turned over. At the beginning, the flag is true. After the first card is picked, it's changed to false. The cards are in a control array, and the variable intFirstPick is set equal to the Index of the control. At the end of the procedure blnFirstTurn is set to false. Then when it is clicked again, an If statement calls a sub procedure to test for a match. My problem is that when I click the first and second cards, it works. Then the second card I picked is being saved like it's the first card picked for the next turn. Can anyone help and maybe give me some helpful code?"
__________________
My PC Specs

Asus K8N
AMD64 2800+
1024 MB RAM PC-3200
GeForce FX 5700 128 MB
80 Gig 7200 RPM Hard Drive
DVD Burner
56k Modem (OH YEAH!!)
8 Channel Onboard Sound
5.1 Logitech Surround Sound
KDS Xtreme Flat Screen Monitor 17in.
Logitech Cordless Mouse
Running my long awated watercooling. Double radiator setup. 3 120mm fans right now. Finishing case.....
Legion2005 is offline  
Old 03-30-2004, 08:21 PM   #2 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

When you say first turn, you mean first turn in a pair, right? So you'd pick two cards, and then when you pick another card it's considered the "first turn"?

If so, why not just use:

If blnFirstTurn = True Then
blnFirstTurn = False
Else
blnFirstTurn = True
End If

(This would be in the procedure called when you click on a card) I'm not sure if this is even what you're talking about, but a look at the code that isn't working would help.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 04-10-2004, 11:57 PM   #3 (permalink)
 
Junior Techie

Join Date: Mar 2004

Posts: 56

raylu

Send a message via AIM to raylu
Default

Yeah, same here. Could you give a step by step example and the vlues of blnFirstTurn for each step?

I think what you want is
Code:
If blnFirstTurn=False Then
[2nd card code here]
blnFirstTurn=True ` <---Did you forget this line?
End If

__________________
\"Only when the last tree is dead, the last field paved, and the last river dammed, only then will we realize that we can\'t eat money.\"
http://raylu.uni.cc
raylu is offline  
Old 05-19-2004, 12:17 PM   #4 (permalink)
 
Newb Techie

Join Date: May 2004

Posts: 18

MiGiT128

Default

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
MiGiT128 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On