Added four new body sockets tonight, which increases the player’s health. Actually, I just had to write the health socket code once and just change the variable that controls the health bonus magnitude. The player can choose from Health +1, Health + 2, Health + 3, and Health + 4. I modified the method in the player class that returns the player’s maximum health to account for these sockets if they are active. Currently, the player can only socket one ability to the body. I think it’s more important to get it working for one, and then later I can modify the sockets for each body part to a dynamically sized list. I still haven’t decided if socket slots will be statically bound to each piece of equipment, or if additional slots can be purchased from an in-game store.
The player’s base health is currently set to 200. Each +1 health socket adds 40 additional health. I will need to decide if the Health sockets will stack when multiple body sockets are available. For instance, equipping a Health +1 and Health +2 socket would result in 120 additional health. I will also need to handle the case where the player unequips a health socket, which would result in the player possibly having more health than the maximum.
I also modified the health meter display while I was working with the health code. Now there are segmented bars for each 20 health. Green bars are health remaining and gray bars are health lost. I added a variable to the enemy class that indicates how much damage the enemy inflicts, which I now have set to 5. Previously, I just subtracted a static 20 value from the player’s health when they collide with an enemy. This way, when an enemy is subclassed, specific damage values can be assigned for the enemy subclass. The reason I chose 5 for default was because it lets me see the fraction of a health bar left over when the player is hit. This will need to be rebalanced later, because 40 hits (200/5) seems to be too generous. Filling the full health bars is easily completed in a loop, but determining how much to fill the last bar which may only be a portion of a bar requires some additional calculations. Basically, the value of modulo current health of health unit size (20) is used to determine how much of the last bar should be displayed.