Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added js version 370 bytes

  • Loading branch information...
commit 91a73e15216916bdf8fe948844579759ab1f30c8 1 parent cf3b687
Nik Coughlin authored February 15, 2011
1  js/SimpleRLGolf.html
... ...
@@ -0,0 +1 @@
  1
+<pre><script>p=(d=document).body.children[0];m='#### #  ###    ##    #   ';x=2;y=3;function t(e){u=x;v=y;k=e?e.keyCode-36:0;k%2<1?v+=k<3?-1:1:u+=k<2?-1:1;if(m[w(v)*5+w(u)]==' '){x=u;y=v}p.innerHTML='';for(j=0;j<10;j++)for(i=0;i<10;i++)p.innerHTML+=i==x&&j==y?'@':m[w(j)*5+w(i)]+(i>8?'\n':'')}function w(i){return i<5?i:5-i+4}d.addEventListener('keyup',t,0);t(3)</script>
25  js/SimpleRLGolfPretty.html
... ...
@@ -0,0 +1,25 @@
  1
+<pre>
  2
+<script>
  3
+  p=(d=document).body.children[0];
  4
+  m='#### #  ###    ##    #   ';
  5
+  x=2;y=3;  
  6
+  function t(e){
  7
+    u=x;
  8
+    v=y;
  9
+    k=e?e.keyCode-36:0;    
  10
+    k%2<1?v+=k<3?-1:1:u+=k<2?-1:1;
  11
+    if(m[w(v)*5+w(u)]==' '){
  12
+      x=u;
  13
+      y=v
  14
+    }    
  15
+    p.innerHTML='';
  16
+    for(j=0;j<10;j++)
  17
+      for(i=0;i<10;i++)
  18
+        p.innerHTML+=i==x&&j==y?'@':m[w(j)*5+w(i)]+(i>8?'\n':'')
  19
+  }  
  20
+  function w(i){
  21
+    return i<5?i:5-i+4
  22
+  }  
  23
+  d.addEventListener('keyup',t,0);
  24
+  t()
  25
+</script>

0 notes on commit 91a73e1

Please sign in to comment.
Something went wrong with that request. Please try again.