diff --git a/resources/public/index.html b/resources/public/index.html index 9656711..dee406a 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -6,17 +6,47 @@ + -
FPS:
-
State:
-
Score:
-
Velocity:
- - - - - +
+
+
+
press any key to start
+
+ + + + + +
+
score 0
+ use W-S keys to move the left paddle and Up-Down arrow keys to move the right paddle +
0 fps
+
+
+
diff --git a/src/cljs/frpong/core.cljs b/src/cljs/frpong/core.cljs index 9860357..9848244 100644 --- a/src/cljs/frpong/core.cljs +++ b/src/cljs/frpong/core.cljs @@ -54,12 +54,13 @@ [(+ x (* vel-x tick)) (+ y (* vel-y tick))]) (defn ^:export frpong [] - (let [width 800 - height 400 + (let [body-el (.-body js/document) + width (- (.-scrollWidth body-el) 20) + height (- (.-scrollHeight body-el) 125) padding 5 paddle-size 100 paddle-width 10 - ball-radius 5 + ball-radius 8 ball-speed 0.33 init-pos [(/ width 2) (/ height 2)] init-vel (let [sgn #(if (< % 0.5) -1 1) @@ -135,7 +136,7 @@ (collision-detector (tap ticks-m) (tap pos-m) (tap vel-m) pl-pos-sust pr-pos-sust (tap game-state-m) game-state vel) - (renderer (tap ticks-m) (tap game-state-m) (tap pos-m) (tap vel-m) (tap pl-pos-m) (tap pr-pos-m)))) + (renderer (tap ticks-m) (tap game-state-m) (tap pos-m) (tap pl-pos-m) (tap pr-pos-m)))) (defn ticker "Ticker component. @@ -248,25 +249,31 @@ "Renderer component. Renders the ball and paddle positions on the browser. Also shows the game state and stats. Reads the current values from the signals supplied as parameters." - [ticks game-state pos vel pl-pos pr-pos] + [ticks game-state pos pl-pos pr-pos] (let [ball-el (dom/by-id "ball") state-el (dom/by-id "state") score-el (dom/by-id "score") lpaddle-el (dom/by-id "lpaddle") rpaddle-el (dom/by-id "rpaddle") - fps-el (dom/by-id "fps") - vel-el (dom/by-id "vel")] - (go-loop - (let [fps (/ 1000 (