Let me preface by saying that I am very very new to programming in general. I've been doing it for about a week and have successfully made things like calculators and all that beginner jazz and have been working on my first real "project", which is a text-based adventure game. My problem right now is that I cannot put together a very simple health system for the life of me and would like to get any pointers any of you might have.
I've rewritten the code for it many times but here is the basic framework of what I've been working with:
def healthSystem(enemy_atk = 0): # Called at the beginning of every game screen.
watermark() # A function that prints the game title and other things at the top of every screen
max_health = 10 # Player max health
no_health = 0 # Player dies at this threshold
modifier = enemy_atk # An enemy attack roll is taken from another function and stored here
current_health = max_health - modifier # Calculating the new health
print("+" * current_health) # Prints the new health to the screen, every 1 health is represented with a "+"
print()
It's very barebones and it works on the first game screen. However, when you progress to the next game screen, everything is recalculated and the health is redrawn to the screen every time, so you get a different amount of health every screen.
Would this call for a class? I have yet to use classes and have seen some examples using them, but I was hoping I could stick to functions for this first project. Thanks for any help everyone.