Added game over notification

master
Abhinav Sarkar 2013-10-15 19:38:47 +05:30
parent daae81a751
commit 7a9712061d
2 changed files with 5 additions and 2 deletions

View File

@ -50,7 +50,7 @@ body {
<span style="float: left; vertical-align: top;">Gravity
<input id="gravity" type="range" min="1" max="10" value="1" step="1" />
</span>
<span style="float: right; font-size: small">
<span style="float: right; font-size: smaller">
<span id="state">press &lt;space&gt; to start</span>
</span>
</div>

View File

@ -311,9 +311,11 @@
score-el (dom/by-id "score")
lpaddle-el (dom/by-id "lpaddle")
rpaddle-el (dom/by-id "rpaddle")
fps-el (dom/by-id "fps")]
fps-el (dom/by-id "fps")
title-el (dom/by-id "title")]
(dom/set-style! ball-el "fill" "orange")
(dom/set-text! state-el "")
(dom/set-text! title-el "Gravity Pong!")
(go (loop [fps-p nil score-p nil]
(let [fps (int (/ 1000 (<! ticks)))
[x y] (<! pos)
@ -331,6 +333,7 @@
(when (= state :gameover)
(do (dom/set-style! ball-el "fill" "red")
(dom/set-text! state-el "press <space> to restart")
(dom/set-text! title-el "GAME OVER")
(start-on-space)))
(recur fps score))))))