Thread: Classes...
View Single Post
  #7  
Old 12-22-2003, 11:32 PM
Termina_Owner Termina_Owner is offline
Registered User
Join Date: Oct 2003
Posts: 175
Termina_Owner is on a distinguished road
The binary ones should have been added to Graal a long time ago, but then again, I don't think much people think in binary anymore... It's a simple reproduction of what it would be in Graal's programming language. Erm...

Ahh... Another trick, that's pretty simple that I see little people use:

NPC Code:

if (weaponfired){
if (this.on == 0){
this.on = 1;
timeout = 0.05;
}
if (this.on == 1) this.on = 0;
}



Whereas that could just be used as:
NPC Code:

if (weaponfired){
this.on = (this.on + 1)%2;
timeout = 0.05;
}


or
NPC Code:

if (weaponfired){
this.on = this.on == 0 ? 1 : 0;
timeout = 0.05;
}


or
NPC Code:

if (weaponfired){
this.on = abs(this.on - 1);
timeout = 0.05;
}



There is many ways of doing it... I personally rather the:
NPC Code:

this.on = (this.on + 1)%2;



Think of any other way that goes in one line?

- Rance Vicious
Reply With Quote