enhanced box.

This commit is contained in:
Bryce Covert
2016-02-15 08:09:04 -08:00
parent 60757614b1
commit 7e8af55d3a
5 changed files with 19 additions and 14 deletions

View File

@@ -30,14 +30,16 @@
(or (scripts (:value cursor)) (scripts :default)))))})))
(defn make [& {:keys [collision interactions entities] :as params}]
(let [interactions-as-list (for [[id spec] interactions]
(merge spec {:mouse-in? (fn [_ x y]
((apply zone/box (:box spec)) x y))
:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script spec)
(when-let [scripts (:scripts spec)]
(or (scripts (:value cursor)) (scripts :default)))))
:id id}))
(merge spec
(when (:box spec)
{:mouse-in? (fn [_ x y]
((apply zone/box (:box spec)) x y))})
{:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script spec)
(when-let [scripts (:scripts spec)]
(or (scripts (:value cursor)) (scripts :default)))))
:id id}))
entities (into {} (for [[id entity] entities]
[id (make-entity id entity)]))]
(merge params {:collision (advent.pathfind/map-from-resource collision)

View File

@@ -4,6 +4,7 @@
[advent.screens.items :as items]
[advent.utils :as utils]
[advent.tween :as tween]
[advent.zone :as zone]
[clojure.zip :as zip]
[play-clj.core :refer :all]
[play-clj.ui :refer :all]
@@ -230,7 +231,9 @@
(actions/walk-straight-to entities :ego [320 -5])
(actions/transition-background entities :inside-castle [182 90])
(actions/walk-to entities :ego [187 75]))}
:return-portrait {:box [103 70 206 116]
:return-portrait {:mouse-in? (fn [_ x y]
(or ((zone/box 103 70 206 116) x y)
((zone/box 103 116 135 135) x y)))
:script (actions/get-script entities (actions/talk entities :ego "It's the shopkeep's desk."))
:scripts {:portrait (actions/get-script entities
(return-portrait entities))

View File

@@ -89,7 +89,7 @@
:warden "The Duke of Remington is a very stern fellow."
:warden "He doesn't bend the rules, even for young thieves.")
:choices actions/previous-choices}
"Took, son of Luke, son of Puke lended me that ladder!"
"Took, son of Luke, son of Puke lent me that ladder!"
{:run #(actions/respond entities %
:warden "It wasn't his to give."
:warden "In fact, he's off to the gallows come dawn."

View File

@@ -43,7 +43,7 @@
:ego "But I haven't got any money!"
:peddler "Well, I'm afraid you won't have the choicest of earplugs."
:ego "Can't I give you something else for them?"
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
:peddler "I'll tell you what, I don't have anything for the kids that come to my stand."
:peddler "If you can bring me the choicest of toys..."
:peddler "... and I mean the choicest of toys... "
:peddler "I will give you the earplugs."))
@@ -421,7 +421,7 @@
(actions/do-dialogue entities
:ego "It's Angus, Remington's buff bull."
:ego "He's used in all of the town's rodeos."
:ego "Farmer Doug feeds him wild high-protein grass diet to keep him in tiptop shape."
:ego "Farmer Doug feeds him a wild high-protein grass diet to keep him in tiptop shape."
:ego "Phew! His stench has attracted a lot of flies."))
:scripts #(condp = %
:grass (actions/get-script entities

View File

@@ -1412,7 +1412,7 @@ void main ()
:inventory (assoc (utils/get-texture "inventory.png") :x 278 :y 0 :baseline 9000
:mouse-in? (zone/box 278 0 320 42)
:opacity 0.8)
#_#_:fps (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)}))
:fps (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)}))
:on-render
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
@@ -1431,7 +1431,7 @@ 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)))]
#_(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)
(assoc (:save entities) :opacity 0.5))