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

@@ -30,7 +30,7 @@
:finish #(assoc % :shown? false)))))
(defn mouse-down [screen entities options]
(let [[x y] (utils/unproject screen options)
(let [[x y] (utils/unproject screen options)
selected-entity (first (filter #((:box %) x y) (vals (:items entities))))]
(assoc entities :selected-item (:item selected-entity)
:down-time (:total-time screen))))
@@ -43,14 +43,14 @@
(defn mouse-drag [screen {:keys [selected-item] :as entities} options]
(when (interactable? entities)
(let [[x y] (utils/unproject screen options)
(let [[x y] (utils/unproject screen options)
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
(cond
(cond
(and selected-item (mouse-outside-inventory? [x y]))
(close screen entities false true)
selected-item
(-> entities
(-> entities
(assoc-in [:items selected-item :x] (- x 32))
(assoc-in [:items selected-item :y] (- y 32))
(assoc :dragged? true)
@@ -60,7 +60,7 @@
(defn mouse-move [screen entities options]
(let [[x y] (utils/unproject screen options)
(let [[x y] (utils/unproject screen options)
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
(assoc entities :hovered-item (:item hovered-entity))))
@@ -97,7 +97,7 @@
)
ego (get-in room-entities [:room :entities :ego])]
(when selected-item
(((:get-script ego) selected-item [0 0]) room-entities)
(((:get-script ego) selected-item [0 0]) room-entities)
(close screen entities true false))))
(defn update-hovered-text [screen {:keys [hovered-text hovered-item selected-item] :as entities}]
@@ -121,7 +121,7 @@
{:overlay (assoc (utils/get-texture "inventory-overlay.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :opacity 0.0)
:fade (assoc (utils/get-texture "black.png")
:scale-x 80
:scale-y 80
:scale-y 80
:opacity 0.7
:origin-x 0
:origin-y 0)
@@ -130,7 +130,7 @@
:shown? false
:hovered-item nil
:opacity 0.0
:tweens {}
:tweens {}
:hovered-text hovered-text}))
:on-render
@@ -146,15 +146,15 @@
(reduce-kv (fn [c k i]
(assoc c k (assoc i :opacity opacity)))
items items))))]
(when shown?
items items))))]
(when shown?
(doto (:hovered-text entities)
(label! :set-color (color 1 1 1 opacity)))
(render! screen [(:fade entities) (:overlay entities)])
(render! screen (vals (:items entities)))
(update-hovered-text screen entities)
(render! screen [(:hovered-text entities)]))
entities))
@@ -165,25 +165,26 @@
(assoc :shown? true
:opacity 0.0
:items (into {} (for [[item index] (map vector items (range))
:let [row (int (/ index 8))
column (mod index 8)
:let [row (int (/ index (Math/floor (/ 8 utils/ui-scale))))
column (mod index (Math/floor (/ 8 utils/ui-scale)))
base-x (* 79 4)
base-y (* 180 4)
x (+ base-x (* column (* 24 4)))
y (- base-y (* row (* 24 4)))
item-width 18
item-width (* utils/ui-scale 4 18)
padding (/ item-width 4)
x (+ base-x (* column (+ padding item-width)))
y (- base-y (* row (+ padding item-width)))
offset-x (+ x (/ item-width 2))
offset-y (+ y (/ item-width 2))
padding (/ item-width 2)
padding (* 4 padding)]]
padded-size (/ (+ item-width padding padding) 2)
#_#_padding (* 4 padding)]]
[item (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
:x x :y y
:scale-x 4
:scale-y 4
:origin-x 0
:origin-y 0
:item item
:box (zone/box (- offset-x padding) (- offset-y padding) (+ offset-x item-width padding padding) (+ offset-y item-width padding padding)))])))
:x (+ x (/ padding 2)) :y (+ y (/ padding 2))
:scale-x (* utils/ui-scale 4)
:scale-y (* utils/ui-scale 4)
:origin-x 9
:origin-y 8
:item item
:box (zone/box (- x padded-size) (- y padded-size) (+ x padded-size) (+ y (/ item-width 2))))])))
(assoc-in [:tweens :fade-in] (tween/tween :fade-in screen [:opacity] 0.0 1.0 0.2 :ease tween/ease-out-cubic)))))
:on-mouse-moved mouse-move

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

View File

