I am trying to make a clicker game and add an achievement where when you go past a certain number it gives the achievement, but after you go past it gives the achievement every click. Is there a way i can fix this?
def clicks():
global x
global y
x = x y
print(x,"clicks")
#1000 cookies
if x >= 1000:
print('Achievement Unlocked: Clicker Beginner! (Achievement 1/7)')
CodePudding user response:
You can add boolean
flag like achievementGranted
and set it as true
when you add achievement.
Also maybe more useful and secure to use if x == 1000
? Because this statement will be executed once when x == 1000, not every time when x >= 1000
CodePudding user response:
def clicks():
global x
global y
x = x y
print(x,"clicks")
#1000 cookies
if x == 1000:
print('Achievement Unlocked: Clicker Beginner! (Achievement 1/7)')
You also need to indent the things after def as I've done above
CodePudding user response:
Your condition say: if x>= so that mean even when c become 1001 it will work
Should be only == and you can store the value to use it in another place