From 0ae2c5cea8b87d9eca18f471abeec44814caa049 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Thu, 18 Sep 2014 17:46:18 -0700 Subject: [PATCH] adding function to flip animations so that we only need one file per anim. --- desktop/src-common/advent/screens/scene.clj | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index d82b3701..418cebc1 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -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 ])]