Saturday, May 12, 2012

Idea to dodge obstacles for the Grade 10 PAT

If the students have to write an adventure game they will probable have to include a stage where you have to cross a river or a road or the sea...

Here is some basic code to make it look like many different cars are passing by at different speeds, although you only need one sprite:

Make one new sprite - pick a car from the sprites under transportation.  Then import other cars as costumes for this sprite.  That means it will look like a different car every time you change to the next costume.
The code continuously

  • picks a random speed
  • change the costume so that it looks like a different car
  • puts the sprite in the starting position (on the left), and
  • makes the sprite move across the stage until it reaches the other side (right end of the stage).

You can duplicate the sprite and adjust the code slightly to make another car come from the right hand side and move to the left.
Now you can try to make the chicken cross the road :-D

No comments:

Post a Comment