How to get objects fly out of another object in pygame.

I’m not sure how to get objects to fly out another object every time it is pressed. It’s just like Cookie Clicker. This is Pygame code(turtle). This is all my code so far:

import turtle

wn = turtle.Screen()
wn.title("Cake Clicker by @.......")
wn.bgpic("backg for app.gif")


cake2 = turtle.Turtle()

clicks = 0

pen = turtle.Turtle()
pen.goto(0, 400)
pen.write(f"Clicks: {clicks}", align="center", font=("Courier New", 32, "normal"))

def clicked(x, y):
    global clicks
    clicks += 1
    pen.write(f"Clicks: {clicks}", align="center", font=("Courier New", 32, "normal"))



If you could respond to me with some help or the correct code, that would be great. All I need is to have a small cake picture jump out of the larger cake in the center when it is clicked (pressed).

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Is there a specific tutorial that you are following? I could take a look at it and check out the prerequisites, it is possible that something is missing.

I tried running the code that you’ve provided and it is not returning any errors.

Best, Bobby