In your specific case, when you call combatant.move()
, you are calling move on the class, not on the instance of the class. The proper way to use that method is to first create an instance.
Typically, people name their class with an uppercase letter, and their instances with a lowercase, to make problems like this easy to spot.
For example:
class Combattant(...):
...
combattant = Combattant(...)
combattant.move(tkey)
The reason self
is required, is so that the methods know which instance they are applied to. This makes it possible to have more than once instance of the class. When you call some_instance.some_method(...)
, python will automatically add the self
parameter when calling the method.