it all works, rather smoothly too.

This commit is contained in:
Bryce Covert
2017-05-29 17:32:21 -07:00
parent 03cba14c2a
commit 42067c1080
19 changed files with 206 additions and 217 deletions

View File

@@ -698,6 +698,7 @@
(>= (get-in entities [:fade :opacity]) 1.0))
(terminate [this screen entities]
(utils/release-resources screen :room)
(let [entities (stop screen (if-let [next-time (get-in entities [:state :next-time])]
(-> entities
(assoc-in [:state :time] next-time)

View File

@@ -28,10 +28,7 @@
(actions/update-state entities
(fn [state] (assoc state :safe-listen-count (inc (:safe-listen-count state 0))))))
(defn make [screen]
(let [[screet atlas] (utils/acquire-atlas screen "packed/behindhouse.atlas")
[screet global-atlas] (utils/acquire-atlas screen "packed/global.atlas")]
(defn make [screen atlas global-atlas]
(rooms/make :music {:day :town-2 :night :night}
:name "Behind house"
:interactions
@@ -175,4 +172,4 @@
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)))
:start-pos [172 122])))
:start-pos [172 122]))

View File

@@ -197,10 +197,8 @@
:scripts {:charcoal (actions/get-script entities
(sign-note entities))}})
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/castle-gate.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
throw-walkie (utils/make-anim-seq atlas "throw-walkie" [205 136] 0.1 (flatten [(repeat 55 0) (range 9) (repeat 55 8)]))
(defn make [screen atlas global-atlas]
(let [throw-walkie (utils/make-anim-seq atlas "throw-walkie" [205 136] 0.1 (flatten [(repeat 55 0) (range 9) (repeat 55 8)]))
walkie-visible (animation 1.0 [(utils/atlas->texture atlas "throw-walkie" 8)])
walkie-invisible (animation 1.0 [(utils/atlas->texture atlas "throw-walkie" 0)])]
(rooms/make :music {:day :town-2 :night :night}

View File

@@ -242,9 +242,8 @@
(actions/walk-straight-to entities :ego [140 85] :face :right :update-baseline? false)
(actions/add-entity entities :blank (get-in @entities [:room :blank])))}})
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/cat-tree.atlas")
cat-stand-sheet (texture! (utils/atlas->texture atlas "cat-stand") :split 22 10)
(defn make [screen atlas global-atlas]
(let [cat-stand-sheet (texture! (utils/atlas->texture atlas "cat-stand") :split 22 10)
cat-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 1 (repeat 10 0) 2 3 4 3 0 0 2 3 4 3 (repeat 10 0) 1 1 (repeat 10 0) 5 5 6 6 7 (repeat 10 [7 8]) 6 5 0])]
(aget cat-stand-sheet 0 i)))
cat-walk (animation 0.2 [(utils/atlas->texture atlas "pounce")])

View File

