multi bird

This commit is contained in:
2014-12-10 13:19:08 -08:00
parent e10c54f85b
commit 04bac2afb9
3 changed files with 29 additions and 22 deletions

View File

@@ -143,7 +143,12 @@
(actions/talk entities :ego "Ye Ol' Antique Shoppe."))}}
:layers [(assoc (texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "inside-castle/pedestal-overlay.png") :x 0 :y 0 :baseline 135)]
:entities {:trophy (assoc (animation->texture screen trophy)
:entities {:bird-1 (utils/make-bird screen (as-> [[185 235]
[220 225] [210 230] [250 235]] p
(concat p (reverse p))))
:bird-2 (utils/make-bird screen (as-> [[220 225] [195 235] [210 230] [250 225]] p
(concat p (reverse p))))
:trophy (assoc (animation->texture screen trophy)
:x 253 :y 69 :baseline 191
:anim trophy
:anim-start 0
@@ -198,7 +203,7 @@
:scale-fn (utils/scaler-fn-from-image "inside-castle/scale.png" 0.25 1.00)
:apply-state (fn [entities]
(as-> entities entities
(if (actions/has-item? entities :ladder)
(update-in entities [:room :entities] #(dissoc % :ladder))
(if (actions/has-item? entities :trophy)
(update-in entities [:room :entities] #(dissoc % :trophy))
entities)))
:start-pos [245 90])))

View File

@@ -19,9 +19,6 @@
balloon-sheet (texture! (texture "outside-castle/balloons.png") :split 20 36)
balloon-stand (animation 0.25 (for [i [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 0 1 2 1 0 1 2 1 0 1 2 1 0 1 2]]
(aget balloon-sheet 0 i)))
bird-sheet (texture! (texture "outside-castle/bird.png") :split 1 2)
bird-stand (animation 0.15 (for [i [0 1]]
(aget bird-sheet 0 i)))
butterfly-stand (utils/make-anim "butterfly.png" [7 7] 0.1 [0 1])
steer-sheet (texture! (texture "outside-castle/steer.png") :split 50 35)
steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]]
@@ -166,22 +163,9 @@
:script (actions/get-script entities
(actions/talk entities :ego "Those look like the choicest of balloons.")))
:stand)
:bird (actions/start-animation screen
(assoc (animation->texture screen bird-stand)
:x 0
:y 0
:baseline 21
:stand bird-stand
:path (catmull-rom-spline (map #(apply vector-2* %) (as-> [[82 235] [134 215] [185 235] [165 238]
[220 225] [210 230] [250 235]] p
(concat p (reverse p)))) true)
:update-fn (fn [screen entities entity]
(let [speed 0.05
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
v (vector-2 0 0)
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))
:stand)
:bird (utils/make-bird screen (as-> [[82 235] [134 215] [185 235] [165 238]
[220 225] [210 230] [250 235]] p
(concat p (reverse p))))
:butterfly (assoc (animation->texture screen butterfly-stand)
:x 161
:y 218

View File

@@ -2,6 +2,7 @@
(:require [play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.math :refer :all]
[play-clj.g2d :refer :all]
[clojure.edn :as edn])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
@@ -79,3 +80,20 @@
(let [sheet (texture! (texture file) :split w h)]
(animation speed (for [i frames]
(aget sheet 0 i)))))
(defn make-bird [screen p]
(let [bird-sheet (texture! (texture "outside-castle/bird.png") :split 1 2)
bird-stand (animation 0.15 (for [i [0 1]]
(aget bird-sheet 0 i)))]
(assoc (animation->texture screen bird-stand)
:x 0
:y 0
:baseline 21
:anim bird-stand
:anim-start 0
:path (catmull-rom-spline (map #(apply vector-2* %) p) true)
:update-fn (fn [screen entities entity]
(let [speed 0.05
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
v (vector-2 0 0)
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))))