← Code

Objects with turtles

Build a falling-stars game with many turtles, and tidy it step by step: from separate variables to lists, dictionaries and classes.

Start1. Many turtles

Many things on screen

Many turtles at once, then lists and dictionaries to keep track of them.

1Many turtlesNot started

Make more turtles with Turtle(), give each one its own commands, and find out what a game with several stars costs in code.

  1. Predict
  2. Run
  3. Investigate › Match the lines
  4. Investigate › Count the cost
  5. Investigate › Spot the bug
  6. Modify › A blue star
  7. Modify › A fourth star
  8. Make a rock
  9. Where this leads
Start lesson
2Lists of starsNot started

Keep the stars in a list and their speeds and points in lists beside it, so one loop moves them all, and find out why lists side by side are fragile.

  1. Predict
  2. Run
  3. Investigate › Eight stars
  4. Investigate › Same place, same star
  5. Investigate › Spot the bug
  6. Modify › Six stars
  7. Modify › Different points
  8. Make a bad star
  9. Where this leads
Start lesson
3One dictionary per starNot started

Classes

Make your own kind of object with class, then give it methods: one line adds another star.

4A Star classNot started
5Stars that move themselvesNot started

Progress is saved in this browser only. Nothing is sent anywhere.

For teachers: Teacher guide (notes, answers, solutions, slides and worksheets)