By John 12
John 12
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")
wn.register_shape("cake2.gif")
cake2 = turtle.Turtle()
cake2.shape("cake2.gif")
cake2.speed(0)
clicks = 0
pen = turtle.Turtle()
pen.hideturtle()
pen.color("black")
pen.penup()
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.clear()
pen.write(f"Clicks: {clicks}", align="center", font=("Courier New", 32, "normal"))
cake2.onclick(clicked)
wn.mainloop()
…
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).
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!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.