Re: absolute and this

absolute is a function.
It returns the absolute value of a number.

int x=absolute(-10);
if(x==10) alert("Absolute", "Absolute worked correctly!");

"this" is a keyword which refers to the instance of a class which invokes its methods.
It is not a requirement to use "this" in bgt, but it can help distinguish class properties from method parameters.

class my_class {
int x=0;
int y=0;
int hp=100;
my_class@ target=null;

my_class(int x, int y) {
this.x=x;
this.y=y;
}

bool is_threat(my_class@ other) {
return [ a-t ](other.target)==@this;
}

void set_target(my_class@ new_target) {
@target=new_target; // It is not necessary to use 'this' here,
// If you wanted to use 'this' to do the same thing, it would look like:
// [ a-t ](this.target)=new_target;
}

bool is_ready() {
return @target!=null;
}
}

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector

Reply via email to