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

@@ -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)))))))