Created
May 25, 2018 09:15
-
-
Save markknol/807c0512457bda0d01f6d64fce1bd57f to your computer and use it in GitHub Desktop.
Life = life
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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