I'm currently creating a text based adventure game using python.
One of the features in the game is that when you enter a room an enemy attacks you and takes off some of your health.
I have an If loop to control if there is an item that you need present, and to print out a statement and take some damage off your health. The statement is printed out, but the health doesn't change.
Anyone any ideas?

I've attached the file as a .txt so you just need to save it as .py
Maybe you all knew this anyway :p

You really want to make your character a class object. That's what object-oriented coding is all about.

Then, you can simply subtract the damage from self.health and all will work fine.

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.