This is a fun challenge to introduce young programmers to the powerful
Python tkinter
canvas component. However, there are a number of gotchas,
omissions, and "why doesn't this work?"s that could frustrate those who
miss them. These bits of Python are an attempt to help you through that with
corrections and additional comments.
The numbers correspond to the sections of the book as the code for each section is added.
A final revised-oop.py
version sticks with the general idea but
reimplements it in an Object Oriented way, (which is how most all games
are programmed in the real world). The revision also corrects the rather
annoying crippling of ship movement by using the <Key>
event instead of
tracking movement state and using <KeyPress>
and <KeyRelease>
methods.
Any comment or revision including the final reimplementation are released into the Public Domain for use as you like, but probably fall under 'derived works' from the DK book so if you don't have a book you should probably buy one to do anything big with any of this. The ideas implemented in this revision are nothing new and present in many other game examples on this site and elsewhere.