Classes
Sepynode supports simple classes with constructors and member functions.
class Player{
var health;
var name;
operator INIT(var number=1000, var string="hey"){
health = number;
name = string;
println << "A new player spawned with the name " + name c< 4;
}
func hit(var damage){
health -= damage;
}
}
var gamer = Player(200, "SpottedZulu");
gamer.hit(20);
println << gamer.health c<6;
Notes
-
Classes are declared using the
classkeyword, followed by the name. -
Class members are defined using the
varkeyword -
operator INIT()is the constructor method of the class, you can give it arguments and default values. -
You can access variables of the class like this:
class_name.value. -
You can call methods of the class like this:
class_name.method().