Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRanvir Sahota
9,844 PointsWhy test Health <= 0;
If the health of an invader is less than 0 would that mean something is wrong with the code? Should we not throw an error and try to fix it? Would it be classed a bug or glitch?
1 Answer
andren
28,558 PointsNo, the health getting below 0 would not really be a bug. If the invader had 1 HP and received 3 points of damage for example then it would end up with -2 health. That's normal and is something that happens in real games all the time. Some games even have overkill bonuses you receive if the enemy ends up with a certain amount of negative health.
As long as you have code that checks the health and marks the Invader as dead when the health is 0 or below (like is done in the video) you won't run into any real problems.
Ranvir Sahota
9,844 PointsRanvir Sahota
9,844 PointsJust realized how wrong I was and hearthstone has something like overkill. Thankyou