Etch A Sketch

Introduction

This challenge is taken from © The Coding Club Python books written by Chris Roffey, which serve as an excellent introduction to Python for younger age groups. The challenge is simple.   Write a Etch A Sketch program that recreates the popular 70s/80s Etch A Sketch toy.

Extensions

Can you add a color picker tool using some more events and key bindings? [solution instance=1] If you have a variable called pencolor defined earlier on in the game e.g. pencolor = “red”

  • Create new defs that update that pencolor to a new value in the same way that you did for xpos or ypos
  • Bind those defs to new key bindings using the number as the keybinding e.g bind(“0”, my_handler)

Can you add a clear screen method?

The canvas.delete(“all”) command can be used to clear the screen. It just needs to be placed in a definition that is attached to a key.

Can you add a pen up mode?

Pen up basically involves making the pen color the same as the background (of that square) so you cannot see it. However, how do you know where the pen is? This is where you need to create some sort of flashing cursor that moves as you redirect the pen. Tricky!

 

About CDB 361 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.