animations don't start in the middle.

This commit is contained in:
2014-09-18 17:14:59 -07:00
parent 40a4e54c80
commit 875c9a6af8
2 changed files with 25 additions and 14 deletions

View File

@@ -59,12 +59,15 @@
(defn get-ego [screen]
(let [player-sheet (texture! (texture "player.png") :split 18 36)
talk-sheet (texture! (texture "ego/talk.png") :split 16 36)
stand-sheet (texture! (texture "ego/stand.png") :split 18 36)
ego {:right (animation 0.075 (for [i (range 8)]
(texture (aget player-sheet 0 i))))
:left (animation 0.075 (for [i (range 8)]
(texture (aget player-sheet 1 i))))
:talk (animation 0.2 (for [i (range 8)]
(texture (aget talk-sheet 0 i))))
:stand (animation 0.1 (for [i (flatten [(repeat 6 [(repeat 10 0) (repeat 3 1) (repeat 20 0)]) 3 4 5 5 5 6 5 6 5 6 5 4 3 ])]
(texture (aget stand-sheet 0 i))))
:baseline 95
:origin-x 9
@@ -165,7 +168,9 @@
(assoc (texture "house.png") :x 0 :y 0 :baseline 122)
(assoc (texture "overdirt.png") :x 0 :y 0 :baseline 240)
(assoc (texture "background-trees.png") :x 0 :y 0 :baseline 44)]
:entities {:sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)}
:entities {:sheep (actions/start-animation screen
(assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160)
sheep)}
:collision "outsidehouse/collision.png"
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))
@@ -196,10 +201,8 @@
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))}))
(defn animate [entity screen]
(if (:anim entity)
(merge entity (animation->texture screen (:anim entity)))
entity)
)
(merge entity (animation->texture (update-in screen [:total-time] #(- % (:anim-start entity)))
(:anim entity))))
(defscreen scene
:on-show
(fn [screen entities]