Tkinter Annoyances

I am on the last chapter in this kids book Creative Coding in Python. It has me creating a game akin to Kaboom for the Atari 2600. I even grabbed an image for the bad guy in that game for my own game. Balloons (or candies) come down the screen. You have to catch them. But avoid red candies!

One final tweak I did was to make that candies speed up every third one you catch. That makes for a quick game. I did have some problems display the user graphic initially. The problems came back to haunt me during collision detection. The graphic just would not display where I wanted it.

Eventually I figured out that when I specify an x and y coordinate to the create_image() function of the canvas, those coordinates are not treated as the upper left hand corner of the image. What a strange default behavior. I had to specify an anchor value of "NW" to make that happen.

I also had some problems getting the key press detection working. Luckily I ran into this problem before. I had to call the focus_set() function on the canvas for it to receive the keyboard events. For some reason, my book skipped that crucial detail.


 

Popular posts from this blog

HTML Web Page Builder

Memories of Logo

Mission Accepted