Commits

Cat's Eye Technologies  committed 8c3980d

Add option/checkbox to repeat running the program indefinitely.

  • Participants
  • Parent commits f4c42ef

Comments (0)

Files changed (2)

File impl/etcha.js/demo/etcha.html

 <button id="stop">Stop</button>
 <button id="step">Step</button>
 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
+<label for="repeat_indefinitely">
+  <input type="checkbox" name="repeat_indefinitely" id="repeat_indefinitely"
+         onchange="c.setRepeatIndefinitely(this.checked);">
+  repeat indefinitely
+</label>
 
 <div>
   example source:

File impl/etcha.js/src/etcha.js

         pc.reset();
         this.progView.setCursors([pc]);
 
+        this.repeatIndefinitely = false;
+
         this.load("");
     };
 
     };
 
     this.step = function() {
-        if (halted) return;
+        if (halted) {
+            if (this.repeatIndefinitely) {
+                pc.reset();
+                halted = false;
+            } else {
+                return;
+            }
+        }
         var instruction = program.charAt(pc.x);
         switch (instruction) {
             case '+':
         halted = false;
         this.draw();
     };
+
+    this.setRepeatIndefinitely = function(value) {
+        this.repeatIndefinitely = value;
+    };
 };
 EtchaController.prototype = new yoob.Controller();