summary history branches tags files
commit:bebfd5a68e5c4c87914eb9592fd59c1f1529cfd3
author:mrmekon
committer:mrmekon
date:Tue Mar 27 13:16:17 2012 -0400
parents:08dc0310b873a73e32214bc976e6e4897ec18a77
Last commit was a lie.  Fixed animation method to be correct again, and replaced setInterval with setTimer since it's less accurate, but can be called once per frame like the other callbacks.
diff --git a/tempest/tempest.cljs b/tempest/tempest.cljs
line changes: +10/-9
index 3f41e88..339c1d2
--- a/tempest/tempest.cljs
+++ b/tempest/tempest.cljs
@@ -850,15 +850,15 @@
 
 (defn animationFrameMethod []
   (let [window (dom/getWindow)
-        options (list (.-requestAnimationFrame window)
-                      (.-webkitRequestAnimationFrame window)
-                      (.-mozRequestAnimationFrame window)
-                      (.-oRequestAnimationFrame window)
-                      (.-msRequestAnimationFrame window))]
+        options (list #(.-requestAnimationFrame window)
+                      #(.-webkitRequestAnimationFrame window)
+                      #(.-mozRequestAnimationFrame window)
+                      #(.-oRequestAnimationFrame window)
+                      #(.-msRequestAnimationFrame window))]
     ((fn [[current & remaining]]
        (cond
-        (nil? current) #((.-setInterval window) % (/ 1000 60))
-        (fn? current) current
+        (nil? current) #((.-setTimeout window) % (/ 1000 30))
+        (fn? (current)) (current)
         :else (recur remaining)))
      options)))
 
@@ -880,6 +880,8 @@
         handler (goog.events.KeyHandler. document)
         dims {:width (.-width canvas) :height (.-height canvas)}]
 
+    (.log js/console (str "Animation function: " (pr-str *animMethod*)))
+    
     (draw-board bgcontext dims level)
     
     (def *frame-count* (atom 0))
@@ -926,7 +928,6 @@
     
     (*animMethod* #(draw-world context dims level))
 
-    (events/listen handler "key" (fn [e] (keypress e)))
-    (. timer (start))))
+    (events/listen handler "key" (fn [e] (keypress e)))))