Simon says – Time to play!

the scratch version of simple simon from MagPi magazine

the original Scratch project, courtesy of MagPi

Well, we’re back at school now and settling in.  I’m looking forward to the first few computing classes next week, but I took time out this weekend to have a play on Scratch and BYOB.  I started off with a project from the latest MagPi magazine, on building a Simple Simon game in Scratch.

The game itself was straightforward, following the code given, although I was reminded in the process exactly what the broadcast and wait block does (broadcasts a message then suspends activity on that thread until the receiving thread has finished). That might well come in handy when I sort out the animations for my virtual pet, as I’d been concerned that other scripts might interrupt any animation that’s run.

However, when I played the game, I found one thing that didn’t feel right – it generates a four tone/light sequence, asks the player to repeat it, then generates a completely new five-tone sequence, which quickly makes it very difficult to play as the difficulty increases.  I seem to remember that the original version of the game would add one to the sequence each time, rather than changing it to a new sequence, so I decided to produce my own version and move it up to BYOB in the process.

The game loaded fine from Scratch, although there were one or two issues with the length of list, which apparently is handled slightly differently between the two programs.  However, I was soon picking the code apart and working on the alterations I wanted.

the block I built to cycle through a list and broadcast each item

the block cycles through a list, broadcasting each item in turn

My first problem was that the original game would generate each tone, broadcast it and then add it to the list.  If I was going to add a number to the existing list, I would need to find a way to cycle through all the objects in the list, broadcasting them one by one.  This seemed an ideal candidate for a self-built block.

Looking around the help system for BYOB and finding words like predicates thrown around merrily made me realise that despite appearances this definitely is not just for kids – while kids can quickly get up and running doing something with Scratch, it’s capable of some pretty powerful stuff, even more so in the BYOB version, although the more high-powered you go the more fiddly it gets to produce the blocks needed, with blocks within blocks within blocks.

Simple Simon game, BYOB version

Simple Simon BYOB version

I had to modify the flow of the main program in order to set up a 4 tone sequence, broadcast it, wait for response, then check it.  If the response is correct it adds to the score, generates and adds a number to the sequence then rebroadcasts, while if the response is wrong it takes a life away and replays the sequence as it is.

I definitely needed paper to scribble my thoughts on to work out the logic of the program, but it went together fairly well.  You know when a game is playable, when you have problems forcing yourself to test it rather than just playing!

The new version is more playable than the original, it makes a little use of the extra facilities of BYOB and I learnt a lot about the use of lists in Scratch/BYOB in the process.

The game currently keeps score during the game but is reset on restarting – one improvement would be to add in a high score variable, to keep track of the highest current run. I could also start the score at 4 instead of 0, so that it reflects the number of notes in the sequence.  An alternative would be to start with a one-note sequence, but that might make the game too slow to get started.



About emmyleigh
Writer/editor/proofreader who loves technology

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: