To start, press space. Your opponent (the red/blackish ball) can be on two different modes. If your opponents center is red, then it will not deal damage, when you get touched. If your opponents center is black, then if you get hit, then you will be harmed. For you to attack, you press a. You must be touching the opponent to hurt it.Your health and the opponents health is random. The power of you and your opponent is also random. If you have better stats (health, and power), then the variable, upper hand will be on player. If not, it will be on artificial. (The programmed enemy.) If the upper hand is on you, the artificial enemy will run away. But if you are in a 180 coordinant range, and it is on attack mode and if key a is not pressed, then he will attack. If the upper hand is on artificial, then he will attack and go after you until the upper hand variable changes. If you get hit, then your sprite will say what health you are at. If you get hit, you are invincible for half a second.
My idea, and all my own code. I hope you enjoy this. If you see any bugs, then type them in the comments. Also, if you get confused if you see the upper hand variables variable and the upper hand variables 2 variable, those are for the upper hand variable, and are very useful. Check out my other projects!