@@ -146,7 +146,7 @@
(Pixmap/setFilter Pixmap$Filter/NearestNeighbour)
(pixmap! resized :draw-pixmap base-cursor (* index 18) 0 16 16
0 0 target-width target-height)
(graphics! :new-cursor resized (* hot-x scale) (* hot-y scale) )))
(defn get-texture [path]
@@ -195,12 +195,12 @@
(first (drop-while #{:fail}
(repeatedly times
#(try (fn)
(catch Exception e
(catch Exception e
(log/error "Could not save!" e)
:fail))))))
(defn save [entities id name & [blurb]]
(let [save-fn (fn []
(let [save-fn (fn []
(log/info "Saving " id name)
(let [save {:name name
:id id
@@ -209,7 +209,7 @@
:x (get-in entities [:room :entities :ego :x])
:y (get-in entities [:room :entities :ego :y]))
:blurb (or blurb name)}]
(steam/write-bytes (steam/save-file-name id) (.getBytes (pr-str save) "UTF-8"))
(on-gl (let [gl-func (fn []
(let [_ (Pixmap/setFilter Pixmap$Filter/BiLinear)
@@ -244,7 +244,7 @@
(defn get-font [filename]
(let [font (-> (bitmap-font filename)
#_(doto (bitmap-font! :set-scale 0.5 0.5)))
#_(doto (bitmap-font! :set-scale 0.5 0.5)))
tr (bitmap-font! font :get-region)
tx (.getTexture tr)]
(call! ^Texture tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
@@ -357,7 +357,7 @@
(defn find-override [entities [x y]]
(first (concat (filter #(and ((:mouse-in? %) entities x y)
(:override %))
(get-in entities [:room :interactions]))
(filter #(and (:mouse-in? %)
@@ -390,7 +390,7 @@
(doto (music (str r ".mp3")) (music! :set-looping true)))))
(defn load-sound [f]
(try
(try
(sound f)
(catch Exception e
(log/info e)
@@ -406,13 +406,13 @@
(defn intersects? [e [x y]]
(when (:object e)
(let [object-width (* (:scale-x e 1.0) (or (:width e) (when (actor? e ) (.getWidth ^Actor (:object e))) 0))
object-height (* (:scale-y e 1.0) (or (:height e) (when (actor? e ) (.getHeight ^Actor (:object e))) 0))
(let [object-width (* (:scale-x e 1.0) (or (:intersect-width e) (:width e) (when (actor? e ) (.getWidth ^Actor (:object e))) 0))
object-height (* (:scale-y e 1.0) (or (:intersect-height e) (:height e) (when (actor? e ) (.getHeight ^Actor (:object e))) 0))
origin-x (* (:scale-x e 1.0) (:origin-x e 0))
origin-y (* (:scale-y e 1.0) (:origin-y e 0))
object-x (- (or (:x e) (when (actor? e ) (.getX ^Actor (:object e))) 0) origin-x)
object-y (- (or (:y e) (when (actor? e ) (.getY ^Actor (:object e))) 0) origin-y)]
(and (:object e)
(< object-x x (+ object-x object-width))
(< object-y y (+ object-y object-height))))))
@@ -434,7 +434,7 @@
(.apply viewport)
(assoc screen :renderer stage :viewport viewport :camera cam)))
(defn unproject
(defn unproject
([screen options]
(unproject screen options [(:input-x options) (:input-y options)]) )
([screen options [x y]]
@@ -443,7 +443,7 @@
y (.y pj)]
[x y])))
(defn project
(defn project
([screen [x y]]
(let [pj (.project ^FitViewport (:viewport screen) (vector-2 x y))
x (.x pj)
@@ -470,12 +470,12 @@
hovering-ego (hovering-ego entities last-pos)
current (get-in entities [:cursor :current])
entities (assoc-in entities [:label :text] "")
selected-inventory-item (@(resolve 'advent.screens.scene/get-selected-inventory-item))]
selected-inventory-item (@(resolve 'advent.screens.scene/get-selected-inventory-item))]
(cond
out-of-bounds
(update-in entities [:cursor] assoc :override nil :active false )
(not (get-in entities [:state :active?]))
(-> entities
@@ -526,9 +526,9 @@
(defn fast-forward-particle [p]
(particle-effect! p :reset)
(particle-effect! p :start)
(particle-effect! p :start)
(particle-effect! p :update 10.0)
(particle-effect! p :update 10.0)
(dotimes [_ 160]
(particle-effect! p :update 0.2)))
@@ -633,7 +633,7 @@
(play-sound! screen entities snd volume-fn pan type 1.0))
([screen entities snd volume-fn pan type pitch]
(let [vol (volume-fn entities)
snd (if (keyword? snd)
(or (-> entities :room :sounds snd)