improving inventory item scales.
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
:finish #(assoc % :shown? false)))))
|
:finish #(assoc % :shown? false)))))
|
||||||
|
|
||||||
(defn mouse-down [screen entities options]
|
(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))))]
|
selected-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||||
(assoc entities :selected-item (:item selected-entity)
|
(assoc entities :selected-item (:item selected-entity)
|
||||||
:down-time (:total-time screen))))
|
:down-time (:total-time screen))))
|
||||||
@@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
(defn mouse-drag [screen {:keys [selected-item] :as entities} options]
|
(defn mouse-drag [screen {:keys [selected-item] :as entities} options]
|
||||||
(when (interactable? entities)
|
(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))))]
|
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||||
(cond
|
(cond
|
||||||
(and selected-item (mouse-outside-inventory? [x y]))
|
(and selected-item (mouse-outside-inventory? [x y]))
|
||||||
(close screen entities false true)
|
(close screen entities false true)
|
||||||
|
|
||||||
selected-item
|
selected-item
|
||||||
(-> entities
|
(-> entities
|
||||||
(assoc-in [:items selected-item :x] (- x 32))
|
(assoc-in [:items selected-item :x] (- x 32))
|
||||||
(assoc-in [:items selected-item :y] (- y 32))
|
(assoc-in [:items selected-item :y] (- y 32))
|
||||||
(assoc :dragged? true)
|
(assoc :dragged? true)
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn mouse-move [screen entities options]
|
(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))))]
|
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||||
(assoc entities :hovered-item (:item hovered-entity))))
|
(assoc entities :hovered-item (:item hovered-entity))))
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
)
|
)
|
||||||
ego (get-in room-entities [:room :entities :ego])]
|
ego (get-in room-entities [:room :entities :ego])]
|
||||||
(when selected-item
|
(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))))
|
(close screen entities true false))))
|
||||||
|
|
||||||
(defn update-hovered-text [screen {:keys [hovered-text hovered-item selected-item] :as entities}]
|
(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)
|
{: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")
|
:fade (assoc (utils/get-texture "black.png")
|
||||||
:scale-x 80
|
:scale-x 80
|
||||||
:scale-y 80
|
:scale-y 80
|
||||||
:opacity 0.7
|
:opacity 0.7
|
||||||
:origin-x 0
|
:origin-x 0
|
||||||
:origin-y 0)
|
:origin-y 0)
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
:shown? false
|
:shown? false
|
||||||
:hovered-item nil
|
:hovered-item nil
|
||||||
:opacity 0.0
|
:opacity 0.0
|
||||||
:tweens {}
|
:tweens {}
|
||||||
:hovered-text hovered-text}))
|
:hovered-text hovered-text}))
|
||||||
|
|
||||||
:on-render
|
:on-render
|
||||||
@@ -146,15 +146,15 @@
|
|||||||
(reduce-kv (fn [c k i]
|
(reduce-kv (fn [c k i]
|
||||||
(assoc c k (assoc i :opacity opacity)))
|
(assoc c k (assoc i :opacity opacity)))
|
||||||
|
|
||||||
items items))))]
|
items items))))]
|
||||||
|
|
||||||
(when shown?
|
(when shown?
|
||||||
(doto (:hovered-text entities)
|
(doto (:hovered-text entities)
|
||||||
(label! :set-color (color 1 1 1 opacity)))
|
(label! :set-color (color 1 1 1 opacity)))
|
||||||
(render! screen [(:fade entities) (:overlay entities)])
|
(render! screen [(:fade entities) (:overlay entities)])
|
||||||
(render! screen (vals (:items entities)))
|
(render! screen (vals (:items entities)))
|
||||||
(update-hovered-text screen entities)
|
(update-hovered-text screen entities)
|
||||||
|
|
||||||
(render! screen [(:hovered-text entities)]))
|
(render! screen [(:hovered-text entities)]))
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
@@ -165,25 +165,26 @@
|
|||||||
(assoc :shown? true
|
(assoc :shown? true
|
||||||
:opacity 0.0
|
:opacity 0.0
|
||||||
:items (into {} (for [[item index] (map vector items (range))
|
:items (into {} (for [[item index] (map vector items (range))
|
||||||
:let [row (int (/ index 8))
|
:let [row (int (/ index (Math/floor (/ 8 utils/ui-scale))))
|
||||||
column (mod index 8)
|
column (mod index (Math/floor (/ 8 utils/ui-scale)))
|
||||||
base-x (* 79 4)
|
base-x (* 79 4)
|
||||||
base-y (* 180 4)
|
base-y (* 180 4)
|
||||||
x (+ base-x (* column (* 24 4)))
|
item-width (* utils/ui-scale 4 18)
|
||||||
y (- base-y (* row (* 24 4)))
|
padding (/ item-width 4)
|
||||||
item-width 18
|
x (+ base-x (* column (+ padding item-width)))
|
||||||
|
y (- base-y (* row (+ padding item-width)))
|
||||||
offset-x (+ x (/ item-width 2))
|
offset-x (+ x (/ item-width 2))
|
||||||
offset-y (+ y (/ item-width 2))
|
offset-y (+ y (/ item-width 2))
|
||||||
padding (/ item-width 2)
|
padded-size (/ (+ item-width padding padding) 2)
|
||||||
padding (* 4 padding)]]
|
#_#_padding (* 4 padding)]]
|
||||||
[item (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
[item (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||||
:x x :y y
|
:x (+ x (/ padding 2)) :y (+ y (/ padding 2))
|
||||||
:scale-x 4
|
:scale-x (* utils/ui-scale 4)
|
||||||
:scale-y 4
|
:scale-y (* utils/ui-scale 4)
|
||||||
:origin-x 0
|
:origin-x 9
|
||||||
:origin-y 0
|
:origin-y 8
|
||||||
:item item
|
:item item
|
||||||
:box (zone/box (- offset-x padding) (- offset-y padding) (+ offset-x item-width padding padding) (+ offset-y item-width padding padding)))])))
|
: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)))))
|
(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
|
:on-mouse-moved mouse-move
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ void main ()
|
|||||||
(do (put! (actions/get-channel current-action) terminated-entities)
|
(do (put! (actions/get-channel current-action) terminated-entities)
|
||||||
(-> terminated-entities
|
(-> terminated-entities
|
||||||
(assoc-in [:fg-actions :current] nil)
|
(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))
|
(= :end (actions/skip-type current-action screen entities))
|
||||||
(let [terminated-entities (actions/terminate 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)
|
interacting-entity (get-interacting-entity entities x y)
|
||||||
current-action (get-in entities [:fg-actions :current])
|
current-action (get-in entities [:fg-actions :current])
|
||||||
;; TODO - hacky way of resetting queue
|
;; TODO - hacky way of resetting queue
|
||||||
|
|
||||||
entities (if current-action
|
entities (if current-action
|
||||||
(skip-action screen entities)
|
(skip-action screen entities)
|
||||||
entities)]
|
entities)]
|
||||||
|
|
||||||
|
|
||||||
(when (and (not (get-in entities [:fg-actions :script-running?]))
|
(when (and (not (get-in entities [:fg-actions :script-running?]))
|
||||||
(or (= (get-in entities [:cursor :down-target])
|
(or (= (get-in entities [:cursor :down-target])
|
||||||
(or (:id interacting-entity) (:id interaction) nil))
|
(or (:id interacting-entity) (:id interaction) nil))
|
||||||
@@ -273,11 +273,11 @@ void main ()
|
|||||||
(do (screen! hud :on-start-script {})
|
(do (screen! hud :on-start-script {})
|
||||||
((:get-script interaction) (get-script-selector entities)
|
((:get-script interaction) (get-script-selector entities)
|
||||||
[x y])))
|
[x y])))
|
||||||
|
|
||||||
((:get-script default-interaction) (get-script-selector entities) [x y])) entities))
|
((:get-script default-interaction) (get-script-selector entities) [x y])) entities))
|
||||||
(cond-> entities
|
(cond-> entities
|
||||||
true (assoc-in [:cursor :down-target] nil)
|
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}]
|
(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)]
|
(let [entities (assoc-in entities [:cursor :depressed?] false)]
|
||||||
@@ -288,10 +288,10 @@ void main ()
|
|||||||
entities
|
entities
|
||||||
|
|
||||||
(= (button-code :right)
|
(= (button-code :right)
|
||||||
(:button options))
|
(:button options))
|
||||||
(do (screen! hud :on-return-item {})
|
(do (screen! hud :on-return-item {})
|
||||||
entities)
|
entities)
|
||||||
|
|
||||||
(and (get-in entities [:state :active?])
|
(and (get-in entities [:state :active?])
|
||||||
(or (not (get-in entities [:state :hud-active?]))
|
(or (not (get-in entities [:state :hud-active?]))
|
||||||
(get-in entities [:fg-actions :script-running?]))
|
(get-in entities [:fg-actions :script-running?]))
|
||||||
@@ -302,7 +302,7 @@ void main ()
|
|||||||
entities)))
|
entities)))
|
||||||
|
|
||||||
(defn get-ego-script [cursor [x y]]
|
(defn get-ego-script [cursor [x y]]
|
||||||
|
|
||||||
(condp = (:value cursor)
|
(condp = (:value cursor)
|
||||||
:charcoal
|
:charcoal
|
||||||
(common/one-liner "Just a dark piece of 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!"))
|
(actions/get-script entities (actions/talk entities :ego "Blegh! Gross!"))
|
||||||
|
|
||||||
:flask-1-strength
|
:flask-1-strength
|
||||||
(actions/get-script entities
|
(actions/get-script entities
|
||||||
(cond (= :held
|
(cond (= :held
|
||||||
(get-in @entities [:state :last-room]))
|
(get-in @entities [:state :last-room]))
|
||||||
(common/do-win entities)
|
(common/do-win entities)
|
||||||
@@ -329,7 +329,7 @@ void main ()
|
|||||||
(Thread/sleep 1000)
|
(Thread/sleep 1000)
|
||||||
(actions/talk entities :warden "Hey, get back in jail!")
|
(actions/talk entities :warden "Hey, get back in jail!")
|
||||||
(common/go-to-jail entities))
|
(common/go-to-jail entities))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(do
|
(do
|
||||||
(actions/talk entities :ego "I'd better save this strength potion for just the right moment!"))))
|
(actions/talk entities :ego "I'd better save this strength potion for just the right moment!"))))
|
||||||
@@ -391,7 +391,7 @@ void main ()
|
|||||||
(do
|
(do
|
||||||
(actions/talk entities :ego "Ugh! I have Gandarf's MagiSafe 2000 tune stuck in my head.")
|
(actions/talk entities :ego "Ugh! I have Gandarf's MagiSafe 2000 tune stuck in my head.")
|
||||||
(actions/play-safe entities))))
|
(actions/play-safe entities))))
|
||||||
|
|
||||||
:alarm-clock
|
:alarm-clock
|
||||||
(common/one-liner "It's a magic device that tells the time.")
|
(common/one-liner "It's a magic device that tells the time.")
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ void main ()
|
|||||||
(actions/do-dialogue entities :ego "Yuck!"))
|
(actions/do-dialogue entities :ego "Yuck!"))
|
||||||
|
|
||||||
:stick
|
:stick
|
||||||
(common/one-liner "It's a huge stick.")
|
(common/one-liner "It's a huge stick.")
|
||||||
|
|
||||||
:wool
|
:wool
|
||||||
(common/one-liner "Better not wash it in hot water.")
|
(common/one-liner "Better not wash it in hot water.")
|
||||||
@@ -415,127 +415,127 @@ void main ()
|
|||||||
:spell-component
|
:spell-component
|
||||||
(common/one-liner "It needs to go into the cauldron.")
|
(common/one-liner "It needs to go into the cauldron.")
|
||||||
|
|
||||||
:feather
|
:feather
|
||||||
(common/one-liner "An owl feather. Smells like puke.")
|
(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.")
|
(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.")
|
(common/one-liner "Gandarf knows what to do next with this.")
|
||||||
|
|
||||||
:broom
|
:broom
|
||||||
(common/one-liner "A janitor's broom.")
|
(common/one-liner "A janitor's broom.")
|
||||||
|
|
||||||
:glass-eye
|
:glass-eye
|
||||||
(common/one-liner "It's a 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.")
|
(common/one-liner "It's got some bull slobber in it.")
|
||||||
|
|
||||||
:crowbar
|
:crowbar
|
||||||
(common/one-liner "It can probably bend steel!")
|
(common/one-liner "It can probably bend steel!")
|
||||||
|
|
||||||
:monocle
|
:monocle
|
||||||
(common/one-liner "It's a monocle.")
|
(common/one-liner "It's a monocle.")
|
||||||
|
|
||||||
:used-earplugs
|
:used-earplugs
|
||||||
(common/one-liner "They've got earwax all over them. No thanks.")
|
(common/one-liner "They've got earwax all over them. No thanks.")
|
||||||
|
|
||||||
:broken-clock
|
:broken-clock
|
||||||
(common/one-liner "Split right down the middle.")
|
(common/one-liner "Split right down the middle.")
|
||||||
|
|
||||||
:trophy
|
:trophy
|
||||||
(common/one-liner "I've proven myself in wisdom!")
|
(common/one-liner "I've proven myself in wisdom!")
|
||||||
|
|
||||||
:carrot
|
:carrot
|
||||||
(common/one-liner "I'm not that hungry.")
|
(common/one-liner "I'm not that hungry.")
|
||||||
|
|
||||||
:ladder
|
:ladder
|
||||||
(common/one-liner "It's the Duke's 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.")
|
(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.")
|
(common/one-liner "Ugh, gross! The blue cheese smells really strong.")
|
||||||
|
|
||||||
:grass
|
:grass
|
||||||
(common/one-liner "This is top quality, high protein stuff!")
|
(common/one-liner "This is top quality, high protein stuff!")
|
||||||
|
|
||||||
:cat-toy
|
:cat-toy
|
||||||
(common/one-liner "It's a little cat toy!")
|
(common/one-liner "It's a little cat toy!")
|
||||||
|
|
||||||
:ash
|
:ash
|
||||||
(common/one-liner "A spell's ashes.")
|
(common/one-liner "A spell's ashes.")
|
||||||
|
|
||||||
:shovel
|
:shovel
|
||||||
(common/one-liner "A grave-digger's shovel.")
|
(common/one-liner "A grave-digger's shovel.")
|
||||||
|
|
||||||
:mandrake
|
:mandrake
|
||||||
(common/one-liner "It's some kind of root.")
|
(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.")
|
(common/one-liner "Looks like I need to add the ashes of magic.")
|
||||||
|
|
||||||
:flask-1
|
:flask-1
|
||||||
(common/one-liner "An empty flask.")
|
(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.")
|
(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.")
|
(common/one-liner "The Slinger's Shot, fully restored.")
|
||||||
|
|
||||||
:frog-legs
|
:frog-legs
|
||||||
(common/one-liner "I wonder where the head is...")
|
(common/one-liner "I wonder where the head is...")
|
||||||
|
|
||||||
:sword
|
:sword
|
||||||
(common/one-liner "Yowza! The Sword of Blergh's sharp as a razor.")
|
(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!")
|
(common/one-liner "I've proven myself worthy in strength!")
|
||||||
|
|
||||||
:spear
|
:spear
|
||||||
(common/one-liner "A knight's spear.")
|
(common/one-liner "A knight's spear.")
|
||||||
|
|
||||||
:slobber
|
:slobber
|
||||||
(common/one-liner "I wonder why I am carrying this drool around.")
|
(common/one-liner "I wonder why I am carrying this drool around.")
|
||||||
|
|
||||||
:kiss
|
:kiss
|
||||||
(common/one-liner "Yuck! A kiss for my bravery.")
|
(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.")
|
(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.")
|
(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.")
|
(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.")
|
(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.")
|
(common/one-liner "I need to fill it with fountain water.")
|
||||||
|
|
||||||
:key
|
:key
|
||||||
(common/one-liner "It's the key to the jail.")
|
(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.")
|
(common/one-liner "Looks like I need the sound of buzzing.")
|
||||||
|
|
||||||
:slingshot
|
:slingshot
|
||||||
(common/one-liner "The Slinger's Shot.")
|
(common/one-liner "The Slinger's Shot.")
|
||||||
|
|
||||||
:teddy
|
:teddy
|
||||||
(common/one-liner "It's the choicest teddy.")
|
(common/one-liner "It's the choicest teddy.")
|
||||||
|
|
||||||
:flies
|
:flies
|
||||||
(common/one-liner "I don't want any of them to buzz off.")
|
(common/one-liner "I don't want any of them to buzz off.")
|
||||||
|
|
||||||
:rope
|
:rope
|
||||||
(common/one-liner "A nice, sturdy, rope.")
|
(common/one-liner "A nice, sturdy, rope.")
|
||||||
|
|
||||||
nil))
|
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]]
|
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))))
|
(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]]
|
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]]
|
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))))
|
(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])
|
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))
|
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 ]]))
|
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))
|
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])
|
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])
|
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])
|
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 [: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])))
|
(rand-nth [:step-sound-1 :step-sound-2 :step-sound-3 :step-sound-4])))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ego {:right {:walk walk-right
|
ego {:right {:walk walk-right
|
||||||
:stand stand-anim
|
:stand stand-anim
|
||||||
@@ -691,7 +691,7 @@ void main ()
|
|||||||
:axe-wood axe-wood
|
:axe-wood axe-wood
|
||||||
:suspended suspended
|
:suspended suspended
|
||||||
:suspended-talk suspended-talk
|
:suspended-talk suspended-talk
|
||||||
:crawl crawl
|
:crawl crawl
|
||||||
:crawl-stand crawl-stand
|
:crawl-stand crawl-stand
|
||||||
:crawl-hide crawl-hide
|
:crawl-hide crawl-hide
|
||||||
:standup standup
|
:standup standup
|
||||||
@@ -743,7 +743,7 @@ void main ()
|
|||||||
:axe-wood (utils/flip axe-wood)
|
:axe-wood (utils/flip axe-wood)
|
||||||
:suspended (utils/flip suspended)
|
:suspended (utils/flip suspended)
|
||||||
:suspended-talk (utils/flip suspended-talk)
|
:suspended-talk (utils/flip suspended-talk)
|
||||||
:crawl (utils/flip crawl)
|
:crawl (utils/flip crawl)
|
||||||
:crawl-stand (utils/flip crawl-stand)
|
:crawl-stand (utils/flip crawl-stand)
|
||||||
:crawl-hide (utils/flip crawl-hide)
|
:crawl-hide (utils/flip crawl-hide)
|
||||||
:standup (utils/flip standup)
|
:standup (utils/flip standup)
|
||||||
@@ -753,12 +753,12 @@ void main ()
|
|||||||
:climb (utils/flip climb)
|
:climb (utils/flip climb)
|
||||||
:poke (utils/flip poke)
|
:poke (utils/flip poke)
|
||||||
:whistle (utils/flip whistle)
|
:whistle (utils/flip whistle)
|
||||||
}
|
}
|
||||||
:baseline (- 240 (double (last start-pos)))
|
:baseline (- 240 (double (last start-pos)))
|
||||||
:facing :right
|
:facing :right
|
||||||
:night-profile :sprite
|
:night-profile :sprite
|
||||||
:origin-x 9
|
:origin-x 9
|
||||||
:origin-y 0
|
:origin-y 0
|
||||||
:scaled true
|
:scaled true
|
||||||
:drop-sound (utils/load-sound "ego/drop.ogg")
|
:drop-sound (utils/load-sound "ego/drop.ogg")
|
||||||
:milk-sound (utils/load-sound "outsidehouse/milk.ogg")
|
:milk-sound (utils/load-sound "outsidehouse/milk.ogg")
|
||||||
@@ -784,18 +784,18 @@ void main ()
|
|||||||
:idea-sound (utils/load-sound "ego/idea.ogg")
|
:idea-sound (utils/load-sound "ego/idea.ogg")
|
||||||
:scale-x start-scale
|
:scale-x start-scale
|
||||||
:scale-y 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
|
:stand-override nil
|
||||||
:mouse-in? (fn [entities x y]
|
: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))
|
half-width (double (/ (* (.getRegionWidth region) (double (or scale 1.0))) 2))
|
||||||
height (double (* (.getRegionHeight region) (double (or scale 1.0))))]
|
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)))
|
((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)
|
:x (first start-pos) :y (last start-pos)
|
||||||
:id "ego"}
|
:id "ego"}
|
||||||
|
|
||||||
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [choose-step-sound 0.5]
|
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [choose-step-sound 0.5]
|
||||||
6 [choose-step-sound 0.5]}
|
6 [choose-step-sound 0.5]}
|
||||||
(get-in ego [:right :walk]) {2 [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 :crowbar] ) {3 [:crowbar-sound 0.5]}
|
||||||
(get-in ego [:right :shoot] ) {14 [:shoot-sound 0.75]}
|
(get-in ego [:right :shoot] ) {14 [:shoot-sound 0.75]}
|
||||||
(get-in ego [:left :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 [: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 :get-sick] ) {1 [:get-sick-sound 0.55]}
|
||||||
(get-in ego [:right :scared-walk] ) {0 [:scared-step-sound 0.15 1.5]
|
(get-in ego [:right :scared-walk] ) {0 [:scared-step-sound 0.15 1.5]
|
||||||
4 [:scared-step-sound 0.15 1.9]}
|
4 [:scared-step-sound 0.15 1.9]}
|
||||||
(get-in ego [:left :stand]) {11 [:blink 0.15]
|
(get-in ego [:left :stand]) {11 [:blink 0.15]
|
||||||
44 [:blink 0.15]
|
44 [:blink 0.15]
|
||||||
77 [:blink 0.15]
|
77 [:blink 0.15]
|
||||||
110 [:blink 0.15]
|
110 [:blink 0.15]
|
||||||
143 [:blink 0.15]
|
143 [:blink 0.15]
|
||||||
176 [:blink 0.15]
|
176 [:blink 0.15]
|
||||||
200 [:scratch-sound 0.15]
|
200 [:scratch-sound 0.15]
|
||||||
|
|
||||||
}
|
}
|
||||||
(get-in ego [:right :stand]) {11 [:blink 0.15]
|
(get-in ego [:right :stand]) {11 [:blink 0.15]
|
||||||
44 [:blink 0.15]
|
44 [:blink 0.15]
|
||||||
77 [:blink 0.15]
|
77 [:blink 0.15]
|
||||||
110 [:blink 0.15]
|
110 [:blink 0.15]
|
||||||
143 [:blink 0.15]
|
143 [:blink 0.15]
|
||||||
176 [:blink 0.15]
|
176 [:blink 0.15]
|
||||||
200 [:scratch-sound 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 [:right :axe-wood]) {:origin-x 17}
|
||||||
(get-in ego [:left :love]) {:origin-x 41}
|
(get-in ego [:left :love]) {:origin-x 41}
|
||||||
(get-in ego [:left :suspended]) {:origin-x 0 :origin-y 0}
|
(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 [: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}})]
|
:default {:origin-x 9}})]
|
||||||
(actions/start-animation screen
|
(actions/start-animation screen
|
||||||
(merge (animation->texture screen (:stand (:right ego))) ego)
|
(merge (animation->texture screen (:stand (:right ego))) ego)
|
||||||
@@ -884,13 +884,13 @@ void main ()
|
|||||||
(do
|
(do
|
||||||
(next-script entities)
|
(next-script entities)
|
||||||
(log/info "starting script")
|
(log/info "starting script")
|
||||||
|
|
||||||
(assoc-in entities [key :script-running?] true))
|
(assoc-in entities [key :script-running?] true))
|
||||||
entities)))))
|
entities)))))
|
||||||
|
|
||||||
(defn update-from-script [screen entities key]
|
(defn update-from-script [screen entities key]
|
||||||
(let [{{:keys [current started? channel script-chan script-running?]} key} entities]
|
(let [{{:keys [current started? channel script-chan script-running?]} key} entities]
|
||||||
|
|
||||||
(if current
|
(if current
|
||||||
(let [entities (if started? entities (actions/begin current screen entities))
|
(let [entities (if started? entities (actions/begin current screen entities))
|
||||||
entities (actions/continue current screen entities)]
|
entities (actions/continue current screen entities)]
|
||||||
@@ -902,7 +902,7 @@ void main ()
|
|||||||
key))
|
key))
|
||||||
(assoc-in entities [key :started?] true)))
|
(assoc-in entities [key :started?] true)))
|
||||||
(let [current (poll! channel)]
|
(let [current (poll! channel)]
|
||||||
|
|
||||||
(-> entities
|
(-> entities
|
||||||
(assoc-in [key :started?] false)
|
(assoc-in [key :started?] false)
|
||||||
(assoc-in [key :last-skip-type] (if current
|
(assoc-in [key :last-skip-type] (if current
|
||||||
@@ -926,7 +926,7 @@ void main ()
|
|||||||
total-time (double total-time)]
|
total-time (double total-time)]
|
||||||
(cond
|
(cond
|
||||||
(not= 0.0 (get-in entities [:fade :opacity]))
|
(not= 0.0 (get-in entities [:fade :opacity]))
|
||||||
entities
|
entities
|
||||||
|
|
||||||
(< (unchecked-subtract total-time time-changed) 0.15)
|
(< (unchecked-subtract total-time time-changed) 0.15)
|
||||||
entities
|
entities
|
||||||
@@ -956,10 +956,10 @@ void main ()
|
|||||||
animated-time (unchecked-subtract total-time anim-start)
|
animated-time (unchecked-subtract total-time anim-start)
|
||||||
last-animated-time (unchecked-subtract animated-time delta-time)
|
last-animated-time (unchecked-subtract animated-time delta-time)
|
||||||
current-frame-index (animation! ^Animation anim :get-key-frame-index
|
current-frame-index (animation! ^Animation anim :get-key-frame-index
|
||||||
(if anim-loop?
|
(if anim-loop?
|
||||||
(get-looped-animation-point anim animated-time)
|
(get-looped-animation-point anim animated-time)
|
||||||
animated-time))
|
animated-time))
|
||||||
|
|
||||||
previous-frame-index (animation! ^Animation anim :get-key-frame-index
|
previous-frame-index (animation! ^Animation anim :get-key-frame-index
|
||||||
(if anim-loop?
|
(if anim-loop?
|
||||||
(get-looped-animation-point anim last-animated-time)
|
(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))
|
(if (= current-frame-index (:current-frame-index entity) (:previous-frame-index entity))
|
||||||
entity
|
entity
|
||||||
(merge (assoc entity
|
(merge (assoc entity
|
||||||
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
|
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
|
||||||
:current-frame-index current-frame-index
|
:current-frame-index current-frame-index
|
||||||
:previous-frame-index previous-frame-index
|
:previous-frame-index previous-frame-index
|
||||||
:origin-x (or (-> entity :anim-origins (get anim) (nth 0))
|
:origin-x (or (-> entity :anim-origins (get anim) (nth 0))
|
||||||
(:base-origin-x entity)
|
(:base-origin-x entity)
|
||||||
(:origin-x entity))
|
(:origin-x entity))
|
||||||
@@ -993,7 +993,7 @@ void main ()
|
|||||||
:active? true
|
:active? true
|
||||||
:last-room :dream
|
:last-room :dream
|
||||||
:time :intro
|
:time :intro
|
||||||
:obtained-items #{}
|
:obtained-items #{}
|
||||||
:inventory []
|
:inventory []
|
||||||
:plaques-read #{}
|
:plaques-read #{}
|
||||||
:clues #{}
|
: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])))
|
(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]))]))
|
(utils/play-music (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
||||||
(-> entities
|
(-> entities
|
||||||
(assoc
|
(assoc
|
||||||
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic
|
: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?]))
|
:finish #(if (not (get-in % [:state :seen-intro?]))
|
||||||
(do ((actions/get-script % (rooms.dream/do-intro %)) entities)
|
(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 {}}}]
|
(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)
|
(if (and (not= previous-frame-index current-frame-index)
|
||||||
(anim-sound-frames anim))
|
(anim-sound-frames anim))
|
||||||
(if-let [[snd vol-scale pitch] (get-in anim-sound-frames [anim current-frame-index])]
|
(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/sourced-volume-fn target vol-scale [x y]))]
|
||||||
(utils/play-sound! screen entities
|
(utils/play-sound! screen entities
|
||||||
(or (snd e) snd)
|
(or (snd e) snd)
|
||||||
vol-scale
|
vol-scale
|
||||||
(utils/get-sound-pan x)
|
(utils/get-sound-pan x)
|
||||||
:once
|
:once
|
||||||
pitch))
|
pitch))
|
||||||
@@ -1040,7 +1040,7 @@ void main ()
|
|||||||
entities))
|
entities))
|
||||||
|
|
||||||
(defn play-key-sounds [screen 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
|
(loop [entities entities
|
||||||
[[target e] & rest] (seq (get-in entities [:room :entities]))]
|
[[target e] & rest] (seq (get-in entities [:room :entities]))]
|
||||||
(if e
|
(if e
|
||||||
@@ -1070,7 +1070,7 @@ void main ()
|
|||||||
entities))
|
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}}]
|
(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.)
|
(let [tmp (Vector3.)
|
||||||
tmp2 (Vector3.)
|
tmp2 (Vector3.)
|
||||||
original-combined (.cpy (.combined camera))
|
original-combined (.cpy (.combined camera))
|
||||||
@@ -1088,20 +1088,20 @@ void main ()
|
|||||||
(.up camera))
|
(.up camera))
|
||||||
(.set parallax-combined (.projection camera))
|
(.set parallax-combined (.projection camera))
|
||||||
(Matrix4/mul (.val parallax-combined) (.val parallax-view))
|
(Matrix4/mul (.val parallax-combined) (.val parallax-view))
|
||||||
|
|
||||||
|
|
||||||
(let [^Batch batch (.getBatch renderer)]
|
(let [^Batch batch (.getBatch renderer)]
|
||||||
|
|
||||||
|
|
||||||
(.setProjectionMatrix batch parallax-combined)
|
(.setProjectionMatrix batch parallax-combined)
|
||||||
(.setShader batch shader)
|
(.setShader batch shader)
|
||||||
(when shader
|
(when shader
|
||||||
(.setUniformf shader "multiply_amount" (float (or multiply-amount 1.0)))
|
(.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)))
|
(.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))
|
(entities/draw! (assoc e :x (+ (/ ^double (:x e) (.zoom camera))
|
||||||
(- (* 320 p 0.5)
|
(- (* 320 p 0.5)
|
||||||
(/ 160 (.zoom camera)) ))
|
(/ 160 (.zoom camera)) ))
|
||||||
@@ -1119,7 +1119,7 @@ void main ()
|
|||||||
(-> e
|
(-> e
|
||||||
(merge (-> entities :time-profiles night-profile))
|
(merge (-> entities :time-profiles night-profile))
|
||||||
(assoc :time (-> entities :state :time)))
|
(assoc :time (-> entities :state :time)))
|
||||||
e)
|
e)
|
||||||
#_(if offset-y
|
#_(if offset-y
|
||||||
(assoc e :y (+ y offset-y))
|
(assoc e :y (+ y offset-y))
|
||||||
e)))
|
e)))
|
||||||
@@ -1150,7 +1150,7 @@ void main ()
|
|||||||
(defn add-georgia-to-all-rooms [screen rooms]
|
(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])
|
(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-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
|
georgia-face (rooms/make-entity :georgia-face
|
||||||
(assoc (animation->texture screen georgia-stand)
|
(assoc (animation->texture screen georgia-stand)
|
||||||
@@ -1190,7 +1190,7 @@ void main ()
|
|||||||
(set! (. cam zoom) utils/min-zoom)
|
(set! (. cam zoom) utils/min-zoom)
|
||||||
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader)
|
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader)
|
||||||
_ (log/info "shader log:" (.getLog 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)]
|
start-pos [(:x state) (:y state)]
|
||||||
has-start-pos? (:x state)
|
has-start-pos? (:x state)
|
||||||
|
|
||||||
@@ -1213,15 +1213,15 @@ void main ()
|
|||||||
:outside-castle (rooms.outside-castle/make screen)}
|
:outside-castle (rooms.outside-castle/make screen)}
|
||||||
rooms (add-georgia-to-all-rooms screen rooms)
|
rooms (add-georgia-to-all-rooms screen rooms)
|
||||||
entities {:rooms rooms
|
entities {:rooms rooms
|
||||||
:step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241)
|
:step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241)
|
||||||
:cam {:zoom utils/min-zoom
|
:cam {:zoom utils/min-zoom
|
||||||
:ideal-x 160
|
:ideal-x 160
|
||||||
:ideal-y 120
|
:ideal-y 120
|
||||||
:x 160
|
:x 160
|
||||||
:y 120
|
:y 120
|
||||||
:paused? false
|
:paused? false
|
||||||
:object nil}
|
:object nil}
|
||||||
|
|
||||||
:current-sounds {:object nil
|
:current-sounds {:object nil
|
||||||
:value []}
|
:value []}
|
||||||
:action-icon {}
|
:action-icon {}
|
||||||
@@ -1237,7 +1237,7 @@ void main ()
|
|||||||
:dream (utils/make-music "dream/music.ogg")
|
:dream (utils/make-music "dream/music.ogg")
|
||||||
:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
||||||
:wind (utils/make-music "music/wind.ogg")}
|
:wind (utils/make-music "music/wind.ogg")}
|
||||||
:state state
|
:state state
|
||||||
:time-profiles {:object nil
|
:time-profiles {:object nil
|
||||||
:default utils/default-night-merge
|
:default utils/default-night-merge
|
||||||
:sprite utils/default-night-merge-sprite
|
:sprite utils/default-night-merge-sprite
|
||||||
@@ -1246,12 +1246,12 @@ void main ()
|
|||||||
:closing? {:object nil
|
:closing? {:object nil
|
||||||
:value false}
|
:value false}
|
||||||
:sounds {:blink (utils/load-sound "ego/blink2.ogg")
|
: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")
|
:disappear (utils/load-sound "inside-house/disappear.ogg")
|
||||||
:grow-sound (utils/load-sound "ego/potion.ogg")
|
:grow-sound (utils/load-sound "ego/potion.ogg")
|
||||||
:object nil}
|
:object nil}
|
||||||
:fade {:object nil
|
:fade {:object nil
|
||||||
:opacity 0.0}
|
:opacity 0.0}
|
||||||
:white-fade (assoc (utils/get-texture "white.png")
|
:white-fade (assoc (utils/get-texture "white.png")
|
||||||
:scale-x 30
|
:scale-x 30
|
||||||
:scale-y 30
|
:scale-y 30
|
||||||
@@ -1283,11 +1283,11 @@ void main ()
|
|||||||
:last-pos [0 0]
|
:last-pos [0 0]
|
||||||
:offset [0 0 ]
|
:offset [0 0 ]
|
||||||
:down-target nil}
|
:down-target nil}
|
||||||
|
|
||||||
:all-items (assoc items/items :object nil)
|
:all-items (assoc items/items :object nil)
|
||||||
:started? {:value false
|
:started? {:value false
|
||||||
:object nil}
|
: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?
|
(assoc-in room [:entities :ego] (get-ego screen (if has-start-pos?
|
||||||
start-pos
|
start-pos
|
||||||
(:start-pos room))
|
(:start-pos room))
|
||||||
@@ -1297,8 +1297,8 @@ void main ()
|
|||||||
(:start-pos room))))))}]
|
(:start-pos room))))))}]
|
||||||
|
|
||||||
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
|
(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.")
|
(log/info "[done] Initializing scene.")
|
||||||
|
|
||||||
(if-let [apply-state (get-in entities [:room :apply-state])]
|
(if-let [apply-state (get-in entities [:room :apply-state])]
|
||||||
@@ -1338,9 +1338,9 @@ void main ()
|
|||||||
(when (get-in entities [:state :active?])
|
(when (get-in entities [:state :active?])
|
||||||
(-> entities
|
(-> entities
|
||||||
(remove-cam-tweens)
|
(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]}]
|
(fn [screen entities {:keys [initial-pointer-1 initial-pointer-2]}]
|
||||||
(when (get-in entities [:state :active?])
|
(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)])
|
(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)
|
(remove-cam-tweens)
|
||||||
(assoc-in [:cursor :last-pos] [0 0])
|
(assoc-in [:cursor :last-pos] [0 0])
|
||||||
(assoc-in [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
|
(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
|
:on-zoom
|
||||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
|
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
|
||||||
(when (get-in entities [:state :active?])
|
(when (get-in entities [:state :active?])
|
||||||
(let [start-zoom (get-in entities [:cam :start-zoom])
|
(let [start-zoom (get-in entities [:cam :start-zoom])
|
||||||
zoom (get-in entities [:cam :zoom])
|
zoom (get-in entities [:cam :zoom])
|
||||||
entities (as-> entities entities
|
entities (as-> entities entities
|
||||||
(if (not start-zoom)
|
(if (not start-zoom)
|
||||||
(assoc-in entities [:cam :start-zoom] zoom)
|
(assoc-in entities [:cam :start-zoom] zoom)
|
||||||
entities)
|
entities)
|
||||||
@@ -1371,14 +1371,14 @@ void main ()
|
|||||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]
|
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]
|
||||||
|
|
||||||
(update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 10.0 )))))
|
(update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 10.0 )))))
|
||||||
|
|
||||||
:on-render
|
: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]
|
(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)
|
(steam/update)
|
||||||
(.apply viewport)
|
(.apply viewport)
|
||||||
|
|
||||||
(if (get-in entities [:closing? :value])
|
(if (get-in entities [:closing? :value])
|
||||||
|
|
||||||
(let [entities (utils/apply-tweens screen entities tweens)
|
(let [entities (utils/apply-tweens screen entities tweens)
|
||||||
entities (update-current-sound-vols! entities)
|
entities (update-current-sound-vols! entities)
|
||||||
entities (remove-ended-sounds screen entities)
|
entities (remove-ended-sounds screen entities)
|
||||||
@@ -1395,7 +1395,7 @@ void main ()
|
|||||||
(doseq [m (vals (get-in entities [:musics]))]
|
(doseq [m (vals (get-in entities [:musics]))]
|
||||||
(when m
|
(when m
|
||||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||||
|
|
||||||
(clear!)
|
(clear!)
|
||||||
(doseq [e (sort-by :baseline all-entities)]
|
(doseq [e (sort-by :baseline all-entities)]
|
||||||
(if (:parallax e)
|
(if (:parallax e)
|
||||||
@@ -1422,7 +1422,7 @@ void main ()
|
|||||||
(actions/pan-to screen entities
|
(actions/pan-to screen entities
|
||||||
(get-in entities [:room :entities :ego :x])
|
(get-in entities [:room :entities :ego :x])
|
||||||
(get-in entities [:room :entities :ego :y])
|
(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
|
tween/ease-in-out-quadratic
|
||||||
5.0)
|
5.0)
|
||||||
(actions/pan-to screen entities
|
(actions/pan-to screen entities
|
||||||
@@ -1430,18 +1430,18 @@ void main ()
|
|||||||
(- 10 ^double (rand-int 20)))
|
(- 10 ^double (rand-int 20)))
|
||||||
(+ ^double (get-in entities [:cam :y] 0)
|
(+ ^double (get-in entities [:cam :y] 0)
|
||||||
(- 10 ^double (rand-int 20)))
|
(- 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
|
tween/ease-in-out-quadratic
|
||||||
5.0))
|
5.0))
|
||||||
entities)
|
entities)
|
||||||
|
|
||||||
|
|
||||||
entities (grab-layers entities)
|
entities (grab-layers entities)
|
||||||
update-room (fn [{:keys [anim update-fn] :as e}]
|
update-room (fn [{:keys [anim update-fn] :as e}]
|
||||||
(let [e (if (:anim e)
|
(let [e (if (:anim e)
|
||||||
(animate e screen)
|
(animate e screen)
|
||||||
e)
|
e)
|
||||||
|
|
||||||
e (if update-fn
|
e (if update-fn
|
||||||
(update-fn screen (get-in entities [:room :entities]) e)
|
(update-fn screen (get-in entities [:room :entities]) e)
|
||||||
e)
|
e)
|
||||||
@@ -1463,8 +1463,8 @@ void main ()
|
|||||||
cursor-offset-x)
|
cursor-offset-x)
|
||||||
:y (unchecked-add (unchecked-subtract last-pos-y 16 )
|
:y (unchecked-add (unchecked-subtract last-pos-y 16 )
|
||||||
cursor-offset-y)})
|
cursor-offset-y)})
|
||||||
|
|
||||||
(clear!)
|
(clear!)
|
||||||
(screen! talking-screen :on-update-camera { :scene-viewport (:viewport screen) :scene-camera (:camera screen)})
|
(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])})
|
(screen! fade-screen :update-fade { :opacity (get-in entities [:fade :opacity])})
|
||||||
(when true #_(not (get-in entities [:cam :paused?]))
|
(when true #_(not (get-in entities [:cam :paused?]))
|
||||||
@@ -1476,15 +1476,15 @@ void main ()
|
|||||||
(utils/update-override screen entities options))
|
(utils/update-override screen entities options))
|
||||||
entities (play-key-sounds screen entities)
|
entities (play-key-sounds screen entities)
|
||||||
entities (update-current-sound-vols! 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]))]
|
(doseq [m (vals (get-in entities [:musics]))]
|
||||||
(when m
|
(when m
|
||||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||||
(doseq [e (doall (sort-by :baseline all-entities))]
|
(doseq [e (doall (sort-by :baseline all-entities))]
|
||||||
(if (:parallax e)
|
(if (:parallax e)
|
||||||
(render-parallax screen e)
|
(render-parallax screen e)
|
||||||
(render! screen [e])))
|
(render! screen [e])))
|
||||||
|
|
||||||
entities))))
|
entities))))
|
||||||
|
|
||||||
:on-resize (fn [{:keys [^FitViewport viewport]} entities {:keys [width height]}]
|
:on-resize (fn [{:keys [^FitViewport viewport]} entities {:keys [width height]}]
|
||||||
@@ -1498,13 +1498,13 @@ void main ()
|
|||||||
|
|
||||||
:on-mouse-moved
|
:on-mouse-moved
|
||||||
mouse-moved
|
mouse-moved
|
||||||
|
|
||||||
:on-touch-dragged
|
:on-touch-dragged
|
||||||
mouse-moved
|
mouse-moved
|
||||||
|
|
||||||
:on-touch-down
|
:on-touch-down
|
||||||
(fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [input-x input-y] :as options}]
|
(fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [input-x input-y] :as options}]
|
||||||
|
|
||||||
(when (utils/contains-point? (.getScreenX viewport) (.getScreenY viewport)
|
(when (utils/contains-point? (.getScreenX viewport) (.getScreenY viewport)
|
||||||
(.getScreenWidth viewport) (.getScreenHeight viewport)
|
(.getScreenWidth viewport) (.getScreenHeight viewport)
|
||||||
input-x input-y)
|
input-x input-y)
|
||||||
@@ -1564,7 +1564,7 @@ void main ()
|
|||||||
:on-menu (fn [{:keys [viewport] :as screen} entities options]
|
:on-menu (fn [{:keys [viewport] :as screen} entities options]
|
||||||
(when-not (or (get-in entities [:tweens :fade-out])
|
(when-not (or (get-in entities [:tweens :fade-out])
|
||||||
(get-in entities [:tweens :fade-in]))
|
(get-in entities [:tweens :fade-in]))
|
||||||
|
|
||||||
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
|
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
|
||||||
(-> entities
|
(-> entities
|
||||||
(assoc-in [:closing? :value] true)
|
(assoc-in [:closing? :value] true)
|
||||||
@@ -1586,7 +1586,7 @@ void main ()
|
|||||||
|
|
||||||
|
|
||||||
(defn grow-hud [screen entities target up?]
|
(defn grow-hud [screen entities target up?]
|
||||||
|
|
||||||
(let [grow-or-shrink (if up? :grow :shrink)
|
(let [grow-or-shrink (if up? :grow :shrink)
|
||||||
scale-from (* utils/ui-scale (if up? 1.0 1.1))
|
scale-from (* utils/ui-scale (if up? 1.0 1.1))
|
||||||
scale-to (* utils/ui-scale (if up? 1.1 1.0))
|
scale-to (* utils/ui-scale (if up? 1.1 1.0))
|
||||||
@@ -1611,10 +1611,10 @@ void main ()
|
|||||||
(defscreen demo
|
(defscreen demo
|
||||||
:on-show
|
:on-show
|
||||||
(fn [screen entities options]
|
(fn [screen entities options]
|
||||||
(let [screen (assoc screen :total-time 0)]
|
(let [screen (assoc screen :total-time 0)]
|
||||||
(utils/setup-viewport screen 640 480)
|
(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)}))
|
{:label (assoc (label "Demo version - DO NOT COPY" (color :white) ) :y 460 :x 5 :baseline 0 :opacity 0.5)}))
|
||||||
|
|
||||||
:on-render
|
:on-render
|
||||||
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
||||||
(.apply viewport)
|
(.apply viewport)
|
||||||
@@ -1633,7 +1633,7 @@ void main ()
|
|||||||
(= 0.0 (get-in scene-entities [:fade :opacity])))))
|
(= 0.0 (get-in scene-entities [:fade :opacity])))))
|
||||||
|
|
||||||
(defmulti transition-hud (fn [screen entities new-state state-data]
|
(defmulti transition-hud (fn [screen entities new-state state-data]
|
||||||
|
|
||||||
[(get-in entities [:inv-fsm :state]) new-state]))
|
[(get-in entities [:inv-fsm :state]) new-state]))
|
||||||
|
|
||||||
(defmethod transition-hud :default [screen entities new-state state-data] entities)
|
(defmethod transition-hud :default [screen entities new-state state-data] entities)
|
||||||
@@ -1669,7 +1669,7 @@ void main ()
|
|||||||
(assoc :selected-item
|
(assoc :selected-item
|
||||||
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||||
:origin-x 8
|
:origin-x 8
|
||||||
:origin-y 0
|
:origin-y 0
|
||||||
:scale-x utils/ui-scale
|
:scale-x utils/ui-scale
|
||||||
:scale-y utils/ui-scale
|
:scale-y utils/ui-scale
|
||||||
:x (- 320 (* utils/ui-scale 12))
|
:x (- 320 (* utils/ui-scale 12))
|
||||||
@@ -1742,7 +1742,7 @@ void main ()
|
|||||||
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
|
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
|
||||||
(transition-done? [this screen entities] true))
|
(transition-done? [this screen entities] true))
|
||||||
(appear-transition (or state-data (get-in entities [:inv-fsm :state-data])) :hide :in)
|
(appear-transition (or state-data (get-in entities [:inv-fsm :state-data])) :hide :in)
|
||||||
|
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
(-> entities
|
(-> entities
|
||||||
@@ -1758,7 +1758,7 @@ void main ()
|
|||||||
[(appear-transition state-data :hide :far-out)
|
[(appear-transition state-data :hide :far-out)
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
(-> entities
|
(-> entities
|
||||||
(dissoc :selected-item)))
|
(dissoc :selected-item)))
|
||||||
(transition-done? [this screen entities]
|
(transition-done? [this screen entities]
|
||||||
true))]
|
true))]
|
||||||
@@ -1767,7 +1767,7 @@ void main ()
|
|||||||
(appear-transition state-data :hide :far-out)
|
(appear-transition state-data :hide :far-out)
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
(-> entities
|
(-> entities
|
||||||
(dissoc :selected-item)))
|
(dissoc :selected-item)))
|
||||||
(transition-done? [this screen entities]
|
(transition-done? [this screen entities]
|
||||||
true))])]
|
true))])]
|
||||||
@@ -1789,7 +1789,7 @@ void main ()
|
|||||||
(animation! (get-in entities [:inventory :anim])
|
(animation! (get-in entities [:inventory :anim])
|
||||||
:is-animation-finished
|
:is-animation-finished
|
||||||
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
||||||
|
|
||||||
(appear-transition state-data :show :out)
|
(appear-transition state-data :show :out)
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
@@ -1812,7 +1812,7 @@ void main ()
|
|||||||
(animation! (get-in entities [:inventory :anim])
|
(animation! (get-in entities [:inventory :anim])
|
||||||
:is-animation-finished
|
:is-animation-finished
|
||||||
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
||||||
|
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
(-> entities
|
(-> entities
|
||||||
@@ -1831,7 +1831,7 @@ void main ()
|
|||||||
(animation! (get-in entities [:inventory :anim])
|
(animation! (get-in entities [:inventory :anim])
|
||||||
:is-animation-finished
|
:is-animation-finished
|
||||||
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
(- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
|
||||||
|
|
||||||
(appear-transition state-data :show :none)
|
(appear-transition state-data :show :none)
|
||||||
(reify ITransition
|
(reify ITransition
|
||||||
(start-transition [this screen entities]
|
(start-transition [this screen entities]
|
||||||
@@ -1877,12 +1877,12 @@ void main ()
|
|||||||
|
|
||||||
current-transition
|
current-transition
|
||||||
nil ;; waiting
|
nil ;; waiting
|
||||||
|
|
||||||
(fsm-busy? entities)
|
(fsm-busy? entities)
|
||||||
(-> (start-transition next-transition screen entities)
|
(-> (start-transition next-transition screen entities)
|
||||||
(assoc-in [:inv-fsm :current-transition] next-transition)
|
(assoc-in [:inv-fsm :current-transition] next-transition)
|
||||||
(assoc-in [:inv-fsm :transition-steps] remaining-transitions))
|
(assoc-in [:inv-fsm :transition-steps] remaining-transitions))
|
||||||
|
|
||||||
next-state
|
next-state
|
||||||
(-> (transition-hud screen entities next-state next-state-data)
|
(-> (transition-hud screen entities next-state next-state-data)
|
||||||
(assoc-in [:inv-fsm :pending-states] (vec pending-states)))
|
(assoc-in [:inv-fsm :pending-states] (vec pending-states)))
|
||||||
@@ -1894,24 +1894,24 @@ void main ()
|
|||||||
:on-show
|
:on-show
|
||||||
(fn [screen entities options]
|
(fn [screen entities options]
|
||||||
(let [screen (assoc screen :total-time 0)
|
(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
|
{:inv-fsm {:state :none
|
||||||
:state-data {}
|
:state-data {}
|
||||||
:target nil
|
:target nil
|
||||||
:target-data nil
|
:target-data nil
|
||||||
:transition-steps []
|
:transition-steps []
|
||||||
:pending-states []}
|
:pending-states []}
|
||||||
:already-saved? false
|
:already-saved? false
|
||||||
|
|
||||||
:close (assoc (utils/get-texture "close.png")
|
:close (assoc (utils/get-texture "close.png")
|
||||||
:x 320 :y 240
|
:x 320 :y 240
|
||||||
:origin-x 16 :origin-y 16
|
:origin-x 16 :origin-y 16
|
||||||
:width 16 :height 16
|
:width 16 :height 16
|
||||||
:scale-x utils/ui-scale :scale-y utils/ui-scale
|
:scale-x utils/ui-scale :scale-y utils/ui-scale
|
||||||
:baseline 9000
|
:baseline 9000
|
||||||
:opacity 0.8)
|
:opacity 0.8)
|
||||||
:save (assoc (utils/get-texture "save.png")
|
:save (assoc (utils/get-texture "save.png")
|
||||||
:x (- 320 (* utils/ui-scale 16) 4) :y 240
|
:x (- 320 (* utils/ui-scale 16) 4) :y 240
|
||||||
:origin-x 16 :origin-y 16
|
:origin-x 16 :origin-y 16
|
||||||
@@ -1919,8 +1919,9 @@ void main ()
|
|||||||
:baseline 9000
|
:baseline 9000
|
||||||
:opacity 0.8)
|
:opacity 0.8)
|
||||||
:inventory (assoc (utils/get-texture "inventory.png") :x (- 320 (* 21 utils/ui-scale)) :y (* 27 utils/ui-scale ) :baseline 9000
|
: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
|
: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
|
: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 ]))
|
: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)))
|
(animation! :set-play-mode (play-mode :normal)))
|
||||||
@@ -1935,7 +1936,7 @@ void main ()
|
|||||||
:all-items (texture! (texture (pixmap "cursor.png")) :split 18 16)
|
:all-items (texture! (texture (pixmap "cursor.png")) :split 18 16)
|
||||||
#_#_:fps (->> (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)
|
#_#_:fps (->> (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)
|
||||||
(utils/add-actor-to-stage screen))}))
|
(utils/add-actor-to-stage screen))}))
|
||||||
|
|
||||||
:on-render
|
:on-render
|
||||||
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
||||||
(.apply viewport)
|
(.apply viewport)
|
||||||
@@ -1962,11 +1963,11 @@ void main ()
|
|||||||
(as-> entities entities
|
(as-> entities entities
|
||||||
(update-in entities [:save] assoc :r 0.75 :g 0.75 :b 0.75)
|
(update-in entities [:save] assoc :r 0.75 :g 0.75 :b 0.75)
|
||||||
(grow-hud screen entities :save false)))
|
(grow-hud screen entities :save false)))
|
||||||
|
|
||||||
entities (or (process-fsm screen entities) entities)]
|
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)))
|
(render! screen [ (if (and hud-interactable? (not (:already-saved? entities)))
|
||||||
(:save entities)
|
(:save entities)
|
||||||
@@ -1976,7 +1977,7 @@ void main ()
|
|||||||
(:inventory entities)
|
(:inventory entities)
|
||||||
(assoc (:inventory entities) :opacity 0.5))
|
(assoc (:inventory entities) :opacity 0.5))
|
||||||
(:selected-item entities)
|
(:selected-item entities)
|
||||||
(:close entities)])
|
(:close entities)])
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
:on-resize
|
:on-resize
|
||||||
@@ -2010,7 +2011,7 @@ void main ()
|
|||||||
(if (hud-interactable?)
|
(if (hud-interactable?)
|
||||||
(-> entities
|
(-> entities
|
||||||
(update-in [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])]))))
|
(update-in [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])]))))
|
||||||
|
|
||||||
|
|
||||||
:on-start-script
|
:on-start-script
|
||||||
(fn [_ entities _]
|
(fn [_ entities _]
|
||||||
@@ -2033,11 +2034,11 @@ void main ()
|
|||||||
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
||||||
hovered-close? (utils/intersects? (:close entities) [x y])
|
hovered-close? (utils/intersects? (:close entities) [x y])
|
||||||
hovered-save? (utils/intersects? (:save entities) [x y])]
|
hovered-save? (utils/intersects? (:save entities) [x y])]
|
||||||
|
|
||||||
(screen! scene :hud-active? { :hud-active? (or hovered-close? hovered-inventory? hovered-save?)})))
|
(screen! scene :hud-active? { :hud-active? (or hovered-close? hovered-inventory? hovered-save?)})))
|
||||||
|
|
||||||
:on-mouse-moved
|
:on-mouse-moved
|
||||||
|
|
||||||
(fn [screen entities options]
|
(fn [screen entities options]
|
||||||
(let [[x y] (utils/unproject screen options)
|
(let [[x y] (utils/unproject screen options)
|
||||||
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
||||||
@@ -2063,23 +2064,23 @@ void main ()
|
|||||||
(grow-hud screen entities :selected-item false)
|
(grow-hud screen entities :selected-item false)
|
||||||
entities)
|
entities)
|
||||||
entities (grow-hud screen entities :close false)
|
entities (grow-hud screen entities :close false)
|
||||||
entities (grow-hud screen entities :save false)]
|
entities (grow-hud screen entities :save false)]
|
||||||
entities
|
entities
|
||||||
))))
|
))))
|
||||||
|
|
||||||
|
|
||||||
:on-touch-up
|
:on-touch-up
|
||||||
(fn [screen entities options]
|
(fn [screen entities options]
|
||||||
(if (= (button-code :left) (:button options))
|
(if (= (button-code :left) (:button options))
|
||||||
(let [[x y] (utils/unproject screen options)]
|
(let [[x y] (utils/unproject screen options)]
|
||||||
(cond
|
(cond
|
||||||
(not (hud-interactable?))
|
(not (hud-interactable?))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
|
||||||
(utils/intersects? (:inventory entities) [x y])
|
(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])])
|
(update-in entities [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])])
|
||||||
|
|
||||||
(do
|
(do
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
(Pixmap/setFilter Pixmap$Filter/NearestNeighbour)
|
(Pixmap/setFilter Pixmap$Filter/NearestNeighbour)
|
||||||
(pixmap! resized :draw-pixmap base-cursor (* index 18) 0 16 16
|
(pixmap! resized :draw-pixmap base-cursor (* index 18) 0 16 16
|
||||||
0 0 target-width target-height)
|
0 0 target-width target-height)
|
||||||
|
|
||||||
(graphics! :new-cursor resized (* hot-x scale) (* hot-y scale) )))
|
(graphics! :new-cursor resized (* hot-x scale) (* hot-y scale) )))
|
||||||
|
|
||||||
(defn get-texture [path]
|
(defn get-texture [path]
|
||||||
@@ -195,12 +195,12 @@
|
|||||||
(first (drop-while #{:fail}
|
(first (drop-while #{:fail}
|
||||||
(repeatedly times
|
(repeatedly times
|
||||||
#(try (fn)
|
#(try (fn)
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/error "Could not save!" e)
|
(log/error "Could not save!" e)
|
||||||
:fail))))))
|
:fail))))))
|
||||||
|
|
||||||
(defn save [entities id name & [blurb]]
|
(defn save [entities id name & [blurb]]
|
||||||
(let [save-fn (fn []
|
(let [save-fn (fn []
|
||||||
(log/info "Saving " id name)
|
(log/info "Saving " id name)
|
||||||
(let [save {:name name
|
(let [save {:name name
|
||||||
:id id
|
:id id
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
:x (get-in entities [:room :entities :ego :x])
|
:x (get-in entities [:room :entities :ego :x])
|
||||||
:y (get-in entities [:room :entities :ego :y]))
|
:y (get-in entities [:room :entities :ego :y]))
|
||||||
:blurb (or blurb name)}]
|
:blurb (or blurb name)}]
|
||||||
|
|
||||||
(steam/write-bytes (steam/save-file-name id) (.getBytes (pr-str save) "UTF-8"))
|
(steam/write-bytes (steam/save-file-name id) (.getBytes (pr-str save) "UTF-8"))
|
||||||
(on-gl (let [gl-func (fn []
|
(on-gl (let [gl-func (fn []
|
||||||
(let [_ (Pixmap/setFilter Pixmap$Filter/BiLinear)
|
(let [_ (Pixmap/setFilter Pixmap$Filter/BiLinear)
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
|
|
||||||
(defn get-font [filename]
|
(defn get-font [filename]
|
||||||
(let [font (-> (bitmap-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)
|
tr (bitmap-font! font :get-region)
|
||||||
tx (.getTexture tr)]
|
tx (.getTexture tr)]
|
||||||
(call! ^Texture tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
(call! ^Texture tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
||||||
@@ -357,7 +357,7 @@
|
|||||||
|
|
||||||
(defn find-override [entities [x y]]
|
(defn find-override [entities [x y]]
|
||||||
(first (concat (filter #(and ((:mouse-in? %) entities x y)
|
(first (concat (filter #(and ((:mouse-in? %) entities x y)
|
||||||
|
|
||||||
(:override %))
|
(:override %))
|
||||||
(get-in entities [:room :interactions]))
|
(get-in entities [:room :interactions]))
|
||||||
(filter #(and (:mouse-in? %)
|
(filter #(and (:mouse-in? %)
|
||||||
@@ -390,7 +390,7 @@
|
|||||||
(doto (music (str r ".mp3")) (music! :set-looping true)))))
|
(doto (music (str r ".mp3")) (music! :set-looping true)))))
|
||||||
|
|
||||||
(defn load-sound [f]
|
(defn load-sound [f]
|
||||||
(try
|
(try
|
||||||
(sound f)
|
(sound f)
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/info e)
|
(log/info e)
|
||||||
@@ -406,13 +406,13 @@
|
|||||||
|
|
||||||
(defn intersects? [e [x y]]
|
(defn intersects? [e [x y]]
|
||||||
(when (:object e)
|
(when (:object e)
|
||||||
(let [object-width (* (:scale-x e 1.0) (or (:width e) (when (actor? e ) (.getWidth ^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 (:height e) (when (actor? e ) (.getHeight ^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-x (* (:scale-x e 1.0) (:origin-x e 0))
|
||||||
origin-y (* (:scale-y e 1.0) (:origin-y 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-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)]
|
object-y (- (or (:y e) (when (actor? e ) (.getY ^Actor (:object e))) 0) origin-y)]
|
||||||
|
|
||||||
(and (:object e)
|
(and (:object e)
|
||||||
(< object-x x (+ object-x object-width))
|
(< object-x x (+ object-x object-width))
|
||||||
(< object-y y (+ object-y object-height))))))
|
(< object-y y (+ object-y object-height))))))
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
(.apply viewport)
|
(.apply viewport)
|
||||||
(assoc screen :renderer stage :viewport viewport :camera cam)))
|
(assoc screen :renderer stage :viewport viewport :camera cam)))
|
||||||
|
|
||||||
(defn unproject
|
(defn unproject
|
||||||
([screen options]
|
([screen options]
|
||||||
(unproject screen options [(:input-x options) (:input-y options)]) )
|
(unproject screen options [(:input-x options) (:input-y options)]) )
|
||||||
([screen options [x y]]
|
([screen options [x y]]
|
||||||
@@ -443,7 +443,7 @@
|
|||||||
y (.y pj)]
|
y (.y pj)]
|
||||||
[x y])))
|
[x y])))
|
||||||
|
|
||||||
(defn project
|
(defn project
|
||||||
([screen [x y]]
|
([screen [x y]]
|
||||||
(let [pj (.project ^FitViewport (:viewport screen) (vector-2 x y))
|
(let [pj (.project ^FitViewport (:viewport screen) (vector-2 x y))
|
||||||
x (.x pj)
|
x (.x pj)
|
||||||
@@ -470,12 +470,12 @@
|
|||||||
hovering-ego (hovering-ego entities last-pos)
|
hovering-ego (hovering-ego entities last-pos)
|
||||||
current (get-in entities [:cursor :current])
|
current (get-in entities [:cursor :current])
|
||||||
entities (assoc-in entities [:label :text] "")
|
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
|
(cond
|
||||||
out-of-bounds
|
out-of-bounds
|
||||||
(update-in entities [:cursor] assoc :override nil :active false )
|
(update-in entities [:cursor] assoc :override nil :active false )
|
||||||
|
|
||||||
|
|
||||||
(not (get-in entities [:state :active?]))
|
(not (get-in entities [:state :active?]))
|
||||||
(-> entities
|
(-> entities
|
||||||
@@ -526,9 +526,9 @@
|
|||||||
|
|
||||||
(defn fast-forward-particle [p]
|
(defn fast-forward-particle [p]
|
||||||
(particle-effect! p :reset)
|
(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]
|
(dotimes [_ 160]
|
||||||
(particle-effect! p :update 0.2)))
|
(particle-effect! p :update 0.2)))
|
||||||
|
|
||||||
@@ -633,7 +633,7 @@
|
|||||||
(play-sound! screen entities snd volume-fn pan type 1.0))
|
(play-sound! screen entities snd volume-fn pan type 1.0))
|
||||||
|
|
||||||
([screen entities snd volume-fn pan type pitch]
|
([screen entities snd volume-fn pan type pitch]
|
||||||
|
|
||||||
(let [vol (volume-fn entities)
|
(let [vol (volume-fn entities)
|
||||||
snd (if (keyword? snd)
|
snd (if (keyword? snd)
|
||||||
(or (-> entities :room :sounds snd)
|
(or (-> entities :room :sounds snd)
|
||||||
|
|||||||
Reference in New Issue
Block a user