From e23843ad37ac1e76aad3696fb91bb64d918d6b9d Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Wed, 16 Oct 2013 21:48:24 +0530 Subject: [PATCH] Added comments --- src/clj/frpong/core.clj | 2 ++ src/cljs/frpong/core.cljs | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/clj/frpong/core.clj b/src/clj/frpong/core.clj index 7d3b4d2..b098607 100644 --- a/src/clj/frpong/core.clj +++ b/src/clj/frpong/core.clj @@ -1,5 +1,7 @@ (ns frpong.core) +(defmacro go [& body] `(cljs.core.async.macros/go ~@body)) + (defmacro go-loop [& body] `(cljs.core.async.macros/go (while true diff --git a/src/cljs/frpong/core.cljs b/src/cljs/frpong/core.cljs index 474cf73..5b3956e 100644 --- a/src/cljs/frpong/core.cljs +++ b/src/cljs/frpong/core.cljs @@ -2,9 +2,17 @@ (:require [frpong.signals :refer (signal keyboard ticks dom-events mult tap)] [domina :as dom :refer [log]] [domina.events :as ev]) - (:require-macros [cljs.core.async.macros :as m :refer [go]] - [frpong.core :refer (go-loop rd wt)])) -;; + (:require-macros [frpong.core :refer (go go-loop rd wt)])) + +;; > `signal` creates a new signal +;; > `keyboard`, `ticks` and `dom-events` create signals for keydown events, browser animation ticks and +;; JS DOM events repectively +;; > `mult` creates a mult(iple) of a signal which can then be tapped using `tap` to create a copy of the +;; original signal +;; > `rd` reads the current value of a signal +;; > `wt` sets the current value of a signal to the provided value +;; > `go` and `go-loop` start and run a component + ;; Signal Diagram ;; ;; +-d-----------+--------------------------+ @@ -30,8 +38,9 @@ ;; d: paddle positions | | ;; s: game state +------------------------------------------------------+ ;; -;; All signals except the signal e are at the rate of the signal f. The signal e is at the rate -;; at which the keyboard issues events. +;; All signals except the signal e are at the rate of the signal b. The signal e is at the rate +;; at which the keyboard issues events. The signal b is at the rate at which the browser supplies +;; animation frames. (defn abs [x] (.abs js/Math x)) (defn sqrt [x] (.sqrt js/Math x))