I'm learning about Inheritance and Polymorphism right now, and I am using TheNewBoston's tutorial as a basis for what I am doing. I didn't really do much, but I wanted to add a Health Function. Once an enemy attacks, I want the health to be reduced. This is working except for the second enemy. I am returned a health of "50," instead of what it should be (i.e. "25").
I'm looking forward to expanding on this once I'm done figuring out Health.
each object has its own data member health, so each attack is decreasing its own objects health. Is the health suppose to be the "players" health indicated by "attack", because its defined as the enemies health, which makes sense, each enemy will have a health too.
Yeah I see that you're right here...Would it be best to create a "Player" class, then, and give them a health? I just need to make sure their health updates every time an attack takes place. I guess that's what I'm trying to figure out right now.
As players and monsters share lots of data types and capabilities, such as spawning, moving, attacking, taking damage, dying, health, position, etc., a person class from which a player class and a monster class can inherit might be a decent base class.