-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from WarFox/styling
animation and styling
- Loading branch information
Showing
11 changed files
with
910 additions
and
499 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
(ns cljs-2048.game-events | ||
(:require | ||
[day8.re-frame.tracing :refer-macros [fn-traced]] | ||
[re-frame.core :as re-frame] | ||
[cljs-2048.local-storage :as ls])) | ||
|
||
(re-frame/reg-event-db | ||
::add-score | ||
(fn-traced | ||
(defn add-score | ||
[db [_ new-score]] | ||
(let [score (+ new-score (:score db)) | ||
high-score (max score (:high-score db))] | ||
(ls/set-high-score! high-score) ;; set high-score in local-storage | ||
(assoc db | ||
:score score | ||
:high-score high-score)))) | ||
:high-score high-score))) | ||
|
||
(defn gameover | ||
[db [_]] | ||
(assoc db :gameover true)) | ||
|
||
(re-frame/reg-event-db | ||
::add-score | ||
add-score) | ||
|
||
(re-frame/reg-event-db | ||
::gameover | ||
(fn-traced | ||
[db [_]] | ||
(assoc db :gameover true))) | ||
gameover) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.