예제 #1
0
파일: Layout.php 프로젝트: arghwoo/matrix
 public function __construct()
 {
     // 讓 STDIN 只讀取一個字元就輸出
     system("stty -icanon time 1");
     // STDIN 沒東西就略過
     stream_set_blocking(STDIN, 0);
     self::$sleep = self::$sleep_standard;
 }
예제 #2
0
 private function captureKeyStroke()
 {
     $c = fread(STDIN, 1);
     if (in_array($c, ['='])) {
         $this->increaseSleep();
     } elseif (in_array($c, ['-'])) {
         $this->decreaseSleep();
     } elseif (in_array($c, ['q'])) {
         exit;
     } elseif (in_array($c, ['1'])) {
         $this->increaseNewRowProperty();
     } elseif (in_array($c, ['2'])) {
         $this->decreaseNewRowProperty();
     } elseif (in_array($c, ['z'])) {
         $this->increaseEmptyRowProperty();
     } elseif (in_array($c, ['x'])) {
         $this->decreaseEmptyRowProperty();
     } elseif (in_array($c, ['a'])) {
         $this->increaseMinRainLength();
     } elseif (in_array($c, ['s'])) {
         $this->decreaseMinRainLength();
     } elseif (in_array($c, ['c'])) {
         self::$color_style = (self::$color_style + 1) % count(Pixel::$color_256);
     }
 }