Skip to content

Instantly share code, notes, and snippets.

@markknol
Created May 25, 2018 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markknol/807c0512457bda0d01f6d64fce1bd57f to your computer and use it in GitHub Desktop.
Save markknol/807c0512457bda0d01f6d64fce1bd57f to your computer and use it in GitHub Desktop.
Life = life
package com.mediamonks.game.state;
import flambe.Component;
import flambe.util.Value;
/**
* Life.
*
* To follow the clues and walk out the exit.
* To know and master the world.
* To be moved by the tears and pain of others, and try to help them out of love and compassion.
* To face our fears and accept the lessons life offers us.
*
* @author Mark Knol
*/
class Life extends Component {
// every life, on a path to find its value
public var value(default, null):Value<Float>;
// are you alive?
public var alive(default, null):Value<Bool> = new Value(true);
public function new() {
// the invigorated self, through being one, taking its first steps
value = new Value<Float>(1.0, onLifeChange);
}
private function onLifeChange(to:Float, from:Float) {
// on life change, do not panic!
alive._ = to > 0.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment