This game allows you to make the computer draw either a fish, a cat, a dog, or a horse! All you have to do is click one of the options and it will draw it for you!

In order to use this code, copy the code below and paste it into your python file. After that, run the code and enjoy!

Copy this code for FREE!:

import tkinter as tk
from turtle import RawTurtle, TurtleScreen, ScrolledCanvas


window = tk.Tk()
window.title("Animal Drawing Game")


canvas = ScrolledCanvas(window)
canvas.grid(row=0, column=0, columnspan=2, sticky="nsew")
screen = TurtleScreen(canvas)
turtle = RawTurtle(screen)
turtle.speed(3)


def draw_cat():
turtle.clear()
screen.bgcolor("white")
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.color("black")
turtle.write(" /\\_/\\ \n( o.o )\n >^_^<", font=("Arial", 12))

def draw_dog():
turtle.clear()
screen.bgcolor("white")
turtle.penup()
turtle.goto(0, -50)
turtle.pendown()
turtle.color("black")
turtle.write(" / \\\n |oo|_ \n | | |", font=("Arial", 12))

def draw_fish():
turtle.clear()
screen.bgcolor("white")
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.color("black")
turtle.write("><((('> \n", font=("Arial", 12))

def draw_horse():
turtle.clear()
screen.bgcolor("white")
turtle.penup()
turtle.goto(-50, -50)
turtle.pendown()
turtle.color("black")
turtle.write(" /\\ \n (0 0)\n / \_", font=("Arial", 12))


def handle_choice(animal):
if animal == "Cat":
draw_cat()
elif animal == "Dog":
draw_dog()
elif animal == "Fish":
draw_fish()
elif animal == "Horse":
draw_horse()


go_again_button.grid(row=1, column=0, columnspan=2)


def reset_game():
turtle.clear()
screen.bgcolor("white")
go_again_button.grid_forget()


animal_buttons = []
animals = ["Cat", "Fish", "Dog", "Horse"]

for i in range(2):
for j in range(2):
animal = animals[i * 2 + j]
button = tk.Button(window, text=animal, width=10, height=2, command=lambda animal=animal: handle_choice(animal))
button.grid(row=i+2, column=j, padx=10, pady=10)
animal_buttons.append(button)


go_again_button = tk.Button(window, text="Go Again?", width=15, height=2, command=reset_game)


go_again_button.grid(row=1, column=0, columnspan=2)
go_again_button.grid_forget()


window.grid_rowconfigure(0, weight=1)
window.grid_rowconfigure(1, weight=0)
window.grid_columnconfigure(0, weight=1)
window.grid_columnconfigure(1, weight=1)


window.mainloop()

Leave a Reply

Your email address will not be published. Required fields are marked *