Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RPG game trouble
#5
I also have the enemy class which inherits from the Character class as well, so wanted to differentiate between the two.
 
In this case, as both the Enemy and Hero class will have different health attributes, and the hero's name will be fetched from the player_name variable, would it be best to keep the super() to override the parent?
 
If I stick with it, I'm still getting the player_name variable not being defined within:
super(Hero, self).__init__(name=player_name, health=3)

Any idea why?
 
I thought maybe it's related to the order of the code (classes using player_name coming before it is defined within intro()), so split up the classes into another file and imported it into the main game script.
 
But, I then get an error that the name Hero is not defined. I added the following lines right at the end of the originally attached script just to get things started...



player = Hero()
villain = Enemy()
intro()
Really appreciate your continued help with this. Thanks.
Reply


Messages In This Thread
RPG game trouble - by J125 - Apr-08-2017, 05:38 PM
RE: RPG game trouble - by ichabod801 - Apr-08-2017, 06:04 PM
RE: RPG game trouble - by J125 - Apr-17-2017, 11:43 AM
RE: RPG game trouble - by ichabod801 - Apr-18-2017, 01:20 AM
RE: RPG game trouble - by J125 - Apr-20-2017, 10:25 AM
RE: RPG game trouble - by Kebap - Apr-20-2017, 05:21 PM
RE: RPG game trouble - by J125 - Apr-24-2017, 11:38 AM
RE: RPG game trouble - by nilamo - Apr-29-2017, 04:42 PM
RE: RPG game trouble - by J125 - May-03-2017, 08:34 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020