first step at dialogue trees.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
[advent.pathfind])
|
||||
[advent.pathfind]
|
||||
#_[advent.screens.scene :as scene])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.scenes.scene2d.utils Align]))
|
||||
@@ -52,3 +53,36 @@
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(size! screen 1280 960)))
|
||||
|
||||
(defscreen choice-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
(update! screen :renderer (stage) :camera (orthographic))
|
||||
{})
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
(render! screen (vals entities))
|
||||
entities)
|
||||
|
||||
:on-present-choices
|
||||
(fn [{:keys [pairs]} [entities]]
|
||||
(let [font (bitmap-font "ego/font.fnt" )
|
||||
tr (bitmap-font! font :get-region)
|
||||
scale 1
|
||||
width (/ (game :width) 1.5)
|
||||
tx (.getTexture tr)
|
||||
_ (texture! tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)]
|
||||
(into entities (for [[[text result-script] i] (map vector pairs (range))]
|
||||
(do (println result-script)
|
||||
[i (assoc (label text (style :label font (color :white))) :x 0 :y (* 20 i) :result-script result-script)])))))
|
||||
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||
(when (seq entities)
|
||||
(when (< y (* 20 (count entities)))
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-start-script :script (:result-script (entities (int (/ y 20)))))
|
||||
{}))))
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(size! screen 1280 960)))
|
||||
|
||||
@@ -155,18 +155,49 @@
|
||||
(aget peddler-sheet 0 i)))
|
||||
peddler-stand (animation 0.2 (for [i (flatten [(repeat 5 0) 6])]
|
||||
(aget peddler-sheet 0 i)))
|
||||
wizard (texture "wizard.png")
|
||||
_ (texture! wizard :flip true false)]
|
||||
wizard-sheet (texture! (texture "wizard/talk.png") :split 20 46)
|
||||
wizard-stand (animation 0.2 (for [i (flatten [(repeat 10 0) 1])]
|
||||
(aget wizard-sheet 0 i)))
|
||||
wizard-talk (animation 0.2 (for [i [0 2 0 2 1 2 0 3 0 2 0 1 0 2]]
|
||||
(aget wizard-sheet 0 i)))]
|
||||
{:inside-house
|
||||
(make-background :interactions {:down-dir {:box [151 0 320 20]
|
||||
:script (actions/get-script entities
|
||||
(actions/walk-to entities :ego [237 1])
|
||||
(actions/transition-background entities :outside-house [262 88]))
|
||||
:cursor :down}}
|
||||
:cursor :down}
|
||||
:wizard {:box [228 80 248 126]
|
||||
:script (actions/get-script entities
|
||||
(actions/talk entities :ego "Hello there Fangald!")
|
||||
(actions/talk entities :wizard "Oh no, not you again!")
|
||||
(actions/present-choices entities "You're not my friend, Mr. Fangald?"
|
||||
(actions/get-script entities
|
||||
(actions/talk entities :ego "You're not my friend, Mr. Fangald?")
|
||||
(actions/talk entities :wizard "No, you are a rascally little boy who is nothing but a cheat!")
|
||||
(actions/present-choices entities
|
||||
"Oh, come on, I'm not that bad."
|
||||
(actions/get-script entities
|
||||
(actions/talk entities :ego "Oh, come on, I'm not that bad.")
|
||||
(actions/talk entities :wizard "Yes you are. Shoo!"))
|
||||
"I'm sorry."
|
||||
(actions/get-script entities
|
||||
(actions/talk entities :ego "I'm sorry")
|
||||
(actions/talk entities :wizard "That's better. Now scram."))
|
||||
))
|
||||
"Yes, it's me!"
|
||||
(actions/get-script entities
|
||||
(actions/talk entities :ego "Yes, it's me!")
|
||||
(actions/talk entities :wizard "Great, just great. Leave me alone."))))}}
|
||||
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200)
|
||||
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)]
|
||||
:entities {:wizard (assoc wizard :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75)}
|
||||
:entities {:wizard (actions/start-animation screen (assoc (animation->texture screen wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75
|
||||
:left {:talk (flip wizard-talk)
|
||||
:stand (flip wizard-stand)}
|
||||
:right {:talk wizard-talk
|
||||
:stand wizard-stand}
|
||||
:facing :left)
|
||||
:stand)}
|
||||
:collision "inside-house/collision.png"
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.75))
|
||||
:outside-house
|
||||
@@ -312,7 +343,7 @@
|
||||
(update! screen :renderer (stage) :camera (orthographic))
|
||||
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
|
||||
music (sound "town-music.mp3")
|
||||
_ (sound! music :loop 0.20)
|
||||
;; _ (sound! music :loop 0.20)
|
||||
backgrounds (backgrounds screen)]
|
||||
{:backgrounds backgrounds
|
||||
:actions {:object nil
|
||||
@@ -361,4 +392,8 @@
|
||||
(if (= (button-code :right)
|
||||
(:button screen))
|
||||
(assoc-in entities [:cursor :current] :main)
|
||||
(left-click screen entities))))
|
||||
(left-click screen entities)))
|
||||
|
||||
:on-start-script (fn [{:keys [script]} [entities] ]
|
||||
(script entities)
|
||||
entities))
|
||||
|
||||
Reference in New Issue
Block a user