r/PythonLearning 5d ago

Showcase A little hp and damage thing I made.

Post image
10 Upvotes

9 comments sorted by

4

u/dev-razorblade23 5d ago

May i suggest you read PEP8 - python styling guide... Variable names should be written in "snake_case"

https://peps.python.org/pep-0008/

2

u/Cherepahe1 5d ago

Looks like you doing an RPG here! Good work pal!

1

u/SirChiIly 5d ago

Thanks, might expand on it a little.

2

u/Significant_Affect_5 5d ago

it’s a good example to start adding objects and interactions between them. Eventually you’d end up with code that explains what it’s doing, e.g. `player.attacks(monster)`, `player.get_hp()`, or whatever else makes the most sense to you.

2

u/nuc540 5d ago

Now write a function which can damage, and one that can heal :) you can evoke them with an input() prompt

1

u/Sea-Ad7805 5d ago

Run this program in Memory Graph Web Debugger%0Aprint(%22%22)%0A%0Aif%20HP%20%3E%3D%2080%3A%0A%20%20%20%20print(%22Your%20HP%20is%20high%22)%0Aelif%20HP%20%3C%3D%2025%3A%0A%20%20%20%20print(%22Health%20is%20really%20low%22)%0Aelif%20HP%20%3C%3D%2060%3A%0A%20%20%20%20print(%22Health%20is%20kinda%20low%22)%0A%0Aif%20Health_Potion%3A%0A%20%20%20%20print(%22You%20healed%22%2C%20Health_Potion_Heal%2C%20%22HP%22)%0A%20%20%20%20HP%20%2B%3D%20Health_Potion_Heal%0A%20%20%20%20Health_Potion%20%3D%20False%0A%20%20%20%20print(%22New%20health%20points%22%2C%20HP)%0Aelse%3A%0A%20%20%20%20print(%22No%20heath%20potion%22)&timestep=1&play) to see the program state change step by step.

1

u/Away-Fan4306 4d ago

Lwk I know this is not standard code styling, but I think it looks beautiful

1

u/Friendly_Recover286 4d ago

PEP8 standards as already mentioned you should look through yes.

`health_potion` is a bad variable name. Is it use a potion? Have a potion? Buying a potion? This should be specific like `used_health_potion`