From the course: Building the Classic Snake Game with Python

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Animation with Python turtle graphics

Animation with Python turtle graphics - Python Tutorial

From the course: Building the Classic Snake Game with Python

Animation with Python turtle graphics

- Before we dive into the snake game itself, we're going to look at how to do animation with python turtle graphics. There's a lot of animation capability built into turtle graphics by default. For example, when you move a turtle forward using something like my turtle dot forward 100, my turtle does indeed move forward, which is a type of animation. However, sometimes you want more control of how the animation works and we can do this by turning off the default animation behavior using screen dot tracer zero, and instead, manually updating the display when we wish, usually inside a loop with a timer attached. Let's have a look at this now. So this is the turtle graphics program template from the last chapter and we're going to modify it to show you this principle. So, where we're creating our screen here on line 12, we're going to add another line and it's going to be screen, dot tracer and I'm going to put zero. You can also put false they're equivalent. And what this does is it…

Contents