jail scene coming together
This commit is contained in:
@@ -1 +1 @@
|
|||||||
{:active? true, :convinced-wizard? true, :inventory [:ladder :flask-1 :grass :medal :kiss :trophy :flask-1-strength :sword ], :wizard-left? false, :clues #{}, :current-riddle :wool, :last-room :inside-jail, :wants-toy true, :mints-eaten 0, :object nil, :obtained-items #{:kiss :medal :sword :flask-1 :grass :ladder :trophy}}
|
{:active? true, :convinced-wizard? true, :inventory [] :chest-contents [:ladder :flask-1 :grass :medal :kiss :trophy :flask-1-strength :sword ], :wizard-left? false, :clues #{}, :current-riddle :wool, :last-room :inside-jail, :wants-toy true, :mints-eaten 0, :object nil, :obtained-items #{:kiss :medal :sword :flask-1 :grass :ladder :trophy}}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@@ -113,6 +113,7 @@
|
|||||||
(defn stop [screen entities target-id & {:keys [face]}]
|
(defn stop [screen entities target-id & {:keys [face]}]
|
||||||
(update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity))))
|
(update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity))))
|
||||||
|
|
||||||
|
|
||||||
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir]}]
|
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir]}]
|
||||||
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
||||||
final-x (int final-x)
|
final-x (int final-x)
|
||||||
@@ -187,6 +188,18 @@
|
|||||||
(terminate [this screen entities] entities)
|
(terminate [this screen entities] entities)
|
||||||
(can-skip? [this screen entities] false)))
|
(can-skip? [this screen entities] false)))
|
||||||
|
|
||||||
|
(defn stop-walking [entities target-id & {:keys [face]}]
|
||||||
|
(run-action entities
|
||||||
|
(begin [this screen entities]
|
||||||
|
(stop screen entities target-id :face face))
|
||||||
|
|
||||||
|
(continue [this screen entities] entities)
|
||||||
|
|
||||||
|
(done? [this screen entities] true)
|
||||||
|
|
||||||
|
(terminate [this screen entities] entities)
|
||||||
|
(can-skip? [this screen entities] false)))
|
||||||
|
|
||||||
(defn walk-to [entities target-id [final-x final-y] & {:keys [can-skip? face]}]
|
(defn walk-to [entities target-id [final-x final-y] & {:keys [can-skip? face]}]
|
||||||
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
||||||
final-x (int final-x)
|
final-x (int final-x)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns advent.screens.rooms.inside-jail
|
(ns advent.screens.rooms.inside-jail
|
||||||
(:require [advent.screens.rooms :as rooms]
|
(:require [clojure.core.async :refer [chan]]
|
||||||
|
[advent.screens.rooms :as rooms]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.screens.items :as items]
|
[advent.screens.items :as items]
|
||||||
[advent.utils :as utils]
|
[advent.utils :as utils]
|
||||||
@@ -30,6 +31,9 @@
|
|||||||
(actions/do-dialogue entities
|
(actions/do-dialogue entities
|
||||||
:ego "Hey!"
|
:ego "Hey!"
|
||||||
:ego "All my possessions are in here!")
|
:ego "All my possessions are in here!")
|
||||||
|
(actions/update-state entities #(-> %
|
||||||
|
(assoc :inventory (concat (:inventory %) (:chest-contents %)))
|
||||||
|
(assoc :chest-contents [])))
|
||||||
(when (not (actions/has-obtained? entities :rope))
|
(when (not (actions/has-obtained? entities :rope))
|
||||||
(actions/do-dialogue entities :ego "Looks like there's some rope in here too.")))
|
(actions/do-dialogue entities :ego "Looks like there's some rope in here too.")))
|
||||||
|
|
||||||
@@ -121,6 +125,11 @@
|
|||||||
:ego "Maybe you should give it a rest.")))
|
:ego "Maybe you should give it a rest.")))
|
||||||
(actions/update-state entities #(assoc % :hay-searches (inc hay-searches)))))
|
(actions/update-state entities #(assoc % :hay-searches (inc hay-searches)))))
|
||||||
|
|
||||||
|
(defn go-to-jail [entities]
|
||||||
|
(actions/update-state entities #(assoc % :chest-contents (remove #{:key} (:inventory %))))
|
||||||
|
(actions/update-state entities #(assoc % :inventory []))
|
||||||
|
(actions/update-state entities #(assoc % :opened-bars? false))
|
||||||
|
(actions/transition-background entities :inside-jail [130 85]))
|
||||||
|
|
||||||
|
|
||||||
(defn make [screen]
|
(defn make [screen]
|
||||||
@@ -152,10 +161,40 @@
|
|||||||
:script (actions/get-script entities
|
:script (actions/get-script entities
|
||||||
(search-hay entities))}
|
(search-hay entities))}
|
||||||
:chest {:box [194 62 228 99]
|
:chest {:box [194 62 228 99]
|
||||||
:script (actions/get-script entities (touch-chest entities))}}
|
:script (actions/get-script entities (touch-chest entities))}
|
||||||
|
:door {:box [257 62 301 152]
|
||||||
|
:cursor :down
|
||||||
|
:script (actions/get-script entities
|
||||||
|
(if (get-in @entities [:state :opened-bars?])
|
||||||
|
(do
|
||||||
|
(actions/walk-to entities :ego [279 57])
|
||||||
|
(actions/transition-background entities :outside-jail [50 46] ))
|
||||||
|
(actions/talk entities :ego "Do you really think I can walk down those steps while I'm locked up?")))}}
|
||||||
:layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0)
|
:layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0)
|
||||||
(assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165)
|
(assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165)
|
||||||
(assoc (texture "inside-jail/glow.png") :x 0 :y 0 :baseline 240)]
|
(assoc (texture "inside-jail/glow.png") :x 0 :y 0 :baseline 240)]
|
||||||
|
:hotspots [{:box [121 40 258 44]
|
||||||
|
:fn (fn [screen entities]
|
||||||
|
|
||||||
|
(let [is-walking? (#{(get-in entities [:room :entities :ego :left :walk])
|
||||||
|
(get-in entities [:room :entities :ego :right :walk])} (get-in entities [:room :entities :ego :anim]))]
|
||||||
|
(if is-walking?
|
||||||
|
(let [entities (-> entities
|
||||||
|
(update-in [:actions] #(assoc % :channel (chan) :current nil :started? false))
|
||||||
|
(update-in [:room :entities :ego] #(actions/start-animation screen % :stand)))]
|
||||||
|
((actions/get-script entities
|
||||||
|
(actions/stop-walking entities :ego)
|
||||||
|
(actions/do-dialogue entities
|
||||||
|
:ego "*creak*"
|
||||||
|
:ego "Oops!"
|
||||||
|
:warden "Hey! What are you doing?"
|
||||||
|
:warden "Get back in jail.")
|
||||||
|
(go-to-jail entities)
|
||||||
|
(actions/do-dialogue entities :warden "Now don't let me catch you trying to escape again.")
|
||||||
|
(actions/play-animation entities :warden :fall-asleep :stop? false)
|
||||||
|
(actions/begin-animation entities :warden :sleep)) entities)
|
||||||
|
entities)
|
||||||
|
entities)))}]
|
||||||
:entities {:warden (assoc (texture "inside-jail/warden.png" )
|
:entities {:warden (assoc (texture "inside-jail/warden.png" )
|
||||||
:x 40 :y 60 :baseline 166
|
:x 40 :y 60 :baseline 166
|
||||||
:stand warden-stand
|
:stand warden-stand
|
||||||
@@ -192,7 +231,7 @@
|
|||||||
:start-pos [130 85]
|
:start-pos [130 85]
|
||||||
:apply-state (fn [entities]
|
:apply-state (fn [entities]
|
||||||
(as-> entities entities
|
(as-> entities entities
|
||||||
(if (actions/has-item? entities :ball-n-chain)
|
(if (actions/has-obtained? entities :ball-n-chain)
|
||||||
(update-in entities [:room :entities] #(dissoc % :ball-n-chain))
|
(update-in entities [:room :entities] #(dissoc % :ball-n-chain))
|
||||||
entities)
|
entities)
|
||||||
(if (get-in entities [:state :warden-sleeping?])
|
(if (get-in entities [:state :warden-sleeping?])
|
||||||
|
|||||||
@@ -252,6 +252,13 @@
|
|||||||
(assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?])}))))
|
(assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?])}))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn update-from-hotspots [screen entities]
|
||||||
|
(if-let [hot-spots (get-in entities [:room :hotspots])]
|
||||||
|
(if-let [hotspot-hit (first (filter #((apply zone/box (:box %)) (get-in entities [:room :entities :ego :x]) (get-in entities [:room :entities :ego :y])) hot-spots))]
|
||||||
|
((:fn hotspot-hit) screen entities)
|
||||||
|
entities)
|
||||||
|
entities))
|
||||||
|
|
||||||
(defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}]
|
(defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}]
|
||||||
(let [new-current (or override current)]
|
(let [new-current (or override current)]
|
||||||
(when-not (= new-current
|
(when-not (= new-current
|
||||||
@@ -349,6 +356,7 @@
|
|||||||
(clear!)
|
(clear!)
|
||||||
(let [entities (update-cursor screen entities)
|
(let [entities (update-cursor screen entities)
|
||||||
entities (update-from-script screen entities)
|
entities (update-from-script screen entities)
|
||||||
|
entities (update-from-hotspots screen entities)
|
||||||
entities (assoc-in entities [:room :entities :ego :last-frame] (get-in entities [:room :entities :ego :object]))
|
entities (assoc-in entities [:room :entities :ego :last-frame] (get-in entities [:room :entities :ego :object]))
|
||||||
entities (update-in entities [:room :entities] (fn [entities]
|
entities (update-in entities [:room :entities] (fn [entities]
|
||||||
(into entities
|
(into entities
|
||||||
|
|||||||
Reference in New Issue
Block a user