@@ -365,9 +365,8 @@
:fairy-godfather "Imagine the sweet smell of victory once you've mopped up some spilled milk."
:fairy-godfather "Or the smell of soap in the bathroom, where you'll spend your time making the tile and porcelain shine."))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/dream.atlas")
fairy-godfather-anim (utils/make-anim atlas "fairy-godfather" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1])
(defn make [screen atlas global-atlas]
(let [fairy-godfather-anim (utils/make-anim atlas "fairy-godfather" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1])
fairy-godfather-talk-anim (utils/make-anim atlas "fairy-godfather" [63 77] 0.15 [5 6 7 8 7 6])
fairy-godfather-magic-anim (utils/make-anim atlas "fairy-godfather-magic" [100 77] 0.15 [0 1 2 3 4 4 4 4 3 2 1 0])]
(rooms/make :music {:intro :wind :day :dream}

View File

@@ -17,11 +17,8 @@
[play-clj.g2d :refer :all])
(:import [com.badlogic.gdx.graphics Color]))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/ending-castle.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
peddler-sheet (texture! (utils/atlas->texture atlas "peddler-talk" ) :split 18 36)
(defn make [screen atlas global-atlas]
(let [peddler-sheet (texture! (utils/atlas->texture atlas "peddler-talk" ) :split 18 36)
peddler-stand (utils/flip (animation 0.2 (for [i (flatten [(repeat 8 0) 6 (repeat 8 0) 6 (repeat 5 0) 4 5 4 5 4 5])]
(aget peddler-sheet 0 i))))
warden-stand (utils/make-anim atlas "warden-2" [21 41] 0.21 (flatten [(repeat 7 0) 1]))

View File

@@ -56,9 +56,8 @@
(actions/get-script entities
(actions/talk entities who msg)))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/held.atlas")
bloodclot-talk (utils/make-anim-seq atlas "bloodclot-head" [114 82] 0.1 [0 1 2 1 0 3 3 0 1 2 1 0 3 4 5 6 5 3 3 1 2 1 3 3 3 3 3 0 0 0 7 8 7])
(defn make [screen atlas global-atlas]
(let [bloodclot-talk (utils/make-anim-seq atlas "bloodclot-head" [114 82] 0.1 [0 1 2 1 0 3 3 0 1 2 1 0 3 4 5 6 5 3 3 1 2 1 3 3 3 3 3 0 0 0 7 8 7])
bloodclot-stand (utils/make-anim-seq atlas "bloodclot-head" [114 82] 0.1 (flatten [(repeat 15 0) 7 8 7]))]
(rooms/make :music :fight
:name "Held"

View File

@@ -196,9 +196,8 @@
(assoc-in [:room :entities :darken :opacity] 0.4)
(assoc-in [:room :entities :glow :opacity] 0.0))))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-antique.atlas")
shopkeep-sheet (texture! (utils/atlas->texture atlas "shopkeep-talk") :split 18 21)
(defn make [screen atlas global-atlas]
(let [shopkeep-sheet (texture! (utils/atlas->texture atlas "shopkeep-talk") :split 18 21)
shopkeep-stand (animation 0.1 (for [i (flatten [(repeat 30 0) 1 (repeat 50 0) 1 0 1 0])]
(aget shopkeep-sheet 0 i)))
shopkeep-talk (animation 0.15 (for [i [0 2 0 2 0 3 1 0]]

View File

@@ -171,13 +171,8 @@
(defn pace [xs speed]
(mapcat #(repeat (- 4 speed) %) xs))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-cafeteria.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
ladder-guard-stand (animation 0.1 [(utils/atlas->texture atlas "ladder-guard-2")])
(defn make [screen atlas global-atlas]
(let [ladder-guard-stand (animation 0.1 [(utils/atlas->texture atlas "ladder-guard-2")])
ladder-guard-talk (animation 0.1 [ (utils/atlas->texture atlas "ladder-guard-2")])
warriors-stand (utils/make-anim atlas "knights-stand" [49 80] 0.6 (take 100 (repeatedly #(rand-int 10))))
knight-a-stand (utils/make-anim atlas "knight-a" [70 85] 0.2 (flatten [(repeat 3 [(repeat 7 0) (repeat 7 1) (repeat 7 0) (repeat 7 2)]) [3 4 5 6 7 8 9]]))

View File

@@ -360,11 +360,8 @@
(do (actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking.")
nil)))
(defn make [screen]
(let [[screet atlas] (utils/acquire-atlas screen "packed/inside-castle.atlas")
[screet global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
sign (utils/make-anim-seq atlas "sign" [44 20] 0.3 (flatten [(repeat 20 0) 1 0 2 0 1 0 2 0 1 0 2 0 1]))
(defn make [screen atlas global-atlas]
(let [sign (utils/make-anim-seq atlas "sign" [44 20] 0.3 (flatten [(repeat 20 0) 1 0 2 0 1 0 2 0 1 0 2 0 1]))
game-player-talk-sheet (texture! (utils/atlas->texture atlas "game-player-talk") :split 40 44)
game-player-talk-up (animation 0.15 (for [i [0 2 0 2 0 2 0 3 0 2 0 1 0 0 0 0 2 0 2 0 3 0 1 0 1 0 0 1 0 2 0 3 0]]
(aget game-player-talk-sheet 0 i)))

View File

@@ -131,10 +131,8 @@
"Nevermind."
{:run #(actions/do-dialogue entities :ego %)}]}))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-house.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
safe-lock (utils/make-anim atlas "safe-lock" [11 8] 0.1 (flatten [(repeat 20 0) 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 (range 3 20) 20 20 20 20 21 21 21 21 21 20 20 21 21 21 21 21 20 20 20 ]))
(defn make [screen atlas global-atlas]
(let [safe-lock (utils/make-anim atlas "safe-lock" [11 8] 0.1 (flatten [(repeat 20 0) 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 (range 3 20) 20 20 20 20 21 21 21 21 21 20 20 21 21 21 21 21 20 20 20 ]))
candle (utils/make-anim atlas "candle" [34 32] 0.2 [1 0 1 2])
candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1] )
experiment-left (utils/flip (utils/make-anim-seq global-atlas "wizard/experiment" [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))]

View File

@@ -216,9 +216,8 @@
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-jail.atlas")
warden-sheet (texture! (utils/atlas->texture atlas "warden") :split 43 58)
(defn make [screen atlas global-atlas]
(let [warden-sheet (texture! (utils/atlas->texture atlas "warden") :split 43 58)
warden-talk (animation 0.2 (for [i [1 0 1 0 1 0 1 0 0 0 2 0]]
(aget warden-sheet 0 i)))
warden-stand (animation 0.1 (for [i (flatten [(repeat 30 0) 2 (repeat 20 0) 2])]

View File

@@ -54,7 +54,7 @@
(defn make [screen]
(defn make [screen atlas global-atlas]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-stash.atlas")
candle-flame (utils/make-anim atlas "candle" [4 4] 0.1 (range 4))
candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1] )

View File

@@ -326,10 +326,8 @@
(actions/talk entities :ego "Eww! He slobbered on my hand.")
(actions/give entities :slobber))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/outside-castle.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
peddler-sheet (texture! (utils/atlas->texture atlas "peddler-talk" ) :split 18 36)
(defn make [screen atlas global-atlas]
(let [peddler-sheet (texture! (utils/atlas->texture atlas "peddler-talk" ) :split 18 36)
peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])]
(aget peddler-sheet 0 i)))
peddler-stand (animation 0.2 (for [i (flatten [(repeat 8 0) 6 (repeat 15 0) 6 (repeat 5 0) 4 5 4 5 4 5 (repeat 10 0)] )]

View File

@@ -602,10 +602,8 @@
(actions/talk entities :ego "That's a big cauldron!"))))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/outsidehouse.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
sheep-stand-sheet (texture! (utils/atlas->texture atlas "sheep-anim") :split 33 21)
(defn make [screen atlas global-atlas]
(let [sheep-stand-sheet (texture! (utils/atlas->texture atlas "sheep-anim") :split 33 21)
sheep-walk-sheet (texture! (utils/atlas->texture atlas "sheep-walk") :split 33 21)
lamb-walk-sheet (texture! (utils/atlas->texture atlas "lamb-walk") :split 27 28)
sheep-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 11) (repeat 15 12)])]

View File

@@ -93,9 +93,8 @@
(actions/walk-straight-to entities :ego [142 96])
(actions/talk entities :ego "This must be Frankie Rockfist's secret stash!")))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/outside-jail.atlas")
guard-sheet (texture! (utils/atlas->texture atlas "guard") :split 37 87)
(defn make [screen atlas global-atlas]
(let [guard-sheet (texture! (utils/atlas->texture atlas "guard") :split 37 87)
guard-stand (animation 0.1 [(aget guard-sheet 0 0)])
guard-talk (animation 0.2 (for [i [0 0 0 0 1 0 0 1]] (aget guard-sheet 0 i)))
guard-sleep (utils/make-anim atlas "guard-sleep" [43 67] 0.1 (range 4))

View File

@@ -182,9 +182,8 @@
(defn grunt-vol [entities]
(* 0.3 (get-in entities [:room :entities :bloodclot :opacity])))
(defn make [screen]
(let [[screen atlas] (utils/acquire-atlas screen "packed/space.atlas")
bloodclot-head-talk-anim (utils/make-anim-seq atlas "bloodclot-head-talk" [82 75] 0.05 [0 0 1 1 2 2 1 1 0 0 1 1 2 2 1 1 0 0 3 4 4 4 3 0 0 1 1 2 2 1 1 0 0 0 0 5 5 5 6 6 6 7 7 7])
(defn make [screen atlas global-atlas]
(let [bloodclot-head-talk-anim (utils/make-anim-seq atlas "bloodclot-head-talk" [82 75] 0.05 [0 0 1 1 2 2 1 1 0 0 1 1 2 2 1 1 0 0 3 4 4 4 3 0 0 1 1 2 2 1 1 0 0 0 0 5 5 5 6 6 6 7 7 7])
bloodclot-head-stand-anim (utils/make-anim-seq atlas "bloodclot-head-talk" [82 75] 0.05 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 3])
bloodclot-head-shoot-anim (utils/make-anim-seq atlas "bloodclot-head-talk" [82 75] 0.05 [8 9 8 9 8 9 8 9 8 9 8 9 8 9 8 9 8 9 8 9 10 11 10 11 10 11 10 11 10 11 10 11])
bloodclot-head-keep-shoot-anim (utils/make-anim-seq atlas "bloodclot-head-talk" [82 75] 0.05 [12 13])

View File

@@ -1204,26 +1204,29 @@
_ (update! screen :shader shader)
log-assets (fn [r] r)
wrap (fn [maker]
wrap (fn [maker atlas-file]
(fn [screen]
(-> (maker screen)
(add-georgia screen global-atlas))))
rooms {:inside-house (wrap rooms.inside-house/make)
:inside-stash (wrap rooms.inside-stash/make)
:outside-house (wrap rooms.outside-house/make)
:behind-house (wrap rooms.behind-house/make)
:cat-tree (wrap rooms.cat-tree/make)
:inside-castle (wrap rooms.inside-castle/make)
:space (wrap rooms.space/make)
:held (wrap rooms.held/make)
:inside-cafeteria (wrap rooms.inside-cafeteria/make)
:inside-antique (wrap rooms.inside-antique/make)
:inside-jail (wrap rooms.inside-jail/make)
:dream (wrap rooms.dream/make)
:ending (wrap rooms.ending/make)
:castle-gate (wrap rooms.castle-gate/make)
:outside-jail (wrap rooms.outside-jail/make)
:outside-castle (wrap rooms.outside-castle/make) }
(let [[screen atlas] (utils/acquire-atlas screen atlas-file :room)
[screen global-atlas ] (utils/acquire-atlas screen "packed/global.atlas" :room)]
(-> (maker screen atlas global-atlas)
(add-georgia screen global-atlas)))))
rooms {:inside-house (wrap rooms.inside-house/make "packed/inside-house.atlas")
:inside-stash (wrap rooms.inside-stash/make "packed/inside-stash.atlas")
:outside-house (wrap rooms.outside-house/make "packed/outsidehouse.atlas")
:behind-house (wrap rooms.behind-house/make "packed/behindhouse.atlas")
:cat-tree (wrap rooms.cat-tree/make "packed/cat-tree.atlas")
:inside-castle (wrap rooms.inside-castle/make "packed/inside-castle.atlas")
:space (wrap rooms.space/make "packed/space.atlas")
:held (wrap rooms.held/make "packed/held.atlas")
:inside-cafeteria (wrap rooms.inside-cafeteria/make "packed/inside-cafeteria.atlas")
:inside-antique (wrap rooms.inside-antique/make "packed/inside-antique.atlas")
:inside-jail (wrap rooms.inside-jail/make "packed/inside-jail.atlas")
:dream (wrap rooms.dream/make "packed/dream.atlas")
:ending (wrap rooms.ending/make "packed/ending.atlas")
:castle-gate (wrap rooms.castle-gate/make "packed/castle-gate.atlas")
:outside-jail (wrap rooms.outside-jail/make "packed/outside-jail.atlas")
:outside-castle (wrap rooms.outside-castle/make "packed/outside-castle.atlas") }
entities {:rooms rooms
:step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241)
:cam {:zoom utils/min-zoom
@@ -1479,6 +1482,9 @@
(assoc-in [:tweens :fade-out]
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish #(do
(-> screen
(utils/release-resources :room)
(utils/release-resources :default))
(utils/stop-all-sounds! %)
(set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
%))))))

View File

@@ -766,18 +766,29 @@
(recur r#))))))))
(defn acquire-atlas [{:keys [resources] :as screen :or {resources []}} file]
(let [atlas (texture-atlas file)]
(defn acquire-atlas
([screen file]
(acquire-atlas screen file :default))
([screen file id]
(let [resources (get-in screen [:resources id] [])
atlas (texture-atlas file)]
(update! screen :resources
(conj resources file))
[(assoc screen :resources (conj resources file))
atlas]))
(assoc (:resources screen) id (conj resources file)))
[(assoc-in screen [:resources id] (conj resources file))
atlas])))
(defn release-resources [screen]
(doseq [resource (:resources screen)]
(defn release-resources
([screen]
(release-resources screen :default))
([screen id]
(println (:resources screen))
(doseq [resource (id (:resources screen))]
(println "releasing " resource)
(asset-manager! *asset-manager* :unload resource))
(update! screen :resources [])
(app! :log "info"(str "Released resources " (.getDiagnostics *asset-manager*))))
(app! :log "info"(str "Released resources " (.getDiagnostics *asset-manager*)))
(update! screen :resources (assoc (:resources screen {}) id []))))
(defn make-anim-seq
([file [w h] speed frames]