an alternative approach to text.
This commit is contained in:
@@ -129,6 +129,31 @@
|
||||
(< x1 x x2)
|
||||
(< y1 y y2))))
|
||||
|
||||
(defscreen talking-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
(update! screen :renderer (stage) :camera (orthographic)) [])
|
||||
:on-render
|
||||
(fn [screen entities]
|
||||
(render! screen entities)
|
||||
entities)
|
||||
|
||||
:on-talk
|
||||
(fn [{:keys [create-talk text x y]} entities]
|
||||
[(let [font (bitmap-font "mainfont.fnt" )
|
||||
tr (bitmap-font! font :get-region)
|
||||
tx (.getTexture tr)
|
||||
_ (texture! tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
||||
talk (assoc (label text (style :label font (color :white)) ) :x (* 4 x) :y (* 4 y))]
|
||||
(label! talk :set-font-scale 1)
|
||||
talk)])
|
||||
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(height! screen (game :height)))
|
||||
|
||||
)
|
||||
|
||||
(defscreen main-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
@@ -159,21 +184,11 @@
|
||||
:go-to [0 80]}]
|
||||
:interactions [{:mouse-in? (box-maker-fn 258 100 281 160)
|
||||
:click-fn (fn [screen entities [x y]]
|
||||
(assoc-in entities [:ego :actions] (concat (path-to-actions screen entities :ego [262 80])
|
||||
[(fn [screen entities]
|
||||
|
||||
(let [font (bitmap-font "mainfont.fnt" )
|
||||
tr (bitmap-font! font :get-region)
|
||||
tx (.getTexture tr)
|
||||
_ (texture! tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
||||
|
||||
|
||||
talk (assoc (label "Knock knock. Anyone home?" (style :label font (color :white)) ) :x 5 :y 100 :baseline 9000)]
|
||||
|
||||
(label! talk :set-font-scale 0.25)
|
||||
(-> entities
|
||||
(assoc :talking talk)
|
||||
(update-in [:ego :actions] rest))))])))}]
|
||||
(assoc-in entities [:ego :actions] [(fn [screen entities]
|
||||
(run! talking-screen :on-talk :text "It's the door to Merlin's house."
|
||||
:x (get-in entities [:ego :x]) :y (+ (get-in entities [:ego :y]) 25) )
|
||||
(-> entities
|
||||
(update-in [:ego :actions] rest)))]))}]
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))
|
||||
:house (assoc house
|
||||
:x 0 :y 0
|
||||
@@ -190,7 +205,6 @@
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
(clear!)
|
||||
(let [entities (update-ego screen entities (:ego entities))
|
||||
_ (label! (:fps entities) :set-text (str (game :fps)))
|
||||
entities (if (get-in entities [:ego :anim])
|
||||
@@ -222,4 +236,4 @@
|
||||
(defgame advent
|
||||
:on-create
|
||||
(fn [this]
|
||||
(set-screen! this main-screen)))
|
||||
(set-screen! this main-screen talking-screen)))
|
||||
|
||||
Reference in New Issue
Block a user