Permalink
Browse files

Square moves and yields to the UI thread

  • Loading branch information...
robashton committed Jun 13, 2012
1 parent 1886dc6 commit 708a50c22e3b6374afcb5faaa1c6176eefde6eb1
Showing with 15 additions and 5 deletions.
  1. +1 −0 \
  2. +13 −4 game.clj
  3. +1 −1 game.js
View
1 \
@@ -0,0 +1 @@
+cljsc game.clj '{:optimizations :none}' > game.js
View
@@ -1,13 +1,22 @@
(ns game)
-
-(defn drawSquare []
+(defn drawRect [x y w h]
(let [target (.getElementById js/document "target")
context (.getContext target "2d")]
- (.fillRect context 0 0 100 100)
+ (.fillRect context x y w h)
)
)
+(defn tick [x]
+ (drawRect x 0 100 100)
+ (if (<= x 1000)
+ (js/setTimeout (fn []
+ (tick (inc x))
+ ) 33 )
+ )
+)
+
+
(defn ^:export init []
- (drawSquare)
+ (tick 0)
)
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 708a50c

Please sign in to comment.