|
-
Dec 16th, 2014, 06:40 PM
#1
Thread Starter
New Member
Simon Game Visual Basic 6.0 Coding Help
Hello! I need to code a game called Simon, where you follow the patterns by pressing the buttons. I will display what I have thus far but I am stuck. How would I be able to generate a random number from 1 to 4 and Store that random number into the array. I need to Run through the array and based on each number show the corresponding color as lit (could be nothing more than changing from DarkRed to Red or something similar)
I would use Buttons for each of Simons color pads. A control array would allow you to run back through the array with each button click to see if the button clicked is the next in line and matches simons pattern.
I understand that that is what I have to do but I have never been taught how to code that. And where would I put that In my coding?Please help?
simon coding.docx
The first picture is what the program would look like and the second one with the sky-blue background is the about form in the menu
-
Dec 16th, 2014, 07:12 PM
#2
Re: Simon Game Visual Basic 6.0 Coding Help
Random nr btwn 1 & 4: Int(Rnd * 4)+1
Size an array to how many levels you want to max out at. Is each new level, just 1 more button pressed? If so, level 1 = 1 button, 2 = 2, 3=3 4=4, etc. Of course you don't have to start out at 1 but may want to start out at level 4 or 6 for example. Either way, size the array: Dim arrLevels(1 To 100) As Byte. 100 is the max nr of levels
Declare a nrLevels variable and keep it updated each time the user gets thru a level correctly, increment the level & randomly select another color, add it to the array: arrLevels(nrLevels) = theRandomColor
As each button is clicked compare that to the array: If arrLevels(n) = colorClicked then let loop continue. If user fails, abort your loop. Your loop would start at 1 and terminate when the user fails or has matched the current level correctly.
pseudo code might look like
Code:
Do
For n = 1 to nrLevels
let user click button
if button <> arrLevels(n) then
user failed
exit for
end if
Next
If n > nrLevels Then ' user got thru the loop & all were correct
if nrLevles = 100 then
user maxed out on levels
exit do
else
nrLevels = nrLevels + 1
get next random button & add to the array
For n = 1 to nrLevels
animate your buttons
next
prompt user to start their turn
end if
else
exit do ' user failed
end if
Loop
game over
The above is not actual code, just something off top of my head to get you started. Have fun coding
-
Dec 19th, 2014, 04:10 PM
#3
Thread Starter
New Member
Re: Simon Game Visual Basic 6.0 Coding Help
I think that you misunderstood, and I did not clarify. For each of the four buttons there is an image box and surrounding that image box is a shape box(which is the border) and I am trying to make that pop up whenever simon picks his choice. I tried coding what you gave me into visual basic but it does not work. The following parts are confusing me:
1. How would I code and make an array for each time the user successfully completes a level to add on a button? I tried coding it in but it did not work.
2. I dont understand how to formulate the coding for 'let the user click button'. I am in the very beginning of class and we have not learned all of the key components of Visual Basic 6 yet.
3.what does 'button; mean? Would that just be the image box?
4.under the nrlevels=nrlevels+1, you say to 'get random button and add to the array'. This part stumped me. We have only recently learned how to do an array. How would I do that?
5. When I animate my levels how would I make it so that when the image box is clicked and when the computer makes it choice, the border(shape box) appears? I have animated it at the beginning of the program but that does not seem to work.
As you can see, A lot of things have confused me and I feel really confused. I do not want it to seem like I am begging for code, I just want to learn how to code this game and pass my class.
Thank you! And sorry for my stuo
-
Dec 19th, 2014, 04:11 PM
#4
Thread Starter
New Member
Re: Simon Game Visual Basic 6.0 Coding Help
I think that you misunderstood, and I did not clarify. For each of the four buttons there is an image box and surrounding that image box is a shape box(which is the border) and I am trying to make that pop up whenever simon picks his choice. I tried coding what you gave me into visual basic but it does not work. The following parts are confusing me:
1. How would I code and make an array for each time the user successfully completes a level to add on a button? I tried coding it in but it did not work.
2. I dont understand how to formulate the coding for 'let the user click button'. I am in the very beginning of class and we have not learned all of the key components of Visual Basic 6 yet.
3.what does 'button; mean? Would that just be the image box?
4.under the nrlevels=nrlevels+1, you say to 'get random button and add to the array'. This part stumped me. We have only recently learned how to do an array. How would I do that?
5. When I animate my levels how would I make it so that when the image box is clicked and when the computer makes it choice, the border(shape box) appears? I have animated it at the beginning of the program but that does not seem to work.
As you can see, A lot of things have confused me and I feel really confused. I do not want it to seem like I am begging for code, I just want to learn how to code this game and pass my class.
Thank you! And sorry for my stupidity....
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|