adding function to flip animations so that we only need one file per anim.
This commit is contained in:
@@ -56,14 +56,23 @@
|
|||||||
(script entities)
|
(script entities)
|
||||||
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]
|
(defn get-ego [screen]
|
||||||
(let [player-sheet (texture! (texture "player.png") :split 18 36)
|
(let [player-sheet (texture! (texture "player.png") :split 18 36)
|
||||||
talk-sheet (texture! (texture "ego/talk.png") :split 18 36)
|
talk-sheet (texture! (texture "ego/talk.png") :split 18 36)
|
||||||
stand-sheet (texture! (texture "ego/stand.png") :split 18 36)
|
stand-sheet (texture! (texture "ego/stand.png") :split 18 36)
|
||||||
ego {:right (animation 0.075 (for [i (range 8)]
|
walk-right (animation 0.075 (for [i (range 8)]
|
||||||
(texture (aget player-sheet 0 i))))
|
(texture (aget player-sheet 0 i))))
|
||||||
:left (animation 0.075 (for [i (range 8)]
|
ego {:right walk-right
|
||||||
(texture (aget player-sheet 1 i))))
|
:left (flip walk-right)
|
||||||
:talk (animation 0.2 (for [i (range 8)]
|
:talk (animation 0.2 (for [i (range 8)]
|
||||||
(texture (aget talk-sheet 0 i))))
|
(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 ])]
|
: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 ])]
|
||||||
|
|||||||
Reference in New Issue
Block a user