|
|
@ -3,25 +3,22 @@
|
|
|
|
(defn proc-cycle [gamestate obj]
|
|
|
|
(defn proc-cycle [gamestate obj]
|
|
|
|
(let [sprite (:sprite obj)
|
|
|
|
(let [sprite (:sprite obj)
|
|
|
|
sprite-cycle (:cycle sprite)
|
|
|
|
sprite-cycle (:cycle sprite)
|
|
|
|
|
|
|
|
from (:from sprite-cycle)
|
|
|
|
maxpos (:count sprite-cycle)
|
|
|
|
maxpos (:count sprite-cycle)
|
|
|
|
{:keys [pos spc last-cycle]} sprite-cycle
|
|
|
|
{:keys [pos spc last-cycle]} sprite-cycle
|
|
|
|
elapsed (get-in gamestate [:timing :elapsed])]
|
|
|
|
elapsed (get-in gamestate [:timing :elapsed])
|
|
|
|
|
|
|
|
restart? (> (inc pos) maxpos)]
|
|
|
|
; new sprite frame?
|
|
|
|
; new sprite frame?
|
|
|
|
(if (> (+ last-cycle elapsed) spc)
|
|
|
|
(if (> (+ last-cycle elapsed) spc)
|
|
|
|
; start cycle from new?
|
|
|
|
; start cycle from new?
|
|
|
|
; reset last-cycle
|
|
|
|
; reset last-cycle
|
|
|
|
|
|
|
|
(-> obj
|
|
|
|
(assoc-in
|
|
|
|
(assoc-in
|
|
|
|
(if (> (inc pos) maxpos)
|
|
|
|
|
|
|
|
; restart cycle
|
|
|
|
|
|
|
|
(assoc-in obj
|
|
|
|
|
|
|
|
[:sprite :cycle :pos]
|
|
|
|
[:sprite :cycle :pos]
|
|
|
|
(:from sprite-cycle))
|
|
|
|
(if restart? from (inc pos)))
|
|
|
|
; run cycle
|
|
|
|
(assoc-in
|
|
|
|
(update-in obj
|
|
|
|
|
|
|
|
[:sprite :cycle :pos]
|
|
|
|
|
|
|
|
inc))
|
|
|
|
|
|
|
|
[:sprite :cycle :last-cycle]
|
|
|
|
[:sprite :cycle :last-cycle]
|
|
|
|
0)
|
|
|
|
0))
|
|
|
|
(update-in obj
|
|
|
|
(update-in obj
|
|
|
|
[:sprite :cycle :last-cycle]
|
|
|
|
[:sprite :cycle :last-cycle]
|
|
|
|
#(+ % elapsed)))))
|
|
|
|
#(+ % elapsed)))))
|
|
|
|