I am trying to make a script that gives the player 5 lives for every 100 points. It works, however a bit too well. When I run the code, when i reach 100 points, it doesn’t stop giving lives, and only stops when I get more points.
This is the code I’m using:
def increase_lives():
global lives
global score
global extralives
if score % 100 == 0 and score != 0 or keyboard.lctrl and keyboard.ralt:
extralives = 1
if extralives == 1:
lives += 5
extralives -= 1
I am using Thonny with PyGame and PGZero. Any help is greatly appreciated.
New contributor
SunkyThaN00b253 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.