PDA

View Full Version : Chapter 5 Game project PP 5.10


Sharris
05-07-2014, 10:32 AM
In this assignment I had to create a memory game where a sequence of buttons light up and the user has to press the buttons in that order. The only problem I am having with this project is how to have the level start over when the user selects the incorrect button and have the timer stop when they follow the sequence correctly. Here is what I have so far can anyone help me? Thanks.

jrrTolkien
05-07-2014, 01:46 PM
This is possible with careful use of integers. Have the integers change after the button is clicked, then have an if/then so if all the integers are at a set value, then you win. For the timer, Have it an if/else where if the "win" integer == 1, do nothing, else if the timer is above zero, minus 1 and display the count. For the if you lose, have all the integers reset. Put if/elses in each so that they only change if you click them in the proper order,

(Use nested loops)

button2's config:
if button1 == 0 and button3 == 0 and button4 == 0 then button2 == 1
button1:
if button2 == 1 and button 3 == 0 and button4 == 0 then button1 == 1
button3:
if button1 == 1 and button2 == 1 and button4 == 0 then button3 == 1

Then have when the world starts, infinitely loop:
if button3 == 1 and button2 == 1 and button1 == 1 then win == 1

After you win, set all the integers to 0 and do the whole thing over again! Hope this helped!

-Jrr

chickentree
05-08-2014, 01:23 PM
In this assignment I had to create a memory game where a sequence of buttons light up and the user has to press the buttons in that order. The only problem I am having with this project is how to have the level start over when the user selects the incorrect button and have the timer stop when they follow the sequence correctly. Here is what I have so far can anyone help me? Thanks.

I'm sorry but your project is not working as you think it is. I don't want to spend a lot of time on a detailed explanation but is important you understand what is there.
You have one method and five events, one of which calls the method.
In my first method you do the following

Set all the button.button (the center of the button) to be invisible
wait 5 seconds - This is a LONG time for a user to wait with nothing going on.
Flash the buttons presumably in the order you want the user to copy.
Start the timer
Set all the button.buttons back to invisible - even though the step above turned off all the buttons it turned on.
Cause each button to blink in order
call Countdown on the timer again, even though it is not clear the last countdown has expired.

After "my first method" does all this, it never runs again.
Meanwhile, as long as the movie is running the other 4 events cause the button.button on the corresponding button to become visible. Whether it stays visible depends on the timing. If "my first method" is still running, the button.button will become invisible in steps 1,4,5 and possibly 2.

There is no logic to check if the user turns on a particular light and nothing to indicate the order in which the lights are turned on.

I know that the email medium can cause peoples comments to seem harsher than they are and so I want to stress I am trying to be constructive and hope you will take the above in that light.
As to what to do I would write separate methods for:
Initialization of every thing.
Initializing all the things needed for a round.
Starting the play
Checking the users input - this is called from an event when the user clicks on a button.
Check for time-outs while the game is running.
handle restarting or ending the game.


If you want to use the time but be able to randomly start and stop it you will have to modify the countdown method to allow for this. You could add a Boolean variable to the timer maybe called "active" to indicate whether the counter should be counting.

Hope all this helps,
Mark

levimrj
05-09-2014, 06:47 PM
I am also tryin to make this game and for the life of me I can't even figger out how to start it! I've been doin fairly well with Alice but I can't rationalize out this game not one bit.
Are there any tutorials or help I can find that would help explain it to me?

chickentree
05-09-2014, 10:08 PM
I am also tryin to make this game and for the life of me I can't even figger out how to start it! I've been doin fairly well with Alice but I can't rationalize out this game not one bit.
Are there any tutorials or help I can find that would help explain it to me?

Can you post the requirements for the project? Without them it is difficult to provide the right advice.

Also, where are you at in the course?
Can you
1. Create Methods?
2. Create functions?
3. Use events?
4. Use lists?

It would also help if you could provide an outline showing the pieces you need to get the project to work. I am just looking for a level of understanding so I know where to start helping you. If you have trouble with the outline, don't stress out just post what you can.


Mark

MrMoke
05-09-2014, 10:32 PM
Mark is Right- I just had to guess without direct knowledge regarding specifics of where you are, and minimum requirements.
I sort of assumed a few things, got on the PC, and created something like it. It's a little different because you can pick anything from 1 upto 10 switches for the REAL Memory Nerds.:eek:

Lists are essential to make this work efficiently.

Attached is zipped WMF file, so you have to click and open it to view.