Lolife now has enemies that can attack the player, healing, experience and levelling.

While the stats being tracked are relatively simple, balancing is anything but! I want each level to feel like a significant power up, so rather than increasing the player's health and damage linearly (which would feel increasingly less meaningful) I decided to go with a percentage increase. At the moment that's settled on +30% damage and +10% health - the lower health increase keeps enemies threatening even as your ability to kill them steps up.
I ended up making a spreadsheet to lay out stats by level for the player and different enemies so that I could see how the numbers change and find a good curve. While I just have health and damage as the base stats, from those I derive hits-to-kill and hits-to-die (at each level, how many hits the player will kill an enemy in, and how many hits from an enemy the player will die in). The ratio of those multiplied by some constant is used to derive the experience the player will gain on killing an enemy, the result being that more dangerous enemies yield more experience. I also have it so that once you can kill an enemy in a single hit, they no longer yield any experience. That prevents someone from grinding against the same weak enemies indefinitely, but there's still a use to those enemies thanks to how healing works.
The player heals whenever they kill an enemy by an amount related to the enemy's damage. In similar games like Hydlide and Ys the player can heal by standing still, but I didn't want something so inactive. By tying healing to killing it encourages more aggression and adds some potential strategy when fighting stronger enemies where weaker enemies are also present and can be used to heal mid-combat. It's similar to God of War or Metal Gear Rising!
I need to do some general performance optimising, but with these core mechanics in place I can now start to think about making content rather than mechanics, which I'm excited about as I generally prefer creating game content!