Commits

catseye  committed 1fe41fa

Improve HTML slightly, allow playfield to be cleared.

  • Participants
  • Parent commits 98e858a

Comments (0)

Files changed (3)

File html/gemooy.html

 </head>
 <body>
 
-<h1>Gemooy</h1>
+<h1>Gemooy
+<button id="load">Load</button>
+<button id="start">Start</button>
+<button id="stop">Stop</button>
+</h1>
 
 <canvas id="canvas" width="400" height="400">
 Your browser doesn't support displaying an HTML5 canvas.
 </canvas>
 
 <span>
-<textarea id="program" rows="10" cols="40">
+<textarea id="program" rows="25" cols="40">
 %   @@   @@
 #  @  $    @
        @
 @   @   @
 </textarea>
 
-<button id="load">Load</button>
-<button id="start">Start</button>
-<button id="stop">Stop</button>
-
 </body>

File src/gemooy.js

 
     self.load = function(textarea) {
         self.stop();
+        p.clear();
         p.load(0, 0, textarea.val());
         p.foreach(function (x, y, value) {
             if (value === '$') {

File src/playfield.js

         store[x+','+y] = value;
     }
 
+    self.clear = function() {
+        store = {};
+        self.min_x = undefined;
+        self.min_y = undefined;
+        self.max_x = undefined;
+        self.max_y = undefined;
+    };
+          
     /*
      * Load a string into the playfield.
      * The string may be multiline, with newline (ASCII 10)