Skip to content

Commit

Permalink
Acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
harrykeightley committed Oct 3, 2023
1 parent 0d17760 commit fcdd0c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/snake/snake.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@
[[:add [:components :food id] [:food]]
[:add [:components :position id] [food-position]]]))

(defn update-tick [x]
(max 100 (- x 5)))

(defsys accelerate {:events :tick}
[[:update [:resource :timer] #(update % :ms dec)]])
[[:update [:resources :timer] #(update %1 :ms update-tick)]])

(defsys display-game
{:resources [:length :bounds]
Expand Down
2 changes: 1 addition & 1 deletion examples/threejs/src/app.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
:events :tick}
(let [[rows cols] (:bounds resources)]
(doseq [[cube [row col]] components]
(set! (.. cube -position -x) col)
(set! (.. cube -position -x) (-> (/ cols 2) - (+ col)))
(set! (.. cube -position -y) (- rows row)))))

(defsys reset-cubes
Expand Down

0 comments on commit fcdd0c3

Please sign in to comment.