Hey guys! First: I am learning python by doing the course on codeacademy right now. Parallel to this I started learning different things from a book.
And here is where I need your help: I started a project to made a game called “shoot the fruit” with pygame zero. In this game hte player shoot an apple with the mouse. Everytime I hit the apple I want to print out the actual score to the terminal.
This seems so simple but I don’t get how I make this happen.
Here is the code:
from random import randint
apple = Actor("apple")
def draw():
screen.clear()
apple.draw()
def place_apple():
apple.x = randint(10, 800)
apple.y = randint(10, 600)
def on_mouse_down(pos):
score = 0
if apple.collidepoint(pos):
score = score + 1
print("Treffer")
print(score)
place_apple()
else:
print("Daneben!")
quit()
place_apple()
Everytime I hit the apple the terminal print my points with 1. Always. Can you help me please?
Thank you!