implemented library of items.
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
(can-skip? [this screen entities])
|
(can-skip? [this screen entities])
|
||||||
(get-channel [this]))
|
(get-channel [this]))
|
||||||
|
|
||||||
|
(defn has-item? [entities item]
|
||||||
|
((set (get-in entities [:state :inventory])) item))
|
||||||
|
|
||||||
(defmacro get-script [entities & forms]
|
(defmacro get-script [entities & forms]
|
||||||
`(fn [starting-entities#]
|
`(fn [starting-entities#]
|
||||||
@@ -260,7 +262,7 @@
|
|||||||
|
|
||||||
(-> entities
|
(-> entities
|
||||||
(update-in [:state :inventory] #(conj % item))
|
(update-in [:state :inventory] #(conj % item))
|
||||||
(assoc-in [:cursor :current] item)))
|
(assoc-in [:cursor :current] (:cursor item))))
|
||||||
|
|
||||||
(continue [this screen entities] entities)
|
(continue [this screen entities] entities)
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
(render! screen [(:fade entities) (:overlay entities)])
|
(render! screen [(:fade entities) (:overlay entities)])
|
||||||
(render! screen (:items entities))
|
(render! screen (:items entities))
|
||||||
(if-let [item (:highlighted-item entities)]
|
(if-let [item (:highlighted-item entities)]
|
||||||
(label! (:highlighted-text entities) :set-text (name item))
|
(label! (:highlighted-text entities) :set-text (:name item))
|
||||||
(label! (:highlighted-text entities) :set-text ""))
|
(label! (:highlighted-text entities) :set-text ""))
|
||||||
(render! screen [(:highlighted-text entities)]))
|
(render! screen [(:highlighted-text entities)]))
|
||||||
entities))
|
entities))
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
offset-y (+ y (/ item-width 2))
|
offset-y (+ y (/ item-width 2))
|
||||||
padding (/ item-width 2)
|
padding (/ item-width 2)
|
||||||
padding (* 4 padding)]]
|
padding (* 4 padding)]]
|
||||||
(assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ item)))
|
(assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||||
:x x :y y
|
:x x :y y
|
||||||
:scale-x 4
|
:scale-x 4
|
||||||
:scale-y 4
|
:scale-y 4
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns advent.screens.rooms.behind-house
|
(ns advent.screens.rooms.behind-house
|
||||||
(:require [advent.screens.rooms :as rooms]
|
(:require [advent.screens.rooms :as rooms]
|
||||||
|
[advent.screens.items :as items]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.utils :as utils]
|
[advent.utils :as utils]
|
||||||
[clojure.zip :as zip]
|
[clojure.zip :as zip]
|
||||||
@@ -28,11 +29,11 @@
|
|||||||
:mushrooms {:box [247 59 269 76]
|
:mushrooms {:box [247 59 269 76]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
entities
|
entities
|
||||||
(if ((get-in @entities [:state :inventory]) :mushrooms)
|
(if (actions/has-item? @entities items/mushrooms)
|
||||||
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
|
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
|
||||||
(do
|
(do
|
||||||
(actions/walk-to entities :ego [242 75])
|
(actions/walk-to entities :ego [242 75])
|
||||||
(actions/give entities :mushrooms)
|
(actions/give entities items/mushrooms)
|
||||||
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
|
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
|
||||||
:window {:box [103 44 130 140]
|
:window {:box [103 44 130 140]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns advent.screens.rooms.inside-house
|
(ns advent.screens.rooms.inside-house
|
||||||
(:require [advent.screens.rooms :as rooms]
|
(:require [advent.screens.items :as items]
|
||||||
|
[advent.screens.rooms :as rooms]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.utils :as utils]
|
[advent.utils :as utils]
|
||||||
[clojure.zip :as zip]
|
[clojure.zip :as zip]
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
:x 265 :y 80 :baseline 240
|
:x 265 :y 80 :baseline 240
|
||||||
:script (actions/get-script entities
|
:script (actions/get-script entities
|
||||||
(actions/remove-entity entities :flask)
|
(actions/remove-entity entities :flask)
|
||||||
(actions/give entities :flask)
|
(actions/give entities items/flask)
|
||||||
(actions/do-dialogue entities :ego "Hey you think I could have this flask?"
|
(actions/do-dialogue entities :ego "Hey you think I could have this flask?"
|
||||||
:wizard "Sure.")))}
|
:wizard "Sure.")))}
|
||||||
:collision "inside-house/collision.png"
|
:collision "inside-house/collision.png"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns advent.screens.rooms.outside-castle
|
(ns advent.screens.rooms.outside-castle
|
||||||
(:require [advent.screens.rooms :as rooms]
|
(:require [advent.screens.items :as items]
|
||||||
|
[advent.screens.rooms :as rooms]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.utils :as utils]
|
[advent.utils :as utils]
|
||||||
[clojure.zip :as zip]
|
[clojure.zip :as zip]
|
||||||
@@ -31,12 +32,12 @@
|
|||||||
:garden {:box [103 170 178 200]
|
:garden {:box [103 170 178 200]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
entities
|
entities
|
||||||
(if ((get-in @entities [:state :inventory]) :carrot)
|
(if (actions/has-item? @entities items/carrot)
|
||||||
(actions/talk entities :ego "If I steal any more, I might get caught.")
|
(actions/talk entities :ego "If I steal any more, I might get caught.")
|
||||||
(do
|
(do
|
||||||
(actions/walk-to entities :ego [128 180])
|
(actions/walk-to entities :ego [128 180])
|
||||||
(actions/talk entities :ego "Hey! Carrots. No one will notice one missing.")
|
(actions/talk entities :ego "Hey! Carrots. No one will notice one missing.")
|
||||||
(actions/give entities :carrot))))}
|
(actions/give entities items/carrot))))}
|
||||||
:peddler {:box [110 90 128 146]
|
:peddler {:box [110 90 128 146]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
entities
|
entities
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns advent.screens.rooms.outside-house
|
(ns advent.screens.rooms.outside-house
|
||||||
(:require [advent.screens.rooms :as rooms]
|
(:require [advent.screens.items :as items]
|
||||||
|
[advent.screens.rooms :as rooms]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.utils :as utils]
|
[advent.utils :as utils]
|
||||||
[clojure.zip :as zip]
|
[clojure.zip :as zip]
|
||||||
@@ -164,23 +165,23 @@
|
|||||||
entities
|
entities
|
||||||
|
|
||||||
|
|
||||||
(if ((get-in @entities [:state :inventory]) :wool)
|
(if (actions/has-item? @entities items/wool)
|
||||||
(actions/talk entities :ego "The sheep has given me enough wool.")
|
(actions/talk entities :ego "The sheep has given me enough wool.")
|
||||||
(if (is-sheep-close? @entities)
|
(if (is-sheep-close? @entities)
|
||||||
(do (actions/walk-to entities :ego ego-sheep-loc)
|
(do (actions/walk-to entities :ego ego-sheep-loc)
|
||||||
(actions/give entities :wool)
|
(actions/give entities items/wool)
|
||||||
(actions/talk entities :ego "I guess her wool is shedding."))
|
(actions/talk entities :ego "I guess her wool is shedding."))
|
||||||
(actions/talk entities :ego "She's too far away for me to pet her."))))
|
(actions/talk entities :ego "She's too far away for me to pet her."))))
|
||||||
:scripts {:wool (actions/get-script entities
|
:scripts {items/wool (actions/get-script entities
|
||||||
(actions/talk entities :ego "She doesn't need it back."))
|
(actions/talk entities :ego "She doesn't need it back."))
|
||||||
:carrot (actions/get-script entities
|
items/carrot (actions/get-script entities
|
||||||
(actions/walk-to entities :ego ego-sheep-loc)
|
(actions/walk-to entities :ego ego-sheep-loc)
|
||||||
(actions/talk entities :ego "Come on girl, get the carrot!")
|
(actions/talk entities :ego "Come on girl, get the carrot!")
|
||||||
(actions/walk-straight-to entities :sheep [95 150]))
|
(actions/walk-straight-to entities :sheep [95 150]))
|
||||||
:flask (actions/get-script entities
|
items/flask (actions/get-script entities
|
||||||
(if (is-sheep-close? @entities)
|
(if (is-sheep-close? @entities)
|
||||||
(do (actions/walk-to entities :ego ego-sheep-loc)
|
(do (actions/walk-to entities :ego ego-sheep-loc)
|
||||||
(actions/give entities :flask-with-contents)
|
(actions/give entities items/flask-with-milk)
|
||||||
(actions/talk entities :ego "Sheeps milk."))
|
(actions/talk entities :ego "Sheeps milk."))
|
||||||
(actions/talk entities :ego "She's too far away.")))}
|
(actions/talk entities :ego "She's too far away.")))}
|
||||||
:left {:walk (utils/flip sheep-walk)
|
:left {:walk (utils/flip sheep-walk)
|
||||||
|
|||||||
@@ -134,7 +134,7 @@
|
|||||||
(update! screen :renderer (stage) :camera (orthographic))
|
(update! screen :renderer (stage) :camera (orthographic))
|
||||||
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
|
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
|
||||||
music (sound "town-music.mp3")
|
music (sound "town-music.mp3")
|
||||||
;; _ (sound! music :loop 0.80)
|
_ (sound! music :loop 0.30)
|
||||||
rooms {:inside-house (rooms.inside-house/make screen)
|
rooms {:inside-house (rooms.inside-house/make screen)
|
||||||
:outside-house (rooms.outside-house/make screen)
|
:outside-house (rooms.outside-house/make screen)
|
||||||
:behind-house (rooms.behind-house/make screen)
|
:behind-house (rooms.behind-house/make screen)
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
{:rooms rooms
|
{:rooms rooms
|
||||||
:state {:object nil
|
:state {:object nil
|
||||||
:active? true
|
:active? true
|
||||||
:inventory (sorted-set)}
|
:inventory []}
|
||||||
:actions {:object nil
|
:actions {:object nil
|
||||||
:channel (chan)
|
:channel (chan)
|
||||||
:current nil
|
:current nil
|
||||||
@@ -200,7 +200,7 @@
|
|||||||
(assoc-in entities [:state :active?] true))
|
(assoc-in entities [:state :active?] true))
|
||||||
|
|
||||||
:on-chose-item (fn [{:keys [item]} [entities]]
|
:on-chose-item (fn [{:keys [item]} [entities]]
|
||||||
(assoc-in entities [:cursor :current] item))
|
(assoc-in entities [:cursor :current] (:cursor item)))
|
||||||
|
|
||||||
:on-start-script (fn [{:keys [script]} [entities]]
|
:on-start-script (fn [{:keys [script]} [entities]]
|
||||||
(script entities)
|
(script entities)
|
||||||
|
|||||||
Reference in New Issue
Block a user