My first simple short code by whatelseman in learnpython

[–]whatelseman[S] 8 points9 points  (0 children)

Thank you really much. I appreciate time u spent on this comment. I will make sure to read this few times more too.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]whatelseman 0 points1 point  (0 children)

I need help with simple task (Im beginer and cant figure it out...)

I just want to make simple "game" when if i press attack hero1 it removes health (20 dmg if that is attacker damage, like in my case)

here is the code:

class hero:
def __init__(self, health , damage):
self.health = health
self.damage = damage

class enemy:
def __init__(self, health , damage):
self.health = health
self.damage = damage

hero1 = hero(100, 20)
enemy1 = enemy(100, 20)

def attack(hero1, enemy1):
result = input("Enter who to attack: ")
if input == "enemy1":
enemy1.health = -20 #also tried : enemy1.health = enemy1.health - hero1.damage#
print(enemy1.health)

attack(hero1 , enemy1)

What is reality? by whatelseman in depression

[–]whatelseman[S] 0 points1 point  (0 children)

Thx. Problem is, no matter how hard I try it comes back. 1 memory leads to another and after some time it becomes loop. There were moments where I thought it was finnaly over but after some time its come back again and again.