Search⌘ K

Object-Oriented

Explore object-oriented programming concepts in JavaScript by adding fight mechanics to an RPG. Understand how classes and methods like attack() manage character interactions, health, and experience points. This lesson helps you grasp the basics of object-oriented design by applying it to a practical game scenario.

We'll cover the following...

Now back to our RPG, which is still pretty boring. What does it lack? Monsters and fights, of course!

Following is how a fight will be handled. If attacked, a character sees their life points decrease from the strength of the attacker. If its health value falls below zero, the character is considered dead and cannot attack anymore. Its ...