Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Simon Say's (http://www.alice.org/community/showthread.php?t=7481)

rmcguire 11-01-2011 02:09 PM

Simon Say's
 
I'm trying to make a bomb diffusing game. To diffuse the bomb a pattern will be displayed and the player must repeat the pattern. The game will be very simular to the classic Simon Say's handheld game where the lights flash and the player is suppose to press the button that was lit up. I'm looking for some help with getting the sprites to display a pattern, wait for the user to copy it, recognize if the pattern was correct and give a new one, or recognize a pattern is wrong and repeat it. Any help with this would be greatly appreciated!

Powerhouse64 11-05-2011 04:04 PM

I can give you a bit of help with this. If you want the pattern being random, let me know and I can try to give you a bit of info on that, but for checking if the pattern was right, I have a pretty reliable system for checking this.

If/else statements are key for this.
First: create your pattern and display it, then give the user a turn at trying to replicate the pattern
Second: create an if/else that says: if [user clicks on the first object of the pattern] (I'm assuming that the user clicks on objects in a certain order) then [go to the next if/else in the next step] else [display fail/blow up the bomb or whatever you choose]
Third: create your second if/else statement that checks if the second click matches the pattern that goes like this: if [user clicks on second object of the pattern] then [go to next if/else] else [display fail/blow up the bomb or whatever you choose]
Fourth: Wash, Rinse, Repeat until the user reaches the end of the pattern.

Hope this helps clear things up! :)

rmcguire 11-05-2011 04:28 PM

There is a potential to have the patterns display at random. I had every intention of just doing a number of set patterns to make the programming a little easier, but some insite on the random would certainly help.

I'm familiar in what you suggested with the if/else statements have doing a typing game that looks for a specific letter in another programming language. For that I used a list to store the word that was to be typed. For each character that the user typed in would store it in another list and recognize if the word was right. Being fairly new to Alice, I'm wondering if I would have to do the same method/ can do the same method.

Powerhouse64 11-05-2011 04:38 PM

[QUOTE=rmcguire;43046]There is a potential to have the patterns display at random. I had every intention of just doing a number of set patterns to make the programming a little easier, but some insite on the random would certainly help.

I'm familiar in what you suggested with the if/else statements have doing a typing game that looks for a specific letter in another programming language. For that I used a list to store the word that was to be typed. For each character that the user typed in would store it in another list and recognize if the word was right. Being fairly new to Alice, I'm wondering if I would have to do the same method/ can do the same method.[/QUOTE]

I'm not really sure what you mean by that, but I'm sure it made total sense to everyone else. Basically what you can do for random patterns is have a CRAPTON of if/else statements asking for a random number and if it is within this range, have this object light up (I'm assuming that objects light up in a pattern for your game) else go check another if/else for another object, and then have Alice create a list for the order of if/else statements chosen, have each data point on that list (being the program for a certain object) correspond to an object. And have Alice create another list for what the user clicks on, then cross-check the data points on those two lists. I know this is a bit confusing, but I am terrible at re-wording my explanations for clarity. If anyone else wants to try to translate what I said, please do so!!!

I hope this helped give you a bit more of an idea behind creating random patterns for a Simon Says game (I did something similar, but unfortunately I've deleted the world and don't have a photographic memory)

rmcguire 11-05-2011 08:38 PM

Shown below is the code that I have gotten done so far. The code in the world.play method is where the two lists, clickedButtons, and p1/p2 are being compared to each other. However the comparison isn't working. What am I doing wrong?


Bomb's Code

Created by: Rory McGuire

world

Events

When is clicked on startbutton
Do:
startbutton.start


When is clicked on startbutton
Do:
world.play


When is clicked on anything
Do:
world.buttonflash ( object under mouse cursor )


Methods

world.pattern 1 ( )
No variables
redbutton.flash


world.record clicks ( [Obj] whichButton)
No variables
If world.record
insert whichButton at end of world.buttonsClicked duration = 0 seconds
Else
Do Nothing


world.buttonflash ( [Obj] whichButton)
No variables
world.record clicks whichButton = whichButton
If ( whichButton == redbutton )
redbutton.flash
Else
Do Nothing
If ( whichButton == bluebutton )
bluebutton.flash
Else
Do Nothing
If ( whichButton == yellow button )
yellow button.flash
Else
Do Nothing
If ( whichButton == greenbutton )
greenbutton.flash
Else
Do Nothing


world.play ( )
No variables
Do together
world.pattern 1
world.timer set value to 0
While ( world.buttonsClicked != world.p1 )
increment world.timer by 1 duration = 1 second
If ( world.timer == 3 )
greenbutton.flash
Else
Do Nothing
If ( world.buttonsClicked == world.p1 )
world.timer set value to 0
remove all items from world.buttonsClicked duration = 0 seconds
world.pattern2
Else
Do Nothing


world.pattern2 ( )
No variables
Do together
redbutton.flash
Do in order
Wait 0.25 seconds
bluebutton.flash


redbutton

Methods

redbutton.flash ( )
howFast = 0.12
Do together
Do Nothing
redbutton.Button set color to (1, 0, 0) duration = howFast seconds
redbutton play sound world.beep-29 (0:00.293) duration = Full Length
redbutton.Button set color to (1, 1, 1) duration = howFast seconds
Do together
Do Nothing


bluebutton

Methods

bluebutton.flash ( )
howfast = 0.12
Do together
bluebutton.Button set color to (0, 0, 1) duration = howfast seconds
bluebutton play sound world.beep-28 (0:00.293) duration = Full Length
Do together
bluebutton.Button set color to (1, 1, 1) duration = howfast seconds


yellow button

Methods

yellow button.flash ( )
howfast = 0.12
Do together
yellow button.Button set color to (1, 1, 0) duration = howfast seconds
yellow button play sound world.beep-22 (0:00.267) duration = Full Length
Do together
yellow button.Button set color to (1, 1, 1) duration = howfast seconds


greenbutton

Methods

greenbutton.flash ( )
howfast = 0.12
Do together
greenbutton.Button set color to (0, 1, 0) duration = howfast seconds
greenbutton play sound world.beep-20 (0:00.267) duration = Full Length
Do together
greenbutton.Button set color to (1, 1, 1) duration = howfast seconds


startbutton

Methods

startbutton.start ( )
No variables
world.record set value to true

Powerhouse64 11-05-2011 10:22 PM

Could you upload whatever you have so far? That would be a lot more helpful than having someone scan through your code. Personally, I'd rather have it IN Alice to read. So if you want to upload your world, I could help you a lot better that way. And I can't guarantee that I can fix all the problems with your world, but I'll give it my best. I'm glad to help if I can though!

Centuri0n 11-05-2011 10:35 PM

W 0 w
 
:eek:That is going to be one long code, nice work so far

rmcguire 11-06-2011 11:35 AM

1 Attachment(s)
Yeah sure. Here it is

Powerhouse64 11-06-2011 11:40 AM

Loading it up right now... I'll get back to you in a few, hopefully!:p

Powerhouse64 11-06-2011 11:43 AM

Quick question, were you aware that by pressing the second, third, then fourth button, you are playing the first three notes of the Lavender Town theme song from Pokemon? 'Cause that's exactly what that is!:D And I'm looking through the program now, but I'm not seeing where that list checking issue is coming up...:mad:


All times are GMT -5. The time now is 12:58 AM.

Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.