Game State – Game Loop

This week we tried out Code Club World’s Desert Race project.  One Code Club member used this for his independent project last round, so we had one expert.  We used his final project to demo the game. Screen Shot 2017-03-12 at 11.20.11 AM

Desert Race is a fairly simple 2-person race to the finish.  The main concept in this game is setting a game state variable to control the action. In event driven games is important to control the allowable events – like when to start. And we don’t want anyone to cheat by starting before the start signal.  Setting up a game state variable, ‘racing’, like a Boolean with 0 (not racing) and 1 (racing) is the concept I was hoping they would take in while making a cool two person game.

Defining a Boolean for game state is the first step to building a Game Loop that programmers use when creating more complex games.

Scratch Wiki also refers to it here: https://wiki.scratch.mit.edu/wiki/Game_Loop.

My fourth graders may not ever get to that level of programming here in Code Club, but it is a powerful idea. I have used this programming technique in (non-Scratch) games I’ve created in the past and found it useful.

I also made a quick version of the project adding a bit of 3D perspective with my Space Race project.  The racers (cat and dog) get smaller as they head to be the first to reach the planet.

Screen Shot 2017-03-12 at 11.26.57 AM

The students made some nice games. Many customized their Sprites and a couple recorded their own “win” sounds.

This one below has some almost imperceivable pitfalls that send you backwards (the opposite of a booster).

At the end of the day a few students asked to be able to keep working on the Desert Race project for next week -they needed more time and were enjoying the project.  I think I’ll let them, but I’ll need another project for those who finished or want to move on.  So I asked one of the two girls in the Club what she would like to work on and she said, how about making an ebook.  I asked if she meant like an animated story?  I’d love to focus on animation more – there are some great techniques to making things look like they are moving – I love Tumbling Santa.  Also, I’m thinking I need to show her Bubble103’s Scratch projects.  Maybe she wants to make a tutorial (nonfiction ebook).  There are a lot of How To projects on the Scratch site.  I’m considering these two options for next week.

Also awesome this week was this project:

Screen Shot 2017-03-12 at 12.18.11 PM.png

This student’s race project was lost when Scratch 2.0 offline editor crashed. He was mostly done and he lost all his code. Instead of recreating it, he made this cool project. (It is a bit glitchy, but neat.)

Maze Race Game

Last week’s Code Club took a lot of planning and preparation.  I’m going to write about it in 2 parts. Here’s part 1.

I introduced one last project for Code Club on Wednesday.  I wanted them to learn that Sprites can sense what they are touching, like a color, or the stage’s edge, or another Sprite. Collision detection is a fairly basic element in many computer games and not trivial to code for in many programming languages, in my opinion. Scratch makes it fairly intuitive. I found three different instructional resources that teach the creation of a maze or race game in Scratch.

Code Club World has a Boat Race project in beta form. It is so new, in fact, that when I went looking for a project of this type, it was only available from Code Club (for UK clubs only).  Looks like a fun project and I want to try it next time.

In Jeremy Scott’s “Starting from Scratch” guide, there’s a maze game that introduces collision detection. I like this resource from the Royal Society of Edinburgh.  It explains basic computer science concepts and ideas that the students will be exposed to using Scratch. That helps me use the correct terminology and know the “why” do I teach this behind the “how” do I teach this. The maze game instructions looked easy to follow to me, but it wasn’t in the Code Club format that the students had grown used to.

Maze game.

Maze game -use the arrow keys to reach the dragon. Don’t touch the sides.

I also came across Simon Haughton’s website and in his second Scratch lesson he has a car racing game. The goal is to cross the finish line without driving off the track.  Driving off the track sends you back to the beginning. I like how he has the students make their own race track in 3 simple steps: Flood the stage with color,  draw or erase the “track”, and draw a finish line in a different color.

My take on Race Game

I used his instructions first with a group of 4th grade students who have been learning a bit about Scratch during school.  We didn’t have time to do any extensions, like adding a timer, enemies or sounds, but a couple of students added a “crashed” costume to their car. Turns out if the new costume is bigger or a different shape than your original, you may be touching the edge of the track even when sent back to the start.  Another student was starting to add an oil slick, like my water hazard, before we ran out of time.

Unsure of how much coding time we’d have in Code Club this week, because we had a guest speaker coming talk about software development, I decided to started with Jeremy Scott’s Maze game instructions. We used the maze gif resource for the stage but I let them choose any two sprites for explorer and target. One student spent the whole time editing the sprite to his satisfaction -a graphic designer in the making, perhaps?  Next we set up the arrow key controls on the explorer sprite and added collision and target detection.   By the end of Code Club some were able to start a second level of their own design.

Second level student example

Second level student example

cp maze

Second level, student example

The jump to using different sources for instruction was hardest on my volunteers.  Our speaker stayed to assist and I had my high school student there as well. I had experience fielding questions with this after my 4th grade class earlier that day, but my volunteers were grasping the concepts at the same time as the students. Also the handouts weren’t as readable as they could’ve been. After a rough start, things settled down and the students seemed pretty independent.  Hey, I think that’s success right there.

What about that guest speaker, you ask?  That’ll be part 2.