Tuesday, 6 June 2017

Rivermead - How To Write Games 101

For this challenge, they're going to need (this is not an exhaustive list ...)
  • An idea
  • Some planning/design skills, so they can work out how they're going to implement said game
  • Preferably, some means of describing the game and design so that if/when they don't finish, at least they can show what they thought of as a set of sketches or whatever
  • Familiarity with the Scratch features that are required to implement the game
  • Obvs, Scratch coding skills!
  • Presentation skills of some sort
Pretty non-trivial...

Ideas

What kind of games could be of interest?
  • Maths games
    • Counting
    • Shape recognition/matching
    • Sum of numbers up to 10
    • Times tables
  • Word games
    • Thing/name match
    • Spell game (say word, have player pick/drop letters)
    • hangman type game
  • Story games
    • Not sure how these could work but could be interesting!
One of the big questions is "Do you expect your player(s) to be able to read?". For kids younger than Year 4, some will, some won't. There's a lot of possibilities for games that don't require reading, or teach reading/numeracy without prior reading skills.

Scratch - what can it do?

Scratch can (not an exhaustive list)
  • "say" things i.e. have a sprite with a speech bubble
  • really say things i.e. replay recorded sound, which could be speech
  • detect keyboard key depressions
  • display sprites, and have them change their appearance ("costumes")
  • move sprites around, or have the player drag and drop them
  • sprites can detect when they're clicked, or touching other sprites, colours etc.
  • switch the stage "background", and the relationship of sprites/stage (forward/backward in layer)
  • play tones, with pitch and timing i.e. simple tunes if you programme it
  • change colours of sprites, stage etc.
  • clone sprites, which can then know if they are clones
  • stage and sprites can 
    • broadcast messages
    • receive messages

Planning

Given the two basic types of entity in Scratch, sprite and stage, how will you set up your game? Just about everything will have to be a sprite, in fact, the stage can provide a backdrop, and can also contain code that isn't sprite-specific e.g. initialisation, choice of random values to drive game etc. 

You will probably need to have at least one sprite that "interacts" with the player, by "say"ing things, or using recorded speech to actually say them. It's also possible that could be done by a stage "background" which is switched appropriately, but the stage doesn't have the "say" verb.

How does the player interact with the game? It's probably easiest to click on a sprite, or use arrow keys to move a sprite. You probably need a start/stop/reset capability e.g. "ask me another". It's also possible to drag a sprite and drop it on another sprite, and have them detect that. 

Make a sketch of a stage. Put sprites on it to show the starting positions. Add storyboard images to show the progress of the game. Or just do it in Scratch if you're fluent enough!

An Example

Let's make a counting game. Show the player a number of objects, and have them "say" how many they count. Let's say 1-9 objects to start with.

How do we decide how many objects to show?
Example random number setting code
What will we use for "objects"? We have to show the number "number_to_count" objects. How do we do that? Various ways...
  • Sprites, obviously... 
    • Have the required maximum number of objects in existence, and display only the number we need
    • Make the required number of objects, and put them in position on the stage
  • Have a stage with at least N different backdrop, where maximum number of objects is N, with each having a different count of objects
    • This seems pretty clumsy... also hard to change the type of objects, since any change requires a whole new backdrop!
I opted for the first option (sprites, N in existence, display ("show") as required). The sprites are just dropped in various positions on the stage, and live there all the time, shown/hidden as required.
Example countable object code - shows/hides depending on "number_to_count"
How will the player interact with the game to say how many objects they've counted? Scratch doesn't do voice recognition... so they will have to click on something or drag/drop something. How about we show the integers 1-9, and they click on the one they think it is?
Simple stage with integers displayed
The integers are all sprites, because it makes it easy to detect them being clicked. They have to detect if 
  1. they are clicked 
  2. they are the right answer
and then tell someone that this has happened.
Code for integer "1" sprite
How are we going to tell the player what to do, and if their answer is correct or not? I know, let's use a sprite... and pick the default cat, because it's Scratch.
Game stage showing interaction sprite, count sprite(s) and answer sprites
The interaction sprite needs some code...

The whole thing can be test driven at https://scratch.mit.edu/projects/164774926/#player.

Improvements and Enhancements

Some possible ideas for making it better or more interesting:
  • Enable it for non-readers
    • Use recorded speech instead of text for all messages
    • Have the integer sprites announce themselves when clicked
    • Maybe have the object sprites say what ordinal number they are when clicked
  • Vary the difficulty - start with say 1-4, increase to 1-9 as number of right answers increases
  • More exciting rewards
    • Score - get a number of right answers, get a splash page
    • Different, random rewards/reward answers to mix it up a bit
  • Vary the type of objects
    • All the same, but randomly different each time
    • All randomly different every time!
  • Count a particular type of object from a selection of different objects e.g. apples/pears/lemons - how many apples are there?



New Victims - Rivermead!

I started out with Code Club as an assistant to Peter Higginson, and as part of that joined the STEM Ambassador programme. This is a great initiative that gets people from the "real world" (whatever the f... that is!) to go into schools and work with children on Science, Technology, Engineering and Maths related projects - not sure where computers fit, oh, possibly Engineering? Anyway, they get you your DBS certification so that you can actually get into a school. Which is quite hard these days - Hawkedon for example has checkpoints on the front and inner doors, with releases controlled from reception etc.

Since the Hawkedon sessions finished at Easter, I wondered if there was anyone out there needing some help. The STEM network people in Winchester send out an email with requests, and Rivermead Primary was looking for someone to help with a "Scratch games challenge" for their Year 4 (8-9 year olds). The Challenge is for the kids, working in pairs with a kid from another school they haven't met before, to design and code a game in Scratch that will teach someone younger than them something. Efforts to be judged by a panel of head teachers, on the basis of a presentation given by the children. Interesting... Target date 30th June, it's already May, and we only get an hour a week, after school (3.30-4.30). Could be a challenge for everyone!

Another (virgin) STEM Ambassador, Graham, had also volunteered - has experience with Cubs and other things like that though, and was a school governor. I also roped in Peter, on the basis that even though I was leading it, he would provide great backup, especially as I'm on holiday some of the times that the club runs.

At the time of writing, we've run three sessions, which have been based on material for the first two lessons at Hawkedon. It's been hard - the kids are a lot younger than the Hawkedon guys, and it seems they haven't had the same exposure to Scratch, although they have had some. There are also logistical problems - we're using Scratch2 online, rather than Scratch1 installed, and once they have had to use tiny netbooks that struggle to run the browser-based IDE. Gosh. Still, everything we do is better than doing nothing, right? And they are starting to think about it more.