adding function to flip animations so that we only need one file per anim.

This commit is contained in:
2014-09-18 17:46:18 -07:00
parent 6efeeabe55
commit 0ae2c5cea8

View File

@@ -56,14 +56,23 @@
(script entities)
entities))
(defn flip [anim]
(animation (animation! anim :get-frame-duration)
(for [src-frame (animation! anim :get-key-frames)
:let [frame (texture (texture! src-frame :get-texture))]]
(do
(texture! frame :set-region src-frame)
(texture! frame :flip true false)
frame))))
(defn get-ego [screen]
(let [player-sheet (texture! (texture "player.png") :split 18 36)
talk-sheet (texture! (texture "ego/talk.png") :split 18 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))))
walk-right (animation 0.075 (for [i (range 8)]
(texture (aget player-sheet 0 i))))
ego {:right walk-right
:left (flip walk-right)
: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 ])]