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,9 +30,11 @@
(or (scripts (:value cursor)) (scripts :default)))))}))) (or (scripts (:value cursor)) (scripts :default)))))})))
(defn make [& {:keys [collision interactions entities] :as params}] (defn make [& {:keys [collision interactions entities] :as params}]
(let [interactions-as-list (for [[id spec] interactions] (let [interactions-as-list (for [[id spec] interactions]
(merge spec {:mouse-in? (fn [_ x y] (merge spec
((apply zone/box (:box spec)) x y)) (when (:box spec)
:get-script (fn [cursor [x y]] {:mouse-in? (fn [_ x y]
((apply zone/box (:box spec)) x y))})
{:get-script (fn [cursor [x y]]
(if (= :main cursor) (if (= :main cursor)
(:script spec) (:script spec)
(when-let [scripts (:scripts spec)] (when-let [scripts (:scripts spec)]

View File

@@ -4,6 +4,7 @@
[advent.screens.items :as items] [advent.screens.items :as items]
[advent.utils :as utils] [advent.utils :as utils]
[advent.tween :as tween] [advent.tween :as tween]
[advent.zone :as zone]
[clojure.zip :as zip] [clojure.zip :as zip]
[play-clj.core :refer :all] [play-clj.core :refer :all]
[play-clj.ui :refer :all] [play-clj.ui :refer :all]
@@ -230,7 +231,9 @@
(actions/walk-straight-to entities :ego [320 -5]) (actions/walk-straight-to entities :ego [320 -5])
(actions/transition-background entities :inside-castle [182 90]) (actions/transition-background entities :inside-castle [182 90])
(actions/walk-to entities :ego [187 75]))} (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.")) :script (actions/get-script entities (actions/talk entities :ego "It's the shopkeep's desk."))
:scripts {:portrait (actions/get-script entities :scripts {:portrait (actions/get-script entities
(return-portrait entities)) (return-portrait entities))

View File

@@ -89,7 +89,7 @@
:warden "The Duke of Remington is a very stern fellow." :warden "The Duke of Remington is a very stern fellow."
:warden "He doesn't bend the rules, even for young thieves.") :warden "He doesn't bend the rules, even for young thieves.")
:choices actions/previous-choices} :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 % {:run #(actions/respond entities %
:warden "It wasn't his to give." :warden "It wasn't his to give."
:warden "In fact, he's off to the gallows come dawn." :warden "In fact, he's off to the gallows come dawn."

View File

@@ -421,7 +421,7 @@
(actions/do-dialogue entities (actions/do-dialogue entities
:ego "It's Angus, Remington's buff bull." :ego "It's Angus, Remington's buff bull."
:ego "He's used in all of the town's rodeos." :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.")) :ego "Phew! His stench has attracted a lot of flies."))
:scripts #(condp = % :scripts #(condp = %
:grass (actions/get-script entities :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 :inventory (assoc (utils/get-texture "inventory.png") :x 278 :y 0 :baseline 9000
:mouse-in? (zone/box 278 0 320 42) :mouse-in? (zone/box 278 0 320 42)
:opacity 0.8) :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 :on-render
(fn [{:keys [^FitViewport viewport] :as screen} [entities]] (fn [{:keys [^FitViewport viewport] :as screen} [entities]]
@@ -1431,7 +1431,7 @@ 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)))]
#_(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)
(assoc (:save entities) :opacity 0.5)) (assoc (:save entities) :opacity 0.5))