improving inventory item scales.

This commit is contained in:
Bryce Covert
2016-12-11 16:37:45 -08:00
parent 0803cbeb5b
commit f87c14abf1
3 changed files with 216 additions and 214 deletions

View File

@@ -210,7 +210,7 @@ void main ()
(do (put! (actions/get-channel current-action) terminated-entities)
(-> terminated-entities
(assoc-in [:fg-actions :current] nil)
(assoc-in [:fg-actions :started?] false))))
(assoc-in [:fg-actions :started?] false))))
(= :end (actions/skip-type current-action screen entities))
(let [terminated-entities (actions/terminate current-action screen entities)]
@@ -255,12 +255,12 @@ void main ()
interacting-entity (get-interacting-entity entities x y)
current-action (get-in entities [:fg-actions :current])
;; TODO - hacky way of resetting queue
entities (if current-action
(skip-action screen entities)
entities)]
(when (and (not (get-in entities [:fg-actions :script-running?]))
(or (= (get-in entities [:cursor :down-target])
(or (:id interacting-entity) (:id interaction) nil))
@@ -273,11 +273,11 @@ void main ()
(do (screen! hud :on-start-script {})
((:get-script interaction) (get-script-selector entities)
[x y])))
((:get-script default-interaction) (get-script-selector entities) [x y])) entities))
(cond-> entities
true (assoc-in [:cursor :down-target] nil)
utils/mobile? (assoc-in [:cursor :last-pos] [0 0]))))
utils/mobile? (assoc-in [:cursor :last-pos] [0 0]))))
(defn handle-touch-up [{:keys [^FitViewport viewport] :as screen} entities {:keys [input-x input-y] :as options}]
(let [entities (assoc-in entities [:cursor :depressed?] false)]
@@ -288,10 +288,10 @@ void main ()
entities
(= (button-code :right)
(:button options))
(:button options))
(do (screen! hud :on-return-item {})
entities)
(and (get-in entities [:state :active?])
(or (not (get-in entities [:state :hud-active?]))
(get-in entities [:fg-actions :script-running?]))
@@ -302,7 +302,7 @@ void main ()
entities)))
(defn get-ego-script [cursor [x y]]
(condp = (:value cursor)
:charcoal
(common/one-liner "Just a dark piece of charcoal.")
@@ -311,7 +311,7 @@ void main ()
(actions/get-script entities (actions/talk entities :ego "Blegh! Gross!"))
:flask-1-strength
(actions/get-script entities
(actions/get-script entities
(cond (= :held
(get-in @entities [:state :last-room]))
(common/do-win entities)
@@ -329,7 +329,7 @@ void main ()
(Thread/sleep 1000)
(actions/talk entities :warden "Hey, get back in jail!")
(common/go-to-jail entities))
:else
(do
(actions/talk entities :ego "I'd better save this strength potion for just the right moment!"))))
@@ -391,7 +391,7 @@ void main ()
(do
(actions/talk entities :ego "Ugh! I have Gandarf's MagiSafe 2000 tune stuck in my head.")
(actions/play-safe entities))))
:alarm-clock
(common/one-liner "It's a magic device that tells the time.")
@@ -407,7 +407,7 @@ void main ()
(actions/do-dialogue entities :ego "Yuck!"))
:stick
(common/one-liner "It's a huge stick.")
(common/one-liner "It's a huge stick.")
:wool
(common/one-liner "Better not wash it in hot water.")
@@ -415,127 +415,127 @@ void main ()
:spell-component
(common/one-liner "It needs to go into the cauldron.")
:feather
:feather
(common/one-liner "An owl feather. Smells like puke.")
:ball-n-chain
:ball-n-chain
(common/one-liner "Why am I lugging this around? It's so heavy.")
:flask-water
:flask-water
(common/one-liner "Gandarf knows what to do next with this.")
:broom
:broom
(common/one-liner "A janitor's broom.")
:glass-eye
:glass-eye
(common/one-liner "It's a glass eye.")
:flask-1-slobber
:flask-1-slobber
(common/one-liner "It's got some bull slobber in it.")
:crowbar
:crowbar
(common/one-liner "It can probably bend steel!")
:monocle
:monocle
(common/one-liner "It's a monocle.")
:used-earplugs
:used-earplugs
(common/one-liner "They've got earwax all over them. No thanks.")
:broken-clock
:broken-clock
(common/one-liner "Split right down the middle.")
:trophy
:trophy
(common/one-liner "I've proven myself in wisdom!")
:carrot
:carrot
(common/one-liner "I'm not that hungry.")
:ladder
:ladder
(common/one-liner "It's the Duke's ladder.")
:motivational-tapes
:motivational-tapes
(common/one-liner "If only I had a VCR. I'd get my life back together.")
:sack-lunch
:sack-lunch
(common/one-liner "Ugh, gross! The blue cheese smells really strong.")
:grass
:grass
(common/one-liner "This is top quality, high protein stuff!")
:cat-toy
:cat-toy
(common/one-liner "It's a little cat toy!")
:ash
:ash
(common/one-liner "A spell's ashes.")
:shovel
:shovel
(common/one-liner "A grave-digger's shovel.")
:mandrake
:mandrake
(common/one-liner "It's some kind of root.")
:flask-water-flies
:flask-water-flies
(common/one-liner "Looks like I need to add the ashes of magic.")
:flask-1
:flask-1
(common/one-liner "An empty flask.")
:flask-flies-ash
:flask-flies-ash
(common/one-liner "Looks like I need to stir it with the gift of flight.")
:magic-slingshot
:magic-slingshot
(common/one-liner "The Slinger's Shot, fully restored.")
:frog-legs
:frog-legs
(common/one-liner "I wonder where the head is...")
:sword
:sword
(common/one-liner "Yowza! The Sword of Blergh's sharp as a razor.")
:medal
:medal
(common/one-liner "I've proven myself worthy in strength!")
:spear
:spear
(common/one-liner "A knight's spear.")
:slobber
:slobber
(common/one-liner "I wonder why I am carrying this drool around.")
:kiss
:kiss
(common/one-liner "Yuck! A kiss for my bravery.")
:flask-1-with-milk
:flask-1-with-milk
(common/one-liner "I've got some sheep's milk in my flask.")
:flask-1-with-mushrooms
:flask-1-with-mushrooms
(common/one-liner "I've got some mushrooms in my flask. It still needs some cream.")
:balloon
:balloon
(common/one-liner "My choicest balloon would be blue. But he didn't give me a choice.")
:money
:money
(common/one-liner "It's got the Duke of Remington's face on it.")
:flask-2
:flask-2
(common/one-liner "I need to fill it with fountain water.")
:key
:key
(common/one-liner "It's the key to the jail.")
:flask-water-ash
:flask-water-ash
(common/one-liner "Looks like I need the sound of buzzing.")
:slingshot
:slingshot
(common/one-liner "The Slinger's Shot.")
:teddy
:teddy
(common/one-liner "It's the choicest teddy.")
:flies
:flies
(common/one-liner "I don't want any of them to buzz off.")
:rope
:rope
(common/one-liner "A nice, sturdy, rope.")
nil))
@@ -590,7 +590,7 @@ void main ()
fire-2-anim (animation 0.1 (for [i [0 1 2 2 2 3 2 3 2 2 2 2 2 2 2 4 4 4 5 6 7 4 4 4 2 2 2 2 2 2 2 2 1 0]]
(texture (aget fire-sheet 0 i))))
fire-3-anim (animation 0.1 (for [i [0 1 2 2 2 3 2 3 2 2 2 2 2 2 4 4 4 4 4 4 5 6 7 4 4 4 4 4 8 9 10 11 4 4 4 2 2 2 2 2 2 2 2 0]]
(texture (aget fire-sheet 0 i))))
(texture (aget fire-sheet 0 i))))
grow (animation 0.1 (for [i [0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 3 0 0 0 0 3 0 0 0 3 3 0 0 0 2 2 0 0 2 0 0 2 0 2 0 2 0 2 0 2 0 2 3 2 3 2 3 2 3 2 4 3 4 3 4 3 4]]
(texture (aget grow-sheet 0 i))))
squat-talk (utils/make-anim "ego/squat-talk.png" [18 36] 0.2 [0 1 0 2 1 0 3])
@@ -604,7 +604,7 @@ void main ()
jumping-straight (utils/make-anim "ego/jump-straight.png" [18 48] 0.075 (repeat 30 4))
swing (utils/make-anim "ego/swing.png" [36 75] 0.145 (flatten [[3 4 5 6 7 ]]))
grow-talk (utils/make-anim "ego/grow-talk.png" [18 36] 0.2 (range 2))
get-sick (utils/make-anim "ego/get-sick.png" [18 36] 0.1 (flatten [(range 6) (repeat 10 5) (reverse (range 6) ) 0 0 0 0 0 0]))
get-sick (utils/make-anim "ego/get-sick.png" [18 36] 0.1 (flatten [(range 6) (repeat 10 5) (reverse (range 6) ) 0 0 0 0 0 0]))
spear (utils/make-anim "ego/spear.png" [18 100] 0.2 [0 1 2 3 2 3 2 3 2 3 2 1 0])
crowbar (utils/make-anim "ego/crowbar.png" [36 36] 0.1 [0 0 0 1 1 2 2 2 2 2 3 2 3 2 3 2 3 2 3 3 3 1 1 0 0 0])
shoot (utils/make-anim "ego/shoot.png" [24 36] 0.075 [0 0 0 1 1 2 2 2 2 2 2 2 2 3 4 5 4])
@@ -639,7 +639,7 @@ void main ()
(rand-nth [:inside-step-sound-1 :inside-step-sound-2 :inside-step-sound-3 :inside-step-sound-4])
(rand-nth [:step-sound-1 :step-sound-2 :step-sound-3 :step-sound-4])))
ego {:right {:walk walk-right
:stand stand-anim
@@ -691,7 +691,7 @@ void main ()
:axe-wood axe-wood
:suspended suspended
:suspended-talk suspended-talk
:crawl crawl
:crawl crawl
:crawl-stand crawl-stand
:crawl-hide crawl-hide
:standup standup
@@ -743,7 +743,7 @@ void main ()
:axe-wood (utils/flip axe-wood)
:suspended (utils/flip suspended)
:suspended-talk (utils/flip suspended-talk)
:crawl (utils/flip crawl)
:crawl (utils/flip crawl)
:crawl-stand (utils/flip crawl-stand)
:crawl-hide (utils/flip crawl-hide)
:standup (utils/flip standup)
@@ -753,12 +753,12 @@ void main ()
:climb (utils/flip climb)
:poke (utils/flip poke)
:whistle (utils/flip whistle)
}
}
:baseline (- 240 (double (last start-pos)))
:facing :right
:night-profile :sprite
:origin-x 9
:origin-y 0
:origin-y 0
:scaled true
:drop-sound (utils/load-sound "ego/drop.ogg")
:milk-sound (utils/load-sound "outsidehouse/milk.ogg")
@@ -784,18 +784,18 @@ void main ()
:idea-sound (utils/load-sound "ego/idea.ogg")
:scale-x start-scale
:scale-y start-scale
:talk-color (color 0.6 1.0 1.0 1.0)
:talk-color (color 0.6 1.0 1.0 1.0)
:stand-override nil
:mouse-in? (fn [entities x y]
(let [{^double entity-x :x ^double entity-y :y ^TextureRegion region :object scale :scale-x} (get-in entities [:room :entities :ego])
(let [{^double entity-x :x ^double entity-y :y ^TextureRegion region :object scale :scale-x} (get-in entities [:room :entities :ego])
half-width (double (/ (* (.getRegionWidth region) (double (or scale 1.0))) 2))
height (double (* (.getRegionHeight region) (double (or scale 1.0))))]
((zone/box (- entity-x half-width) entity-y (+ entity-x half-width) (+ entity-y height)) x y)))
:get-script get-ego-script
:get-script get-ego-script
:x (first start-pos) :y (last start-pos)
:id "ego"}
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [choose-step-sound 0.5]
6 [choose-step-sound 0.5]}
(get-in ego [:right :walk]) {2 [choose-step-sound 0.5]
@@ -809,25 +809,25 @@ void main ()
(get-in ego [:right :crowbar] ) {3 [:crowbar-sound 0.5]}
(get-in ego [:right :shoot] ) {14 [:shoot-sound 0.75]}
(get-in ego [:left :shoot] ) {14 [:shoot-sound 0.75]}
(get-in ego [:left :get-sick] ) {1 [:get-sick-sound 0.55]}
(get-in ego [:right :get-sick] ) {1 [:get-sick-sound 0.55]}
(get-in ego [:right :scared-walk] ) {0 [:scared-step-sound 0.15 1.5]
4 [:scared-step-sound 0.15 1.9]}
(get-in ego [:left :stand]) {11 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
176 [:blink 0.15]
200 [:scratch-sound 0.15]
}
(get-in ego [:right :stand]) {11 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
176 [:blink 0.15]
200 [:scratch-sound 0.15]
}
@@ -867,9 +867,9 @@ void main ()
(get-in ego [:right :axe-wood]) {:origin-x 17}
(get-in ego [:left :love]) {:origin-x 41}
(get-in ego [:left :suspended]) {:origin-x 0 :origin-y 0}
(get-in ego [:right :suspended]) {:origin-x 0 :origin-y 0}
(get-in ego [:right :suspended]) {:origin-x 0 :origin-y 0}
(get-in ego [:left :suspended-talk]) {:origin-x 0 :origin-y 0}
(get-in ego [:right :suspended-talk]) {:origin-x 0 :origin-y 0}
(get-in ego [:right :suspended-talk]) {:origin-x 0 :origin-y 0}
:default {:origin-x 9}})]
(actions/start-animation screen
(merge (animation->texture screen (:stand (:right ego))) ego)
@@ -884,13 +884,13 @@ void main ()
(do
(next-script entities)
(log/info "starting script")
(assoc-in entities [key :script-running?] true))
entities)))))
(defn update-from-script [screen entities key]
(let [{{:keys [current started? channel script-chan script-running?]} key} entities]
(if current
(let [entities (if started? entities (actions/begin current screen entities))
entities (actions/continue current screen entities)]
@@ -902,7 +902,7 @@ void main ()
key))
(assoc-in entities [key :started?] true)))
(let [current (poll! channel)]
(-> entities
(assoc-in [key :started?] false)
(assoc-in [key :last-skip-type] (if current
@@ -926,7 +926,7 @@ void main ()
total-time (double total-time)]
(cond
(not= 0.0 (get-in entities [:fade :opacity]))
entities
entities
(< (unchecked-subtract total-time time-changed) 0.15)
entities
@@ -956,10 +956,10 @@ void main ()
animated-time (unchecked-subtract total-time anim-start)
last-animated-time (unchecked-subtract animated-time delta-time)
current-frame-index (animation! ^Animation anim :get-key-frame-index
(if anim-loop?
(if anim-loop?
(get-looped-animation-point anim animated-time)
animated-time))
previous-frame-index (animation! ^Animation anim :get-key-frame-index
(if anim-loop?
(get-looped-animation-point anim last-animated-time)
@@ -967,9 +967,9 @@ void main ()
(if (= current-frame-index (:current-frame-index entity) (:previous-frame-index entity))
entity
(merge (assoc entity
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
:current-frame-index current-frame-index
:previous-frame-index previous-frame-index
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
:current-frame-index current-frame-index
:previous-frame-index previous-frame-index
:origin-x (or (-> entity :anim-origins (get anim) (nth 0))
(:base-origin-x entity)
(:origin-x entity))
@@ -993,7 +993,7 @@ void main ()
:active? true
:last-room :dream
:time :intro
:obtained-items #{}
:obtained-items #{}
:inventory []
:plaques-read #{}
:clues #{}
@@ -1005,7 +1005,7 @@ void main ()
(do (music! (utils/get-current-music entities) :set-volume (utils/current-music-volume (get-in entities [:volume :value])))
(utils/play-music (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
(-> entities
(assoc
(assoc
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic
:finish #(if (not (get-in % [:state :seen-intro?]))
(do ((actions/get-script % (rooms.dream/do-intro %)) entities)
@@ -1019,8 +1019,8 @@ void main ()
(defn play-sound-if-necessary [screen entities target {:keys [previous-frame-index current-frame-index anim-sound-frames anim x y] :as e :or {anim-sound-frames {}}}]
(if (and (not= previous-frame-index current-frame-index)
(anim-sound-frames anim))
(if-let [[snd vol-scale pitch] (get-in anim-sound-frames [anim current-frame-index])]
@@ -1032,7 +1032,7 @@ void main ()
(utils/sourced-volume-fn target vol-scale [x y]))]
(utils/play-sound! screen entities
(or (snd e) snd)
vol-scale
vol-scale
(utils/get-sound-pan x)
:once
pitch))
@@ -1040,7 +1040,7 @@ void main ()
entities))
(defn play-key-sounds [screen entities]
(if (= (get-in entities [:fade :opacity]) 0.0)
(if (= (get-in entities [:fade :opacity]) 0.0)
(loop [entities entities
[[target e] & rest] (seq (get-in entities [:room :entities]))]
(if e
@@ -1070,7 +1070,7 @@ void main ()
entities))
(defn render-parallax [{:keys [^OrthographicCamera camera ^Stage renderer ^ShaderProgram shader] :as screen} {:keys [parallax ^float multiply-amount ^float hue-amount] :as e :or {parallax 1.0}}]
(let [tmp (Vector3.)
tmp2 (Vector3.)
original-combined (.cpy (.combined camera))
@@ -1088,20 +1088,20 @@ void main ()
(.up camera))
(.set parallax-combined (.projection camera))
(Matrix4/mul (.val parallax-combined) (.val parallax-view))
(let [^Batch batch (.getBatch renderer)]
(.setProjectionMatrix batch parallax-combined)
(.setShader batch shader)
(when shader
(.setUniformf shader "multiply_amount" (float (or multiply-amount 1.0)))
(.setUniformf shader "hue_amount" (float (or hue-amount 1.0))))
(.setUniformf shader "hue_amount" (float (or hue-amount 1.0))))
(.setColor batch (color (:r e 1.0) (:g e 1.0) (:b e 1.0) (:opacity e 1.0)))
(entities/draw! (assoc e :x (+ (/ ^double (:x e) (.zoom camera))
(- (* 320 p 0.5)
(/ 160 (.zoom camera)) ))
@@ -1119,7 +1119,7 @@ void main ()
(-> e
(merge (-> entities :time-profiles night-profile))
(assoc :time (-> entities :state :time)))
e)
e)
#_(if offset-y
(assoc e :y (+ y offset-y))
e)))
@@ -1150,7 +1150,7 @@ void main ()
(defn add-georgia-to-all-rooms [screen rooms]
(let [georgia-talk (utils/make-anim "ego/georgia.png" [30 30] 0.15 [0 1 0 1 0 0 1 0 1 2])
georgia-stand (utils/make-anim "ego/georgia.png" [30 30] 0.3 [0 0 0 0 0 0 0 2 0 0 0 0 2])
georgia-love (utils/make-anim "ego/in-love.png" [30 30] 0.1 [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 14 14 15 15 15 14 14 14 14 14 14 14 14 15 15 15 15 15 14 14 14 14 15 15 15 15 15 15 14 14 14 14 14])
georgia-love (utils/make-anim "ego/in-love.png" [30 30] 0.1 [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 16 17 18 17 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 14 14 15 15 15 14 14 14 14 14 14 14 14 15 15 15 15 15 14 14 14 14 15 15 15 15 15 15 14 14 14 14 14])
georgia-face (rooms/make-entity :georgia-face
(assoc (animation->texture screen georgia-stand)
@@ -1190,7 +1190,7 @@ void main ()
(set! (. cam zoom) utils/min-zoom)
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader)
_ (log/info "shader log:" (.getLog shader))
state (get-state @utils/selected-save)
state (get-state @utils/selected-save)
start-pos [(:x state) (:y state)]
has-start-pos? (:x state)
@@ -1213,15 +1213,15 @@ void main ()
:outside-castle (rooms.outside-castle/make screen)}
rooms (add-georgia-to-all-rooms screen rooms)
entities {:rooms rooms
:step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241)
:cam {:zoom utils/min-zoom
:step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241)
:cam {:zoom utils/min-zoom
:ideal-x 160
:ideal-y 120
:x 160
:y 120
:paused? false
:object nil}
:current-sounds {:object nil
:value []}
:action-icon {}
@@ -1237,7 +1237,7 @@ void main ()
:dream (utils/make-music "dream/music.ogg")
:secret-hideout (utils/make-music "music/secret-hideout.ogg")
:wind (utils/make-music "music/wind.ogg")}
:state state
:state state
:time-profiles {:object nil
:default utils/default-night-merge
:sprite utils/default-night-merge-sprite
@@ -1246,12 +1246,12 @@ void main ()
:closing? {:object nil
:value false}
:sounds {:blink (utils/load-sound "ego/blink2.ogg")
:pickup (utils/load-sound "pickup.ogg")
:pickup (utils/load-sound "pickup.ogg")
:disappear (utils/load-sound "inside-house/disappear.ogg")
:grow-sound (utils/load-sound "ego/potion.ogg")
:object nil}
:fade {:object nil
:opacity 0.0}
:opacity 0.0}
:white-fade (assoc (utils/get-texture "white.png")
:scale-x 30
:scale-y 30
@@ -1283,11 +1283,11 @@ void main ()
:last-pos [0 0]
:offset [0 0 ]
:down-target nil}
:all-items (assoc items/items :object nil)
:started? {:value false
:object nil}
:room (as-> (get rooms (:last-room state)) room
:room (as-> (get rooms (:last-room state)) room
(assoc-in room [:entities :ego] (get-ego screen (if has-start-pos?
start-pos
(:start-pos room))
@@ -1297,8 +1297,8 @@ void main ()
(:start-pos room))))))}]
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
(add-timer! screen k start time))
(add-timer! screen k start time))
(log/info "[done] Initializing scene.")
(if-let [apply-state (get-in entities [:room :apply-state])]
@@ -1338,9 +1338,9 @@ void main ()
(when (get-in entities [:state :active?])
(-> entities
(remove-cam-tweens)
(update-in [:cam] dissoc :start-zoom))))
(update-in [:cam] dissoc :start-zoom))))
:on-pinch
:on-pinch
(fn [screen entities {:keys [initial-pointer-1 initial-pointer-2]}]
(when (get-in entities [:state :active?])
(let [[pointer-1-x pointer-1-y] (utils/unproject screen nil [(.x initial-pointer-1) (.y initial-pointer-1)])
@@ -1349,14 +1349,14 @@ void main ()
(remove-cam-tweens)
(assoc-in [:cursor :last-pos] [0 0])
(assoc-in [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))))))
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))))))
:on-zoom
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
(when (get-in entities [:state :active?])
(let [start-zoom (get-in entities [:cam :start-zoom])
zoom (get-in entities [:cam :zoom])
entities (as-> entities entities
entities (as-> entities entities
(if (not start-zoom)
(assoc-in entities [:cam :start-zoom] zoom)
entities)
@@ -1371,14 +1371,14 @@ void main ()
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]
(update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 10.0 )))))
:on-render
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} {{:keys [last-pos ] [cursor-offset-x cursor-offset-y] :offset} :cursor :keys [tweens] :as entities} options]
(steam/update)
(.apply viewport)
(if (get-in entities [:closing? :value])
(let [entities (utils/apply-tweens screen entities tweens)
entities (update-current-sound-vols! entities)
entities (remove-ended-sounds screen entities)
@@ -1395,7 +1395,7 @@ void main ()
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
(clear!)
(doseq [e (sort-by :baseline all-entities)]
(if (:parallax e)
@@ -1422,7 +1422,7 @@ void main ()
(actions/pan-to screen entities
(get-in entities [:room :entities :ego :x])
(get-in entities [:room :entities :ego :y])
(constantly (get-in entities [:room :entities :ego :scale-x]))
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0)
(actions/pan-to screen entities
@@ -1430,18 +1430,18 @@ void main ()
(- 10 ^double (rand-int 20)))
(+ ^double (get-in entities [:cam :y] 0)
(- 10 ^double (rand-int 20)))
(constantly (get-in entities [:room :entities :ego :scale-x]))
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0))
5.0))
entities)
entities (grab-layers entities)
update-room (fn [{:keys [anim update-fn] :as e}]
(let [e (if (:anim e)
(animate e screen)
e)
e (if update-fn
(update-fn screen (get-in entities [:room :entities]) e)
e)
@@ -1463,8 +1463,8 @@ void main ()
cursor-offset-x)
:y (unchecked-add (unchecked-subtract last-pos-y 16 )
cursor-offset-y)})
(clear!)
(clear!)
(screen! talking-screen :on-update-camera { :scene-viewport (:viewport screen) :scene-camera (:camera screen)})
(screen! fade-screen :update-fade { :opacity (get-in entities [:fade :opacity])})
(when true #_(not (get-in entities [:cam :paused?]))
@@ -1476,15 +1476,15 @@ void main ()
(utils/update-override screen entities options))
entities (play-key-sounds screen entities)
entities (update-current-sound-vols! entities)
entities (remove-ended-sounds screen entities)]
entities (remove-ended-sounds screen entities)]
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
(doseq [e (doall (sort-by :baseline all-entities))]
(if (:parallax e)
(render-parallax screen e)
(render! screen [e])))
(render! screen [e])))
entities))))
:on-resize (fn [{:keys [^FitViewport viewport]} entities {:keys [width height]}]
@@ -1498,13 +1498,13 @@ void main ()
:on-mouse-moved
mouse-moved
:on-touch-dragged
mouse-moved
:on-touch-down
(fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [input-x input-y] :as options}]
(when (utils/contains-point? (.getScreenX viewport) (.getScreenY viewport)
(.getScreenWidth viewport) (.getScreenHeight viewport)
input-x input-y)
@@ -1564,7 +1564,7 @@ void main ()
:on-menu (fn [{:keys [viewport] :as screen} entities options]
(when-not (or (get-in entities [:tweens :fade-out])
(get-in entities [:tweens :fade-in]))
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
(-> entities
(assoc-in [:closing? :value] true)
@@ -1586,7 +1586,7 @@ void main ()
(defn grow-hud [screen entities target up?]
(let [grow-or-shrink (if up? :grow :shrink)
scale-from (* utils/ui-scale (if up? 1.0 1.1))
scale-to (* utils/ui-scale (if up? 1.1 1.0))
@@ -1611,10 +1611,10 @@ void main ()
(defscreen demo
:on-show
(fn [screen entities options]
(let [screen (assoc screen :total-time 0)]
(let [screen (assoc screen :total-time 0)]
(utils/setup-viewport screen 640 480)
{:label (assoc (label "Demo version - DO NOT COPY" (color :white) ) :y 460 :x 5 :baseline 0 :opacity 0.5)}))
:on-render
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
(.apply viewport)
@@ -1633,7 +1633,7 @@ void main ()
(= 0.0 (get-in scene-entities [:fade :opacity])))))
(defmulti transition-hud (fn [screen entities new-state state-data]
[(get-in entities [:inv-fsm :state]) new-state]))
(defmethod transition-hud :default [screen entities new-state state-data] entities)
@@ -1669,7 +1669,7 @@ void main ()
(assoc :selected-item
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
:origin-x 8
:origin-y 0
:origin-y 0
:scale-x utils/ui-scale
:scale-y utils/ui-scale
:x (- 320 (* utils/ui-scale 12))
@@ -1742,7 +1742,7 @@ void main ()
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
(transition-done? [this screen entities] true))
(appear-transition (or state-data (get-in entities [:inv-fsm :state-data])) :hide :in)
(reify ITransition
(start-transition [this screen entities]
(-> entities
@@ -1758,7 +1758,7 @@ void main ()
[(appear-transition state-data :hide :far-out)
(reify ITransition
(start-transition [this screen entities]
(-> entities
(-> entities
(dissoc :selected-item)))
(transition-done? [this screen entities]
true))]
@@ -1767,7 +1767,7 @@ void main ()
(appear-transition state-data :hide :far-out)
(reify ITransition
(start-transition [this screen entities]
(-> entities
(-> entities
(dissoc :selected-item)))
(transition-done? [this screen entities]
true))])]
@@ -1789,7 +1789,7 @@ void main ()
(animation! (get-in entities [:inventory :anim])
:is-animation-finished
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :out)
(reify ITransition
(start-transition [this screen entities]
@@ -1812,7 +1812,7 @@ void main ()
(animation! (get-in entities [:inventory :anim])
:is-animation-finished
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(reify ITransition
(start-transition [this screen entities]
(-> entities
@@ -1831,7 +1831,7 @@ void main ()
(animation! (get-in entities [:inventory :anim])
:is-animation-finished
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :none)
(reify ITransition
(start-transition [this screen entities]
@@ -1877,12 +1877,12 @@ void main ()
current-transition
nil ;; waiting
(fsm-busy? entities)
(-> (start-transition next-transition screen entities)
(assoc-in [:inv-fsm :current-transition] next-transition)
(assoc-in [:inv-fsm :transition-steps] remaining-transitions))
next-state
(-> (transition-hud screen entities next-state next-state-data)
(assoc-in [:inv-fsm :pending-states] (vec pending-states)))
@@ -1894,24 +1894,24 @@ void main ()
:on-show
(fn [screen entities options]
(let [screen (assoc screen :total-time 0)
screen (utils/setup-viewport screen 320 240)]
screen (utils/setup-viewport screen 320 240)]
{:inv-fsm {:state :none
:state-data {}
:target nil
:target-data nil
:transition-steps []
:pending-states []}
:already-saved? false
:already-saved? false
:close (assoc (utils/get-texture "close.png")
:x 320 :y 240
:origin-x 16 :origin-y 16
:width 16 :height 16
:scale-x utils/ui-scale :scale-y utils/ui-scale
:baseline 9000
:opacity 0.8)
:opacity 0.8)
:save (assoc (utils/get-texture "save.png")
:x (- 320 (* utils/ui-scale 16) 4) :y 240
:origin-x 16 :origin-y 16
@@ -1919,8 +1919,9 @@ void main ()
:baseline 9000
:opacity 0.8)
:inventory (assoc (utils/get-texture "inventory.png") :x (- 320 (* 21 utils/ui-scale)) :y (* 27 utils/ui-scale ) :baseline 9000
:intersect-width 42 :intersect-height 48
:width 42 :height 56
:origin-x 21 :origin-y 27
:origin-x 21 :origin-y 27
:scale-x utils/ui-scale :scale-y utils/ui-scale
:open (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 (flatten [(range 6) 6 7 8 7 ]))
(animation! :set-play-mode (play-mode :normal)))
@@ -1935,7 +1936,7 @@ void main ()
:all-items (texture! (texture (pixmap "cursor.png")) :split 18 16)
#_#_:fps (->> (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)
(utils/add-actor-to-stage screen))}))
:on-render
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
(.apply viewport)
@@ -1962,11 +1963,11 @@ void main ()
(as-> entities entities
(update-in entities [:save] assoc :r 0.75 :g 0.75 :b 0.75)
(grow-hud screen entities :save false)))
entities (or (process-fsm screen entities) entities)]
#_(label! (:fps entities) :set-text (str (game :fps)))
#_(label! (:fps entities) :set-text (str (game :fps)))
(render! screen [ (if (and hud-interactable? (not (:already-saved? entities)))
(:save entities)
@@ -1976,7 +1977,7 @@ void main ()
(:inventory entities)
(assoc (:inventory entities) :opacity 0.5))
(:selected-item entities)
(:close entities)])
(:close entities)])
entities))
:on-resize
@@ -2010,7 +2011,7 @@ void main ()
(if (hud-interactable?)
(-> entities
(update-in [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])]))))
:on-start-script
(fn [_ entities _]
@@ -2033,11 +2034,11 @@ void main ()
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
hovered-close? (utils/intersects? (:close entities) [x y])
hovered-save? (utils/intersects? (:save entities) [x y])]
(screen! scene :hud-active? { :hud-active? (or hovered-close? hovered-inventory? hovered-save?)})))
:on-mouse-moved
(fn [screen entities options]
(let [[x y] (utils/unproject screen options)
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
@@ -2063,23 +2064,23 @@ void main ()
(grow-hud screen entities :selected-item false)
entities)
entities (grow-hud screen entities :close false)
entities (grow-hud screen entities :save false)]
entities (grow-hud screen entities :save false)]
entities
))))
:on-touch-up
(fn [screen entities options]
(if (= (button-code :left) (:button options))
(if (= (button-code :left) (:button options))
(let [[x y] (utils/unproject screen options)]
(cond
(cond
(not (hud-interactable?))
nil
(utils/intersects? (:inventory entities) [x y])
(if (= :selected (get-in entities [:inv-fsm :state]))
(if (= :selected (get-in entities [:inv-fsm :state]))
(update-in entities [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])])
(do