The Wayback Machine - https://web.archive.org/web/20240930185544/https://www.geeksforgeeks.org/draw-moving-object-using-turtle-in-python/
Open In App

Draw moving object using Turtle in Python

Last Updated : 12 Sep, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite: Python Turtle Basics

Turtle is an inbuilt module in python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle. To move turtle, there are some functions i.e forward(), backward(), etc.

1.)Move the Object (ball)  :

Following steps are used:

  • Import Turtle package.
  • Set screen with dimensions and color.
  • Form turtle object with color.
  • Form the object (ball – made of colored circle).
  • Call the function for making object again and again and clear the screen.

Below is the implementation  :

Python3




# import turtle package
import turtle
  
  
# function for movement of an object 
def moving_object(move):
      
    # to fill the color in ball
    move.fillcolor('orange') 
      
    # start color filling
    move.begin_fill() 
      
    # draw circle
    move.circle(20)  
      
    # end color filling
    move.end_fill()             
  
# Driver Code
if __name__ == "__main__" :
      
    # create a screen object
    screen = turtle.Screen() 
  
    # set screen size
    screen.setup(600,600)    
  
    # screen background color
    screen.bgcolor('green')   
  
    # screen updaion 
    screen.tracer(0)           
  
    # create a turtle object object
    move = turtle.Turtle() 
  
    # set a turtle object color
    move.color('orange')
  
    # set turtle object speed
    move.speed(0) 
  
    # set turtle object width
    move.width(2)     
  
    # hide turtle object
    move.hideturtle()          
  
    # turtle object in air
    move.penup()               
  
    # set initial position
    move.goto(-250, 0) 
  
    # move turtle object to surface
    move.pendown()             
  
    # infinite loop
    while True :
          
        # clear turtle work
        move.clear()  
          
        # call function to draw ball
        moving_object(move)   
          
        # update screen
        screen.update()    
          
        # forward motion by turtle object
        move.forward(0.5)      


Output :

Example 2:  Move the Object (box)

Following steps are used:

  • Import Turtle package.
  • Set screen with dimensions and color.
  • Form turtle object with color.
  • Form the object (box – made of colored square).
  • Call the function for making object again and again and clear the screen.

Below is the implementation:-

Python3




import turtle
  
screen = turtle.Screen()
screen.setup(500,500)
screen.bgcolor('Green')
  
# tell screen to not 
# show automatically
screen.tracer(0)            
  
t = turtle.Turtle()
t.speed(0)
t.width(3)
  
# hide donatello, we
# only want to see the drawing
t.hideturtle()            
  
def draw_square() :
    t.fillcolor("Orange")
    t.begin_fill()
    for side in range(4) :
        t.forward(100)
        t.left(90)
    t.end_fill()
t.penup()
t.goto(-350, 0)
t.pendown()
  
while True :
    t.clear()
    draw_square()
      
    # only now show the screen,
    # as one of the frames
    screen.update()         
    t.forward(0.02)
      
# This code is contributed by pulkitagarwal03pulkit


Output:



Previous Article
Next Article

Similar Reads

