From 67a91b05221beaf27ae317996cd4d835f898c4b6 Mon Sep 17 00:00:00 2001 From: Timur Abishev Date: Sun, 28 Sep 2014 00:47:41 +0400 Subject: [PATCH] fix mystic f**king s**t --- src/rockets/game.cljs | 17 +++++++++++------ src/rockets/model.cljs | 4 ++-- src/rockets/sprites.cljs | 5 +++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/rockets/game.cljs b/src/rockets/game.cljs index bde6cd4..40e7601 100644 --- a/src/rockets/game.cljs +++ b/src/rockets/game.cljs @@ -8,17 +8,22 @@ [rockets.model :as model])) (q/defcomponent - CellComponent [cell selected?] - (sprites/CoolSpriteComponent (:cell-type cell) (:orientation cell) selected? false)) + ;CellComponent [cell selected?] + CellComponent [args] + (let [cell-type ((args :cell) :cell-type) + orientation ((args :cell) :orientation) + selected? (args :selected?)] + (sprites/CoolSpriteComponent {:type cell-type, :angle orientation, :selected? selected?, :fire? false}))) (q/defcomponent - FieldComponent [cells selected] + ;FieldComponent [cells selected] + FieldComponent [args] (html [:table {:style util/no-borders-style} (for [x (range 0 model/size-n)] [:tr {:style util/no-borders-style} (for [y (range 0 model/size-m) - :let [cell (nth (nth cells x) y)]] - [:td {:style util/no-borders-style} (CellComponent cell false)])])])) + :let [cell (nth (nth (args :cells) x) y)]] + [:td {:style util/no-borders-style} (CellComponent {:cell cell, :selected? false})])])])) (q/defcomponent ShuffleComponent [refresh-time] @@ -29,7 +34,7 @@ (html [:table {:style util/no-borders-style} [:tr {:style util/no-borders-style} [:td {:style (merge {:vertical-align "bottom"} util/no-borders-style)} (ShuffleComponent (:reload-time board))] - [:td {:style util/no-borders-style} (FieldComponent (:cells board) (:selected board))]]])) + [:td {:style util/no-borders-style} (FieldComponent board)]]])) (def space-between-boards (* sprites/sprite-width 4)) (def board-width (* sprites/sprite-width (inc model/size-m))) diff --git a/src/rockets/model.cljs b/src/rockets/model.cljs index 7171f65..ea3aea6 100644 --- a/src/rockets/model.cljs +++ b/src/rockets/model.cljs @@ -110,9 +110,9 @@ (util/update-value board [:cells ((board :selected) :x) ((board :selected) :y)] do-rotate-cell)) (defn event-select [game-state board] + ;(js/console.log (sablono.util/to-str ((:cells (game-state board)) 0))) ;todo add action when selected in reset field (util/update-value game-state [board] do-rotate-selected)) (defn event-tick [game-state tick] - (when (= (mod tick 100) 0) (js/console.log tick)) - game-state) + (if (= (mod tick 10) 0) (event-select game-state :board1) game-state)) diff --git a/src/rockets/sprites.cljs b/src/rockets/sprites.cljs index 3f244fb..6857d9f 100644 --- a/src/rockets/sprites.cljs +++ b/src/rockets/sprites.cljs @@ -52,5 +52,6 @@ (html [:div {:style fire-style}])) (q/defcomponent - CoolSpriteComponent [type angle selected? fire?] - (html (selected-state (fire-state(sprite type angle) fire?) selected?))) \ No newline at end of file + ;CoolSpriteComponent [type, angle, fire?, selected?] + CoolSpriteComponent [args] + (html (selected-state (fire-state(sprite (args :type) (args :angle)) (args :fire?)) (args :selected?)))) \ No newline at end of file