-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I did do a find for every evidence of the "cards" and I discovered in the LoadCards section, this:
Code:
Private Function DealBlueCard(Ctrl As Control, OldSlot As Integer) As Integer
Dim i As Integer, X As Integer
i = CurrentBlueSlot
Do While BlueCards(currentCard) > 51
currentCard = currentCard + 1
If currentCard > 53 Then ShuffleBlueCards
Loop
Ctrl.Picture = BlueCards(currentCard)
Picture1.AutoRedraw = True
Picture1.PaintPicture Ctrl.Picture, Ctrl.Left, Ctrl.Top
Picture1.AutoRedraw = False
Ctrl.Tag = cards(BlueCards(currentCard))
currentCard = currentCard + 1
If currentCard > 52 Then ShuffleBlueCards 'Note I changed this to 52 (that's correct right?)
Me.Refresh
DealBlueCard = Ctrl.Tag Mod 13
End Function
I have removed the word "cards" from that sub, as well as in the DealRedCard sub.
I also discovered in what used to be the LoadCards sub, the word "cards" appears again (twice over):
Code:
Private Sub LoadCards(sPath As String)
Dim i As Integer, lstr As String
For i = 0 To 51
lstr = App.Path & "\" & sPath & "\" & Choose(Int(i / 13) + 1, "s", "c", "h", "d") & _
Trim(Mid(" 2 3 4 5 6 7 8 910 j q k a", (i Mod 13) * 2 + 1, 2)) & ".bmp"
Set cards(i) = New StdPicture
Set cards(i) = LoadPicture(lstr)
Next
End Sub
I have created two separate subs and replaced the word "cards" with their corresponding colours:
Code:
Private Sub LoadBlueCards(sPath As String)
Dim i As Integer, lstr As String
For i = 0 To 51
lstr = App.Path & "\" & sPath & "\" & Choose(Int(i / 13) + 1, "s", "c", "h", "d") & _
Trim(Mid(" 2 3 4 5 6 7 8 910 j q k a", (i Mod 13) * 2 + 1, 2)) & ".bmp"
Set BlueCards(i) = New StdPicture
Set BlueCards(i) = LoadPicture(lstr)
Next
End Sub
Private Sub LoadRedCards(sPath As String)
Dim i As Integer, lstr As String
For i = 0 To 51
lstr = App.Path & "\" & sPath & "\" & Choose(Int(i / 13) + 1, "s", "c", "h", "d") & _
Trim(Mid(" 2 3 4 5 6 7 8 910 j q k a", (i Mod 13) * 2 + 1, 2)) & ".bmp"
Set RedCards(i) = New StdPicture
Set RedCards(i) = LoadPicture(lstr)
Next
End Sub
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I tried removing the "cards(0 To 51) As Integer", but when I tested the project, it didn't work. Removing the one from the GameEssentials was probably the only option at this time.
Also, I reinstated the code that I had from the previous code (the one I posted in the last post didn't work after all), and the form works perfectly.
Even better, I did a test last night before heading to bed, and I had the blue player answer the first question and then play the cards, then the red player won the second question, and then the blue player won the latter two questions of the round, and the cards work properly now.
I will be doing several tests over the next 2 days, and if successful, I will be ready to create the Round 2 form (which may be just some light editing and saving the form as a Round 2 form).
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
Thanks for the reminder, but I did do a control array count and it did come up 174 or around there. Just to be safe, I decided to do individual forms for each of the 3 rounds of game play. And besides, it's easier for me to maintain than having to go through all that consolidated code.
You don't have 174 controls. I just did a check and you have only 68 in the Round1f form.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I did so many test runs in the same project file (by using the run feature), and it worked for a while, but now it seems as if the code has gotten screwed.
What I wonder is, is it possible that by using the same project file to run the forms over and over again in such short time frame may cause the project to not work properly after a while? Is that one of the reasons why the wrong subs are set off even though the card is right (or wrong)?
If so, I can see another reason why it is important to compile to an EXE first.
And is it possible that having "dead" code is causing such problems in the forms?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
I did so many test runs in the same project file (by using the run feature), and it worked for a while, but now it seems as if the code has gotten screwed.
What I wonder is, is it possible that by using the same project file to run the forms over and over again in such short time frame may cause the project to not work properly after a while? Is that one of the reasons why the wrong subs are set off even though the card is right (or wrong)?
If so, I can see another reason why it is important to compile to an EXE first.
And is it possible that having "dead" code is causing such problems in the forms?
Unfortunately the answer to all those questions is no.
Here is the best thing I can suggest you do.
When the wrong subs are set off, immediately put the program in break mode and copy or otherwise make note of all the cards in each deck that have been played. You can do that by examining BlueCards() and RedCards()
and making note of the first 10 or 20 or however many were played until the current cards that caused the problem are encountered. Now add code like
BlueCards(0) = 13
BlueCards(1) = 21
BlueCards(2) = 14
BlueCards(3) = 48
to each of the shuffle routines like I illustrated in a previous post, replacing the 13, 21, etc with the 10 or 20 values that you noted from the run that had the problem. Now when you run again you should begin to get the same cards and hence the same results as the last time. In this run when you get close to the point of the problem put the program in break mode and then continue the execution stepping through it line by line using the F8 key and the Quick Watch key to examine variable values at important decision points. Doing this you hopefully will find a variable that has an unexpected, wrong, value. When you get to that point let me know and we can discuss how to track down why it is getting the wrong value.
BTW if you haven't already read my VB6 Debug Tutorial you should because many of theses techniques are discussed there in some detail.
-
1 Attachment(s)
Re: Flickering Buttons: How Do I Get Rid Of Them?
I should have added that if you have any questions about what I suggested above, please ask.
OK here is something else. Ever since I started working with your program it bothered me that if I tried to close Round1f before it was finished displaying the cards it would just start over again. The main reason for that was that the StartQuestion sub was the sub that was in the process of being executed when I would try to close the form, but since that sub contains references to controls on the form, the very next line would reload the form. That happens because as I may have mentioned before, if you refer to a control on a form that will cause it to be loaded. Here are the changes necessary to stop that behavior.
1) Replace the StartPlaying sub with the text that's in the attachment.
2)
Code:
Private Sub Game1_Click()
Debug.Print "CSInfo.Game1_Click" 'WARNING. DO NOT REMOVE OR MODIFY THIS COMMENT.CSInfo.Game1_Click
'new
On Error Resume Next
Round1f.Show
'new
'CSInfo.Hide
End Sub
3) Remove Dim playing As Boolean from Round1f. You may have done this already.
4)
Code:
Private Sub Form_Unload(Cancel As Integer)
Debug.Print "Round1f.Form_Unload" 'WARNING. DO NOT REMOVE OR MODIFY THIS COMMENT.Round1f.Form_Unload
playing = False
'new
CSInfo.Show
End Sub
5)
Code:
Private Sub Form_Load()
Debug.Print "Round1f.Form_Load" 'WARNING. DO NOT REMOVE OR MODIFY THIS COMMENT.Round1f.Form_Load
Dim i As Integer, lstr As String, hdc As Long
'Me.WindowState = 1
Me.Show
'new
CSInfo.Hide
'the rest of your code
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I do have some bad news...
The error with the card playing doesn't seem to want to escape. Also, I really find it hard to understand how to debug properly when all those words are surrounded by other words, and many of them being words that I am not familiar with. I have a hard time comprehending to certain information if it's surrounded by other words that are close together (above, next to each other, or below). If only the information could be made more concise, that would be great.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
BTW, just to clarify, the problem only exists when the following occurs:- The blue (or red) player answers three non-consecutive questions and wins control of the cards.
- The problem exists after the fourth question (the sudden death question) when the blue (or red) player wins that third non-consecutive question and chooses to play the cards instead of passing to the opponent.
The problem doesn't exist (at least, as far as I know) when:- The same player answers four questions in a row and wins control of the cards all the way.
- The same contestant wins the first three questions and makes a mistake the first two times, and then successfully gets it right the third time.
To sum it up, there would be skipping involved among the four questions for the blue (or red) player in order for there to be a mistake.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
I do have some bad news...
The error with the card playing doesn't seem to want to escape. Also, I really find it hard to understand how to debug properly when all those words are surrounded by other words, and many of them being words that I am not familiar with. I have a hard time comprehending to certain information if it's surrounded by other words that are close together (above, next to each other, or below). If only the information could be made more concise, that would be great.
Please copy/paste to here the sections that you have a problem with and I'll try to reword them. If you underline the words you don't understand I'll change or explain them. We could also do this via PM's if you would prefer.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I might have stated that the problem with the wrong sub being set off exists after the fourth question (Sudden Death) and the contestant wins the question and has the option to pass or play. When that player chooses to play, he calls a card higher (or vice versa), and while it is higher, the opposite sub is set off instead.
I wonder if, by chance, it has to do with the intTurn variable where some line that says "intTurn = intTurn + 1" exists in the red area, but not in the blue area, and the "intTurn = intTurn + 1" line is not necessary in the Sudden Death question (or is it really necessary?), seeing there is only one player playing the cards to determine the winner of that round?
Or is it possible that it may have to do with the BluePlayCount integer? Either way, I will see if I can work on it in the coming days. I can see why the code seemed to work fine a week or two ago, but now it seems to be still flawed in some way.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Did you ever try what I suggested in post #246? And I think it would be to your benefit if you told me what it is that you don't understand (post #250), because there is a LOT you can do with Debug and I'm sure YOU COULD FIND THE PROBLEM FAIRLY QUICKLY. For example given the situation you just described, if you knew ahead of time what the next card(s) was going to be you could reproduce the same situation over and over, trying different things to see if they help. For example did you know that if the program is in Break mode that you can type
?intTurn
and then press return to see what the current value is, and if you want, CHANGE it by doing either of the following and then pressing Return.
intTurn = 2
intTurn = intTurn + 1
I ask these questions because you often don't say one way or the other if you've tried what I suggested. Is it because you don't understand? If that's the case please tell me what part you don't understand and I'll try again.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
MartinLiss
Did you ever try what I suggested in post #246? And I think it would be to your benefit if you told me what it is that you don't understand (post #250), because there is a LOT you can do with Debug and I'm sure YOU COULD FIND THE PROBLEM FAIRLY QUICKLY. For example given the situation you just described, if you knew ahead of time what the next card(s) was going to be you could reproduce the same situation over and over, trying different things to see if they help. For example did you know that if the program is in Break mode that you can type
?intTurn
and then press return to see what the current value is, and if you want, CHANGE it by doing either of the following and then pressing Return.
intTurn = 2
intTurn = intTurn + 1
I ask these questions because you often don't say one way or the other if you've tried what I suggested. Is it because you don't understand? If that's the case please tell me what part you don't understand and I'll try again.
I apologize, but I have a hard time comprehending to longer paragraphs. But I will try and read the Debug manual thread even if I have to print it off on paper.
And besides, in case you didn't know, I have rules that only allow me one hour maximum of computer time at a time, five times daily. This is due to the fact that my caregiver in my apartment strongly encourages me to do other things other than the computer. I actually had a massive jolt of back pain around this time last year, in fact. This may have been partly because of me sitting in front of my computer for hours on end whenever I was not at work. My caregiver wants me to do other things and not just take advantage of my free time. But I still do use the computer - but only in limited intervals five times daily.
That said, I will see if I can print off the entire contents of the tutorial you supplied and take a stab at reading through it in my free time. Then I will see what I can do to try to fix the problem.
And thanks for providing the useful tip on the debugging of the intTurn.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
I apologize, but I have a hard time comprehending to longer paragraphs. But I will try and read the Debug manual thread even if I have to print it off on paper.
And besides, in case you didn't know, I have rules that only allow me one hour maximum of computer time at a time, five times daily. This is due to the fact that my caregiver in my apartment strongly encourages me to do other things other than the computer. I actually had a massive jolt of back pain around this time last year, in fact. This may have been partly because of me sitting in front of my computer for hours on end whenever I was not at work. My caregiver wants me to do other things and not just take advantage of my free time. But I still do use the computer - but only in limited intervals five times daily.
That said, I will see if I can print off the entire contents of the tutorial you supplied and take a stab at reading through it in my free time. Then I will see what I can do to try to fix the problem.
And thanks for providing the useful tip on the debugging of the intTurn.
No need to apologize and thanks for giving me a better understanding of your problems.
If your caregiver ever wants to talk with me please feel free to give him/her my email address.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I am just wondering another thing...
I remember somebody (smUX, if I recall) helping me code Super Password (another game show that aired in the 1980s), and he seemed to code most of the elements in one consolidated sub.
I am also wondering if consolidation of all the separate subs for the Higher/Lower Right/Wrong may be a good idea that will allow for the calling of the cards to run smoothly with no problems?
I can send you a sample of the Super Password forms and you can see how condensed the code is and that may give you a rough idea on how to condense the card playing instead of having to go from sub to sub. Maybe the code I have for Card Sharks may be a bit complex and may have led to errors all along.
Would it be alright for me to send you the Super Password project file (as a sample) so that you can see how it's more condensed?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I know how to consolidate code so there's no need to send me the Super Password project file unless you want to talk about specific things in that file.
I've sugggested all along that you consolidate things as much as possible because it makes a program easier to maintain and with less code there is less chance for errors.
Give me a while and I'll be back with an example from your code.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
An example from the Super Password code:
Code:
Private Sub cmdStart_Click()
Dim mainans() As String
cmdStart.Enabled = False
Do
lblRound.Caption = Val(lblRound.Caption) + 1
getclue
currcluestep = 0 'Sets the system to clue 0...it'll be clue 1 when it's time to show the clue
Do: DoEvents
currcluestep = currcluestep + 1
dosubclue (currcluestep) 'sub-clue is the word used to guess the main password
gue = InputBox("Now try to guess the Super Password...", "Have a guess!")
maincorr = 0
mainans = Split(mainpass, ",")
If InStr(mainpass, "," & LCase(gue) & ",") <> 0 Then 'There is more than one possible answer to the password, and this checks them all
MsgBox "CORRECT!": maincorr = 1: lblAnswerRight.Caption = mainans(1): lblMainAnswer.Visible = False
winnings = Val(lblRound.Caption) * 100: If winnings > 400 Then winnings = 400 'Works out the winnings based on the round number
lblMoney.Caption = Val(lblMoney.Caption) + winnings 'adds winnings to total money
Else
MsgBox "Incorrect"
End If
Loop While currcluestep < 5 And maincorr = 0 'Allows for a max of 4 clues
Loop While lblMainAnswer.Visible = False And Val(lblRound.Caption) < 5 'Allows for a max of 4 rounds, but you can change the 5 to any number (add 1 to however many you want)
End Sub
Private Sub Form_Load()
maxclue = 2 'the amount of clues to work with...I've only modified a few clues so I
'have only set this to 2
Randomize
'Some people say that randomize only needs to be used once in a program, and in a way they
'are right...it won't be more random if used again, but it also won't be less random so
'the location of randomize doesn't matter really as long as it's used at least once
End Sub
Public Function dosubclue(X As Single)
Dim dt() As String, passes() As String
passes = Split(pass(X), ",")
guesses = 0
Do
txtGuess.Text = ""
guesses = guesses + 1
sclue = Int(Rnd(1) * Val(maxclues)) + 1 'chooses a random clue line for the sub-word
dt = Split(clue(X, sclue), ",")
lblClue.Caption = dt(0) 'Gets the first word in the line for that clue line
Do: DoEvents: Loop While lblClue.Tag = ""
lblClue.Tag = "": corr = 0
If InStr(LCase(pass(X)), "," & LCase(txtGuess.Text) & ",") <> 0 Then
'Add to score
MsgBox "Correct!": corr = 1
Else
'This next line (if the answer is incorrect) sets the results boxes (below the answer box)
'to red and puts the clue into them to help the player with guessing.
MsgBox "Incorrect!": cmdGuess(guesses).Caption = lblClue.Caption: cmdGuess(guesses).BackColor = &HFF&
End If
Loop While corr = 0 And guesses < 4
'Add clue to main clue
MsgBox passes(1) & " is added to the list of clues"
lblMainClue(X).Caption = passes(1)
'This bit of code returns the clue boxes for the sub clue to normal
For b = 1 To 4: cmdGuess(b).Caption = "-= " & Trim(Str(b)) & " =-": cmdGuess(b).BackColor = &H80FF80: Next b
End Function
Public Function getclue()
clu = Int(Rnd(1) * maxclue) + 1 'chooses a clue at random. Maxclue is the number of clues available
fre = FreeFile 'chooses the next available free file number
Open App.Path & "/puzzles/" & Trim(Str(clu)) & ".txt" For Input As #fre
Line Input #fre, mainpass 'loads the main password into the variable 'mainpass'
For b = 1 To 5
Line Input #fre, pass(b) 'loads the password clue for the main password
pass(b) = "," & pass(b) & "," 'this saves about 8 bytes per clue file by doing this here
Line Input #fre, frms(b) 'loads the forms for the clue (which I still don't understand)
Line Input #fre, numclues
For c = 1 To Val(numclues)
Line Input #fre, clue(b, c) 'loads the clue for pass()
Next c
Next b
Close #fre
End Function
You'll notice that there are comments included.
If code like this could be used to play the cards more smoothly in Card Sharks, that would be a great help. :)
-
1 Attachment(s)
Re: Flickering Buttons: How Do I Get Rid Of Them?
Rather than giving you an example, let's talk about why you have four separate subs in a lot of cases when just one would do. If I'm wrong about any of this please let me know.
In one case cmdLowerCds_Click calls AnswerLowerCards or AnswerLowerCardsTwo, or AnswerLowerCardsThree, or AnswerLowerCardsFour depending on the question number.
Those four subs seem to be identical except that they call LowerRightCards or LowerRightCardsTwo, etc.
Those four subs seem to be identical except that they ALL call AskHigherLowerCards so it seems to me that six of these subs are unnecessary.
I've attached a two-page document that shows what you have now, followed by what I think you need.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I viewed the flowchart, but beforehand I was thinking...
If I eliminated the HigherRightCards and HigherWrongCards subs and consolidated the contents of both those subs into the AnswerHigherCards sub, that may make the game run more smoothly. Here is a snippet of the newly revamped code (I did a backup, btw):
Code:
Private Sub AnswerHigherCards()
Dim i As Integer
If WhosTurn = RedPlayer Then
PlaySound App.Path & "\sounds\isHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
SetDialog "Is it higher?"
i = CurrentRedSlot
CurrentRedSlot = CurrentRedSlot + 1
If CurrentRedSlot = 4 Then
Sleep 250
PlaySound App.Path & "\sounds\ifHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
End If
i = DealRedCard(CurImage, 0)
SetDialog "It's the " & NameCard(CurImage.Tag) & "!"
If oldRedCardValue < i Then
oldRedCardValue = i
If CurrentRedSlot = 1 Or FreezeCard(WhosTurn) = 1 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! It is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
AskHigherLowerCards
ElseIf CurrentRedSlot = 2 Or FreezeCard(WhosTurn) = 2 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! It is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
AskHigherLowerCards
ElseIf CurrentRedSlot = 3 Or FreezeCard(WhosTurn) = 3 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! It is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
AskHigherLowerCards
ElseIf CurrentRedSlot = 4 Then
RedGameWin
End If
ElseIf oldRedCardValue > i Then
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = BluePlayer
Wait 100
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
ElseIf oldRedCardValue = i Then
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = BluePlayer
Wait 100
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
End If
Else
PlaySound App.Path & "\sounds\isHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
SetDialog "Is it higher?"
i = CurrentBlueSlot
CurrentBlueSlot = CurrentBlueSlot + 1
If CurrentBlueSlot = 4 Then
Sleep 250
PlaySound App.Path & "\sounds\ifHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
End If
i = DealBlueCard(CurImage, 0)
SetDialog "It's the " & NameCard(CurImage.Tag) & "!"
If oldBlueCardValue < i Then
oldBlueCardValue = i
If CurrentBlueSlot = 1 Or FreezeCard(WhosTurn) = 1 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! it is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
ElseIf CurrentBlueSlot = 2 Or FreezeCard(WhosTurn) = 2 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! it is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
ElseIf CurrentBlueSlot = 3 Or FreezeCard(WhosTurn) = 3 Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! it is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
ElseIf CurrentBlueSlot = 4 Then
BlueGameWin
End If
ElseIf oldBlueCardValue > i Then
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = RedPlayer
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
ElseIf oldBlueCardValue = i Then
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = RedPlayer
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
End If
End If
End Sub
What do you think of this idea of consolidating?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Consolidating is a good idea but please also consider getting rid of those 6 unnecessary subs I pointed out (and probably others that are unnecessarily duplicated).
Compare this CAREFULLY with what you posted. I think I got rid of unnecessary duplicated code but I haven't tested it.
Code:
Private Sub AnswerHigherCards()
Dim i As Integer
PlaySound App.Path & "\sounds\isHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
SetDialog "Is it higher?"
If WhosTurn = RedPlayer Then
i = CurrentRedSlot
CurrentRedSlot = CurrentRedSlot + 1
If CurrentRedSlot = 4 Then
Sleep 250
PlaySound App.Path & "\sounds\ifHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
End If
i = DealRedCard(CurImage, 0)
SetDialog "It's the " & NameCard(CurImage.Tag) & "!"
If oldRedCardValue < i Then
oldRedCardValue = i
If (CurrentRedSlot = 1 Or FreezeCard(WhosTurn) = 1) Or _
(CurrentRedSlot = 2 Or FreezeCard(WhosTurn) = 2) Or _
(CurrentRedSlot = 3 Or FreezeCard(WhosTurn) = 3) Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! It is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
AskHigherLowerCards
Else
RedGameWin
End If
Else
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = BluePlayer
Wait 100
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
End If
Else
i = CurrentBlueSlot
CurrentBlueSlot = CurrentBlueSlot + 1
If CurrentBlueSlot = 4 Then
Sleep 250
PlaySound App.Path & "\sounds\ifHigher.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
End If
i = DealBlueCard(CurImage, 0)
SetDialog "It's the " & NameCard(CurImage.Tag) & "!"
If oldBlueCardValue < i Then
oldBlueCardValue = i
If (CurrentBlueSlot = 1 Or FreezeCard(WhosTurn) = 1) Or _
(CurrentBlueSlot = 2 Or FreezeCard(WhosTurn) = 2) Or _
(CurrentBlueSlot = 3 Or FreezeCard(WhosTurn) = 3) Then
SetDialog lblDialog(1).Caption & vbCrLf & "Yes! it is higher!"
Me.Refresh
PlaySound App.Path & "\sounds\ding.wav", ByVal 0&, SND_SYNC Or SND_FILENAME
cmdFreezeCd.Visible = True
cmdFreezeCd.Enabled = True
Else
BlueGameWin
End If
Else
SetDialog lblDialog(1).Caption & vbCrLf & "No, it is not higher."
GetBuzzSnd2
cmdHigherCds.Visible = False
cmdLowerCds.Visible = False
cmdFreezeCd.Visible = False
Wait 2000
RemoveCards
Me.Refresh
Wait 2000
WhosTurn = RedPlayer
If intTurn = 1 Then
If FreezeCard(WhosTurn) = 0 Then
RevealFreeShot
End If
ElseIf intTurn = 2 Then
CurrentQues = CurrentQues + 1
WhosTurn = BluePlayer
StartQuestionTwo
End If
End If
End If
End Sub
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I don't want to overload you with changes, but since you have some "twin" variables like CurrentRedSlot and CurrentBlueSlot I'd like to show you a technique you could use to cut down on your code.
Instead of
Code:
Dim CurrentRedSlot As Integer, CurrentBlueSlot As Integer...
you could do
Code:
Private CurrentSlot(1) As Integer
Private Enum PlayerColor
Red = 0
Blue = 1
End Enum
which you would use like this:
Code:
CurrentSlot(Red) = 0
'instead of CurrentRedSlot = 0
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Also, would this be a good idea with the oldRedCardValue and the oldBlueCardValue variables also?
And shouldn't the CurrentSlot code go like this:
Code:
Private Sub CurrentSlot(PlayerColor As Integer)
Private Enum PlayerColor
Red = 0
Blue = 1
End Enum
End Sub
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
Also, would this be a good idea with the oldRedCardValue and the oldBlueCardValue variables also?
And shouldn't the CurrentSlot code go like this:
Code:
Private Sub CurrentSlot(PlayerColor As Integer)
Private Enum PlayerColor
Red = 0
Blue = 1
End Enum
End Sub
No, and I'm sorry if I confused things. I'm proposing a variable named CurrentSlot to replace your current CurrentRedSlot and CurrentBlueSlot variables.
BTW I used Private CurrentSlot rather than Dim CurrentRedSlot As Integer, CurrentBlueSlot As Integer because while it works the same way, Private is the more modern way of defining form-level variables.
One more thing. I just noticed that in several subs you already have local variables called CurrentSlot. So to avoid confusion if you do want to replace oldRedCardValue and oldBlueCardValue choose a different name than CurrentSlot.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
MartinLiss
I'm proposing a variable named CurrentSlot to replace your current CurrentRedSlot and CurrentBlueSlot variables.
So where would I place the CurrentSlot variable? In the declarations, or as another sub?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Subs and variables are two completely different things so the correct place is in the Declarations section where you currently have CurrentRedSlot and CurrentBlueSlot.
If you aren't completely sure how to define or use my new variable then you shouldn't make the change.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I have consolidated the subs and placed them all in their cmd_Click() subs. I realized there is no real need to have all those subs involved when I can do everything within button commands.
However, after doing the first test run, I discovered that, after the first card on the row is revealed, when I call a card higher or lower, and if the result is correct, the Freeze button shows for only a split second, then disappears.
I will be sending the updated files soon, but I will point out that I did provide commentary where the error exists. The commentary reads:
Code:
' This is where the freeze button stays only briefly after the second card on the row is revealed. The Freeze button stays fixed when or after the third card on the row is revealed.
If you do a find for these words:
' This is where the freeze button
by going to Edit and Find, you will see where the line is and it will tell you where the problem exists. But be sure to run the form to see if the problem exists on your side.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I did discover today that when I started the first round, and the blue player won the first question, the blue player started with an Ace of Spades. Called it lower (needless to say), and while the card was lower (it was a 9), the wrong sound effect and corresponding stuff played.
I am wondering if this has to do with the NameCard sub (originally created by technorobbo) in the GameEssentials8 module? It may be possible that the deck of 52 cards (for the red or blue player) are just consolidated in one sub, and not grouped properly (by suit).
I wonder if placing the card images in a resource file and grouping them by suit so that the order of the cards in each suit starts with the 2 and goes all the way up to the Ace, yet the cards in the 52-deck are still labelled 0 to 51?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
JonSea31
I did discover today that when I started the first round, and the blue player won the first question, the blue player started with an Ace of Spades. Called it lower (needless to say), and while the card was lower (it was a 9), the wrong sound effect and corresponding stuff played.
I am wondering if this has to do with the NameCard sub (originally created by technorobbo) in the GameEssentials8 module? It may be possible that the deck of 52 cards (for the red or blue player) are just consolidated in one sub, and not grouped properly (by suit).
I wonder if placing the card images in a resource file and grouping them by suit so that the order of the cards in each suit starts with the 2 and goes all the way up to the Ace, yet the cards in the 52-deck are still labelled 0 to 51?
I can't do anything more right now except to point out that 0 to 51 is room for 52 cards. I'm working on a problem in one of my own apps!
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
MartinLiss
I can't do anything more right now except to point out that 0 to 51 is room for 52 cards. I'm working on a problem in one of my own apps!
Okay, I understand.
However, I think I may have successfully figured out the problem just now. When you have free time available, I'll come back to the thread to explain my problem.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
If you want to, please send me your current files and the details of a problem you'd like me to help with.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
I will give you a heads up on what may have been to blame for the problem. I discovered this when I had an Ace of Spades on the first card reveal after the first question, and I called the next card lower. While the next card result was a 9 of Diamonds, and the right card on top of that, the LowerWrongCards sub was set off for some weird reason.
Here's what I discovered:
The cards in the deck are designated numbers 0 to 51. The Ace of Spades is designated as Card #12, whereas the 9 of Diamonds was designated #40-something. Since I called the card lower than the Ace of Spades, it did not register as lower since a number in the 40s is not lower than 12.
The oldBlueCardValue (or oldRedCardValue) is supposed to record the card value (2 to Ace), not card value as in the sequence in the deck.
This problem could be resolved if I placed all the cards in the deck and corresponding information in a separate text file. The text file would go like this:
Code:
1, s2, 2, a Two
2, s3, 3, a Three
3, s4, 4, a Four
4, s5, 5, a Five
5, s6, 6, a Six
6, s7, 7, a Seven
7, s8, 8, an Eight
8, s9, 9, a Nine
9, s10, 10, a Ten
10, sj, 11, a Jack
11, sq, 12, a Queen
12, sk, 13, a King
13, sa, 14, an Ace
14, c2, 2, a Two
15, c3, 3, a Three
16, c4, 4, a Four
17, c5, 5, a Five
18, c6, 6, a Six
19, c7, 7, a Seven
20, c8, 8, an Eight
21, c9, 9, a Nine
22, c10, 10, a Ten
23, cj, 11, a Jack
24, cq, 12, a Queen
25, ck, 13, a King
26, ca, 14, an Ace
27, h2, 2, a Two
28, h3, 3, a Three
29, h4, 4, a Four
30, h5, 5, a Five
31, h6, 6, a Six
32, h7, 7, a Seven
33, h8, 8, an Eight
34, h9, 9, a Nine
35, h10, 10, a Ten
36, hj, 11, a Jack
37, hq, 12, a Queen
38, hk, 13, a King
39, ha, 14, an Ace
40, d2, 2, a Two
41, d3, 3, a Three
42, d4, 4, a Four
43, d5, 5, a Five
44, d6, 6, a Six
45, d7, 7, a Seven
46, d8, 8, an Eight
47, d9, 9, a Nine
48, d10, 10, a Ten
49, dj, 11, a Jack
50, dq, 12, a Queen
51, dk, 13, a King
52, da, 14, an Ace
The contents of the text file appear in four columns:
Col. 1: The card number in the deck (1 to 52)
Col. 2: The card image filename (assuming it is a .bmp file)
Col. 3: The numeric card value for the corresponding card (2 for deuce, 3 for three ... 13 for King, 14 for Ace)
Col. 4: The remainder of the caption that should display when the card is revealed and the caption should read "It's (content in the fourth column when the card is drawn)!"- The line number (as displayed in column 1) should be drawn at random.
- The card image (as displayed in column 2) should be displayed on the corresponding line chosen at random.
- The oldBlueCardValue (and the oldRedCardValue) should record the card value by what is drawn on that same line (2 to 14).
- The remainder of the caption should fill in what comes after (using pseudocode) "It's " & (insert caption from column 4) & "!"
Files will be delivered shortly.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Forgot to mention that the content of the text file I supplied in the last post is found in the data.txt file, which is located in the "cards" folder.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
You shouldn't have to depend on a text file. Give me a few hours to look into it.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Here's somthing that you can use if you want to.
Code:
Option Explicit
Private CardRank As New Collection
Public Sub FillCardRank()
CardRank.Add "52", "Ace of spades"
CardRank.Add "51", "King of spades"
CardRank.Add "50", "Queen of spades"
CardRank.Add "49", "Jack of spades"
CardRank.Add "48", "10 of spades"
CardRank.Add "47", "9 of spades"
CardRank.Add "46", "8 of spades"
CardRank.Add "45", "7 of spades"
CardRank.Add "44", "6 of spades"
CardRank.Add "43", "5 of spades"
CardRank.Add "42", "4 of spades"
CardRank.Add "41", "3 of spades"
CardRank.Add "40", "2 of spades"
CardRank.Add "39", "Ace of hearts"
CardRank.Add "38", "King of hearts"
CardRank.Add "37", "Queen of hearts"
CardRank.Add "36", "Jack of hearts"
CardRank.Add "35", "10 of hearts"
CardRank.Add "34", "9 of hearts"
CardRank.Add "33", "8 of hearts"
CardRank.Add "32", "7 of hearts"
CardRank.Add "31", "6 of hearts"
CardRank.Add "30", "5 of hearts"
CardRank.Add "29", "4 of hearts"
CardRank.Add "28", "3 of hearts"
CardRank.Add "27", "2 of hearts"
CardRank.Add "26", "Ace of diamonds"
CardRank.Add "25", "King of diamonds"
CardRank.Add "24", "Queen of diamonds"
CardRank.Add "23", "Jack of diamonds"
CardRank.Add "22", "10 of diamonds"
CardRank.Add "21", "9 of diamonds"
CardRank.Add "20", "8 of diamonds"
CardRank.Add "19", "7 of diamonds"
CardRank.Add "18", "6 of diamonds"
CardRank.Add "17", "5 of diamonds"
CardRank.Add "16", "4 of diamonds"
CardRank.Add "15", "3 of diamonds"
CardRank.Add "14", "2 of diamonds"
CardRank.Add "13", "Ace of clubs"
CardRank.Add "12", "King of clubs"
CardRank.Add "11", "Queen of clubs"
CardRank.Add "10", "Jack of clubs"
CardRank.Add "9", "10 of clubs"
CardRank.Add "8", "9 of clubs"
CardRank.Add "7", "8 of clubs"
CardRank.Add "6", "7 of clubs"
CardRank.Add "5", "6 of clubs"
CardRank.Add "4", "5 of clubs"
CardRank.Add "3", "4 of clubs"
CardRank.Add "2", "3 of clubs"
CardRank.Add "1", "2 of clubs"
End Sub
Private Sub Form_Load()
FillCardRank
' Looking your AnswerHigherCards sub I think this line uses the proper variables
' What it does is use the NAMES of the two cards and then compare their
' numeric values in the CardRank collection. In other words "Ace of spades" would
' give as value of 52 which is of course the highest possible value
If CardRank(NameCard(CurImage.Tag)) > CardRank(oldBlueCardValue) Then
' Do greater code here
Else
' Do less than code here
End If
End Sub
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Would this (the text in bold) be right?
Code:
Private Sub Form_Load()
FillCardRank
' Looking your AnswerHigherCards sub I think this line uses the proper variables
' What it does is use the NAMES of the two cards and then compare their
' numeric values in the CardRank collection. In other words "Ace of spades" would
' give as value of 52 which is of course the highest possible value
If CardRank(NameCard(CurImage.Tag)) > CardRank(oldBlueCardValue) Then
HigherRightCards
Else
HigherWrongCards
End If
End Sub
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Nope. The code you provided doesn't seem to work. There has to be a corresponding card value (not as in the deck, but to differentiate between a deuce, and three, all the way up to an Ace.
I tested the code just now, and I started with an 8. I changed it to a 3 of Diamonds, and called the next card higher. While the card was indeed higher (a 6 of Spades), it still went by the numbers ranging from 1 to 52. This problem would be prevented if there was a corresponding numeric value for each of the following:
2 of (suit) = 2
3 of (suit) = 3
4 of (suit) = 4
5 of (suit) = 5
6 of (suit) = 6
7 of (suit) = 7
8 of (suit) = 8
9 of (suit) = 9
10 of (suit) = 10
Jack of (suit) = 11
Queen of (suit) = 12
King of (suit) = 13
Ace of (suit) = 14
This designation of numeric values should be the key element and not the numbers from 1 to 52. These numeric values (2 to 14) can be repeated in each suit. If not for that, I would get the wrong sub set off even when getting the rightful card.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Okay I think I see what is wrong.
At the end of DealBlueCard make this change
Code:
'new
' DealBlueCard = Ctrl.Tag Mod 13
DealBlueCard = Ctrl.Tag
And change the "If" in AnswerHigerCards to
Code:
If CardRank(NameCard(oldBlueCardValue)) < CardRank(NameCard(CurImage.Tag)) Then
You should also change the start of FillCardRank as follows
Code:
Public Sub FillCardRank()
'new
Set CardRank = New Collection
Try that out by always guessing higher on the blue turn and let me know if it works.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
BTW the difference between DealBlueCard = Ctrl.Tag and DealBlueCard = Ctrl.Tag Mod 13 is this.
If the card dealt for example is the King of clubs then NameCard(Ctrl.Tag) correctly gives "King of clubs" but NameCard(Ctrl.Tag Mod 13) gives "King of spades".
And as a matter of fact using Mod 13 always gives spades. Do you have any idea why the Mod 13 was there?
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
Quote:
Originally Posted by
MartinLiss
And as a matter of fact using Mod 13 always gives spades. Do you have any idea why the Mod 13 was there?
No. That may have been originally done by technorobbo.
-
Re: Flickering Buttons: How Do I Get Rid Of Them?
It still doesn't work.- I had a 4 of clubs as the first card. Called it higher.
- Result was a 7 of Spades, called it higher.
- Result was a 6 of Spades. While it is supposed to be the wrong card, the sub for the right card was set off instead of for the wrong card.
- Called the next card higher, and the result was a 2 of Diamonds (or whatever red suit). The HigherWrongCards sub was set off (rightfully so).
I think I know what is supposed to be done, but isn't it okay to take my suggestion and at least try it? (not saying it to be rude or anything).
I have another suggestion:
Maybe if I could store the deck of cards in a separate sub per deck. Maybe the NameCard sub (originally created by technorobbo) is not working well. Looking back at my Blockbusters game code from last summer, I was originally planning on retrieving the letter combinations for each label on each block from a text file. You suggested that I use lines that start with "strLetters(0)", "strLetters(1)", "strLetters(2)", etc. followed by the letter combinations, and placing them in the FormLoad area.
Well, I was suggesting that the following code that I was originally planning to retrieve from a text file could be put into a separate sub for each deck of cards and have the program choose each card at random, using each card only once for each round. Here's how I suggest the code be done (and copy/paste the same code and use for the blue deck):
Code:
strRedCards(1) = s2.bmp|2|a Two
strRedCards(2) = s3.bmp|3|a Three
strRedCards(3) = s4.bmp|4|a Four
strRedCards(4) = s5.bmp|5|a Five
...
strRedCards(50) = dq.bmp|12|a Queen
strRedCards(51) = dk.bmp|13|a King
strRedCards(52) = da.bmp|14|an Ace
There would now be 3 columns for each strCards(i) line. The first column would retrieve the corresponding card on that line for revealing on the board. The second column would be used to designate the corresponding card numeric value (2 to 14). In this case, here is how it should function:
The oldRedCardValue should not be a number between 0 to 51 (or 1 to 52), but should be a number that appears in the second column (2 to 14). Here is a prime example:
If oldRedCardValue < i Then <== Ace of Hearts, value recorded as 14 from Column 2 on the strCards(39) line, not 38 in the deck
oldRedCardValue = i ' <== Two of Clubs, value recorded as 1 from Column 2 on the strCards(14) line, not 13 in the deck
If CurrentSlot(red) < 4 Then
HigherRightCards ' <== This is the sub that should be set off, because 14 (the oldRedCardValue, not 38) is less than the i value that should be recorded as 2. The new oldRedCardValue (oldRedCardValue = i) is now recorded as 2 (not 13 or 14 as in the deck)
ElseIf CurrentSlot(red) = 4 Then
GameWin
End If
Else
HigherWrongCards
End If
Also, I want to tell you that the suit is not a necessary element for determining the card value. If you view a few of these clips:
http://www.youtube.com/watch?v=N8VLRQsoeKI
http://www.youtube.com/watch?v=FmdYjy9Gns4
http://www.youtube.com/watch?v=_XgqBCSAftg
You will notice that there is hardly any mention of "of spades", "of hearts", "of diamonds", or "of clubs" when the cards are revealed (if there are, it's just a rarity). Just the card value in words that is retrieved from column 3 on the strCards(#) line, and the following code:
Code:
SetDialog "It's the " & NameCard(CurImage.Tag) & "!"
Should be replaced with (using pseudocode):
Code:
SetDialog "It's " & (Column3 on strCards(#) line) & "!"
I think maybe this is something worth considering. The NameCard may not be working properly, and the ShuffleRedCards (and Blue) may only work with games such as Blackjack, Poker, Solitaire, etc. It may not be necessary for Card Sharks, as the cards would normally be selected at random for this game.