Turtle Race Game Using Python - Turtle Graphics Library
Turtle graphics is a popular way to introduce programming concepts to beginners. It's a fun and interactive module in Python that lets you create simple drawings and animations using a "turtle" that moves around the screen. In this tutorial, we'll create an exciting turtle race game where you can bet on the color of a turtle and watch as they race
4 min read
turtle.forward() method in Python-Turtle
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support. turtle.forward() The turtle.forward() method is used to move the turtle forward by the value of the argument that it takes. It gives
1 min read
turtle.setpos() and turtle.goto() functions in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support. turtle.setpos() This method is used to move the turtle to an absolute position. This method has Aliases: setpos, setposition, goto. S
1 min read
Draw Circle in Python using Turtle
Turtle is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like turtle.forward(…) and turtle.right(…) which can move the turtle around. Turtle is a beginner-friendly way to learn Python by running some basic commands and viewing the turtle do it graphically. It is like a drawing board t
3 min read
Draw a Hut using turtle module in Python
Turtle is a inbuilt module in Python, which has many functions like forward(), backward(), right() and left() etc. You can draw a hut on the screen just by using the turtle module in Python. In this article, we will create a hut using the turtle module. Approach: Import turtleSet the background color.Define a function to draw the front portion of t
2 min read
Draw a Tic Tac Toe Board using Python-Turtle
The Task Here is to Make a Tic Tac Toe board layout using Turtle Graphics in Python. For that lets first know what is Turtle Graphics. Turtle graphics In computer graphics, turtle graphics are vector graphics using a relative cursor upon a Cartesian plane. Turtle is drawing board like feature which let us to command a turtle and draw using it. Feat
2 min read
Draw Cube and Cuboid in Python using Turtle
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move the turtle, there are some functions i.e forward(), backward(), etc. Drawing Cube Following steps are used: First draw the front sq
2 min read
Draw Shape inside Shape in Python Using Turtle
Prerequisites: Turtle Programming in Python Turtle is a Python feature like a drawing board, which let us command a turtle to draw all over it! We can use many turtle functions which can move the turtle around. Turtle comes in the turtle library. The turtle module can be used in both object-oriented and procedure-oriented ways. Some of the commonly
3 min read
Draw Colored Solid Cube using Turtle in Python
Turtle is an inbuilt module in Python. It provides: Drawing using a screen (cardboard).Turtle (pen). To draw something on the screen, we need to move this turtle (pen) and to move the turtle(pen), there are some functions like the forward(), backward(), etc. Prerequisite: Turtle Programming Basics Drawing Colored Solid Cube In this section, we will
2 min read
Draw smiling face emoji using Turtle in Python
Prerequisite: Python Turtle Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle. To move turtle, there are some functions i.e forward(), backward(), etc. In this article, we will see how to draw a smiling face emoji using the Turtl
2 min read
Draw Clock Design using Turtle in Python
Prerequisites: Turtle Programming in Python Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. To draw Clock Design : Following steps are used : Import turtl
2 min read
Draw Concentric Circles with VIBGYOR Using Turtle in Python
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. To draw Concentric VIBGYOR : Following steps are used : Importing
2 min read
Draw Panda Using Turtle Graphics in Python
Turtle is an inbuilt module in Python. It provides: Drawing using a screen (cardboard).Turtle (pen). To draw something on the screen, we need to move the turtle (pen), and to move the turtle, there are some functions like the forward(), backward(), etc. Prerequisite: Turtle Programming Basics Draw Panda Using Turtle Graphics In this section, we wil
2 min read
Draw Heart Using Turtle Graphics in Python
Turtle is an inbuilt module in Python. It provides: Drawing using a screen (cardboard).Turtle (pen). To draw something on the screen, we need to move the turtle (pen) and to move the turtle, there are some functions like the forward(), backward(), etc Prerequisite: Turtle Programming Basics Draw Heart Using Turtle Graphics In this section, we will
2 min read
Draw Rainbow using Turtle Graphics in Python
Turtle is an inbuilt module in Python. It provides: Drawing using a screen (cardboard).Turtle (pen). To draw something on the screen, we need to move the turtle (pen), and to move the turtle, there are some functions like the forward(), backward(), etc. Prerequisite: Turtle Programming Basics Draw Rainbow Using Turtle Graphics In this section, we w
2 min read
Draw Ellipse Using Turtle in Python
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. Approach: The following steps are used : Import turtleDivide the e
2 min read
Draw Graph Grid Using Turtle in Python
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. Approach: Following steps are used : Import turtleSet screenMake t
2 min read
Draw Dot Patterns Using Turtle in Python
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. 1) Draw Dot Square Following steps are used : Import turtleMake tu
2 min read
Draw Chess Board Using Turtle in Python
Prerequisite: Turtle Programming Basics Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc. For drawing Chess Board following steps are used : Import turtle a
2 min read
Draw Spiraling Star using Turtle in Python
Prerequisite: Python Turtle Basics Turtle is an inbuilt module of python. It enables us to draw any drawing by a turtle and methods defined in the turtle module and by using some logical loops. To draw something on the screen(cardboard) just move the turtle(pen).To move turtle(pen) there are some functions i.e forward(), backward(), etcApproach to
1 min read
Draw Spiraling Polygon using Turtle in Python
Prerequisite: Python Turtle Basic Turtle is an inbuilt module of python. It enables us to draw any drawing by a turtle, methods defined in the turtle module and by using some logical loops. To draw something on the screen(cardboard) just move the turtle(pen). To move turtle(pen) there are some functions i.e forward(), backward(), etc. Approach to d
1 min read
Draw Spiraling Square using Turtle in Python
Prerequisite: Python Turtle Basic Turtle is an inbuilt module of python. It enables us to draw any drawing by a turtle, methods defined in the turtle module and by using some logical loops. To draw something on the screen(cardboard) just move the turtle(pen). To move turtle(pen) there are some functions i.e forward(), backward(), etc. Approach to d
1 min read
Draw Spiraling Triangle using Turtle in Python
Prerequisite: Python Turtle Basic Turtle is an inbuilt module of python. It enables us to draw any drawing by a turtle, methods defined in the turtle module, and by using some logical loops. To draw something on the screen(cardboard) just move the turtle(pen). To move turtle(pen) there are some functions i.e forward(), backward(), etc. Approach to
1 min read
Draw an Olympic Symbol in Python using Turtle
Prerequisites: Turtle Programming in Python The Olympic rings are five interlaced rings, colored blue, yellow, black, green, and red on a white field. As shown in the below image. Approach:import Turtle moduleset the thickness for each ringdraw each circle with specific coordinates Below is the implementation. C/C++ Code import turtle # object tr f
1 min read
Draw a Flower using Turtle in Python
Prerequisites: Turtle Programming in Python Turtle is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like turtle.forward(…) and turtle.right(…) which can move the turtle around. Turtle is a beginner-friendly way to learn Python by running some basic commands and viewing the turtle do
3 min read
Draw a car using Turtle in Python
Prerequisite: Turtle module, Drawing Shapes There are many modules in python which depict graphical illustrations, one of them is a turtle, it is an in-built module in Python, which lets the user control a pen(turtle) to draw on the screen(drawing board). It is mostly used to illustrate figures, shapes, designs, etc. In this article, we will learn
2 min read
Draw a snowman using turtle module in Python
Prerequisite: Turtle module, Drawing Shapes There are many modules in python which depicts graphical illustrations, one of them is turtle, it is an in-built module in Python, which lets the user control a pen(turtle) to draw on screen(drawing board). It is mostly used to illustrate figures, shapes, designs etc. In this article, we will learn how to
2 min read
Draw house using Turtle programming in Python
Prerequisite: Turtle Programming in Python “Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all over it! ”turtle” comes packed with the standard Python package and need not be installed externally. Step 1: Import turtle and math module in Python. import turtle import math Step 2: Choose a background color fo
2 min read
Draw tree using Turtle module in Python
Prerequisite: Turtle module, Drawing Triangle, Drawing Rectangle There are many modules in python which depicts graphical illustrations, one of them is turtle, it is an in-built module in Python, which lets the user control a pen(turtle) to draw on screen(drawing board). It is mostly used to illustrate figures, shapes, designs etc. In this article,
2 min read
How to draw 2-layered and colored spider web in Python using Turtle Module?
Prerequisite: Python Turtle module Basics We all must have seen the spiderweb at our homes but have you ever wonder how many efforts and patience is required for building that. Let's salute the efforts of Spider and continue building one by ourselves. Spiderwebs usually comprise radical and spiral threads. What if you can make a colored 2-layered s
2 min read
Practice Tags :