From 1205e931608c262f3927a923156ca9509c101775 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Sat, 12 Oct 2013 16:32:11 +0530 Subject: [PATCH] More comments --- src/cljs/frpong/core.cljs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cljs/frpong/core.cljs b/src/cljs/frpong/core.cljs index afa8020..cce0e7b 100644 --- a/src/cljs/frpong/core.cljs +++ b/src/cljs/frpong/core.cljs @@ -101,7 +101,7 @@ The signals are taken as parameters." [frames game-state pos vel pl-pos pr-pos] (let [ticks (chan) ;; tick signal - ticks-m (mult ticks) ;; mutliplexers for all signals + ticks-m (mult ticks) ;; multiplexers for all signals pos-m (mult pos) vel-m (mult vel) pl-pos-m (mult pl-pos) @@ -128,7 +128,8 @@ "Ticker component. Converts `frames` signal to ticks and outputs them to the `ticks` signal as long as the `game-state` signal is not :gameover. Once the `game-state` signal is - :gameover, stops the `frames` signal hence stopping the entire game." + :gameover, stops the `frames` signal hence stopping the entire game. + Each tick is the number of milliseconds since the last tick was generated." [frames game-state ticks] (let [ticks-in (tick-chan (diff-chan frames))] (go (loop [] @@ -148,7 +149,12 @@ pos-next (next-pos (! pos-out pos-next)))) - (defn paddle-positioner [keycodes pos-in pos-out] + (defn paddle-positioner + "Paddle Positioner component. + Captures the keydown signal for the provides keycodes and calculates the next paddle + position using the current paddle position (from the `pos-in` signal) and keydown signal + and outputs it to the `pos-out` signal." + [keycodes pos-in pos-out] (let [keys (key-chan keycodes)] (go-loop (let [pos (