Intermediate Scratch – Challenge 15 – Create a Rock-Paper-Scissors Game for 1 or 2 Players!

CDA-S2-Challenge15-RockPaperScissorsThis week’s challenge is to create a game of Rock-Paper-Scissors.

This week, you can choose to either create a 2-player networked game with a friend, or if you don’t feel like doing networking, you can write a 1-player version where you play against the computer. It’s up to you!

This challenge makes use of the networking ideas that we have covered in recent weeks, when writing a network Chat program and when writing 2-player Pong.

The big ideas behind today’s challenge are:

  1. How to design a 1-player or 2-player program
  2. Using variables  for exchange of data between computers and to pick random numbers
  3. Using broadcasts to sync parts of the game

Here are the presentation slides from the day, in PDF format: CDA-S2-Challenge15-RockPaperScissors.pdf

Next time, we will help ninjas to work on their own games.

If you would like me to send you these slides in PowerPoint format, feel free to get in touch on Twitter or via the comments!

Scratch Advanced – Week 16 – Stop Motion Animation

We are going to revisit one of the topics we did earlier in the year. Do you remember The Movies, where we had the spinning wheel looking like it was going backwards?

Well we are going to do something similar over the next couple of weeks, where we will investigate and use Stop Motion, this is the same movie making technique that the Wallace and Grommet Movies are made with.

So what are we going to learn, well, we are going ot use a lot of techniques we have used before, so it is more a case of what are we going to re-learn.

  • Broadcasts – to make our code smaller and neater
  • Variables to simplify the code, specifically local variables.
  • Speech Bubbles.
  • Program Flow, there are a lot of things that need to happen and we need them to happen in the right order.

We are going to animate The Three Little Pigs and the Big Bad Wolf.

As you know this is a little story and in stories, things happen one after the other, so that is what we need our code to do as well, there is not much point having everything running from a Green Flag, we need some way to control the flow of the Program.

First we are going to need some Sprites though.

  1. A Wolf
  2. Pig One
  3. Pig Two
  4. Pig Three
  5. Straw House
  6. Wood House
  7. Brick House

As you know my drawing skills are excellent, so I have come up with the following:

Sprites

Nice aren’t they. I’m sure you can do better.

When the Story starts there is only the Wolf, One Pig and the Straw house visible, so all the others need some code under a Green Flag to get them ready, backstage, ready for when it is their turn in the story.

The Wood House for example has just a HIDE under the Green Flag, you will need to determine what each Sprite will need under a Green Flag control. Basically anything to get it ready for the story.

On to the Stop Motion Animation.

Stop Motion is where something is moved a small bit and then a picture taken and then moved another small bit and another picture taken, until the figure has moved to where it needs to be.

We are going to do something similar, where we will set up the x and y position of the Sprite in local variables and then get another piece of code to do the actual moving, this helps to make the code a little easier to read as it splits it into smaller sections.

Here is the code for example that one of Pigs uses to move to the next House

Pig2

You can see how I have split it into smaller pieces and that I have used local Variables to set the x and y positions.

You will need to figure out where on the screen you want the Sprites to go and how fast you want them to go there, that will determine the numbers that you need to use when you are SETting the xPosition and yPosition variables.

As the Wolf is kind of the main Character in the Story, we control everything from his Sprite. We do one thing after another and if we need to wait for something else to happen we use a Broadcast and Wait, this will control how the code flows from the top to the Bottom.

Here is all the code for the Wolf Sprite

Wolf

Now, my code is very scrappy, there are a number of BUGs that need to be sorted out, for example when Pig One moves to the Wood House and the Wolf comes over, the Speech Bubble covers the Pig, this should be changed really.

At the end of the day, you can make your Story as simple or as complex as you like, one thing that I can tell you though, is that the more time you spend on the project the better it will end up.

You can also do real Stop Motion with a Camera and Lego, you can then import the different pictures into Scratch as either Stages or Sprites.

I did one as Stages which is up on the Scratch Web Site and here is one of the Stages from it.

LegoStopMotionSample