moving ego into background.
This commit is contained in:
@@ -120,7 +120,11 @@
|
||||
(defn backgrounds [screen]
|
||||
(let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21)
|
||||
sheep (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])]
|
||||
(aget sheep-sheet 0 i)))]
|
||||
(aget sheep-sheet 0 i)))
|
||||
|
||||
peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36)
|
||||
peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])]
|
||||
(aget peddler-sheet 0 i)))]
|
||||
{:outside-house
|
||||
(make-background :interactions
|
||||
{:door {:box [258 100 281 160]
|
||||
@@ -137,7 +141,7 @@
|
||||
:sheep {:box [38 160 71 181]
|
||||
:script (actions/get-script
|
||||
entities
|
||||
(if ((get-in @entities [:ego :inventory]) :wool)
|
||||
(if ((get-in @entities [:background :entities :ego :inventory]) :wool)
|
||||
(actions/talk entities :ego "The sheep has given me enough wool.")
|
||||
(do (actions/give entities :ego :wool)
|
||||
(actions/talk entities :ego "I guess his wool is shedding."))))}
|
||||
@@ -161,7 +165,7 @@
|
||||
(assoc (texture "house.png") :x 0 :y 0 :baseline 122)
|
||||
(assoc (texture "overdirt.png") :x 0 :y 0 :baseline 240)
|
||||
(assoc (texture "background-trees.png") :x 0 :y 0 :baseline 44)]
|
||||
:entities [(assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)]
|
||||
:entities {:sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)}
|
||||
:collision "outsidehouse/collision.png"
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))
|
||||
|
||||
@@ -177,9 +181,17 @@
|
||||
:script (actions/get-script
|
||||
entities
|
||||
(actions/walk-to entities :ego [191 90])
|
||||
(actions/talk entities :ego "Hello there."))}}
|
||||
(actions/talk entities :ego "Hello there, peddler.")
|
||||
(actions/talk entities :peddler "Good day sir! Care to see any of my wares?")
|
||||
(actions/talk entities :peddler "I have only the choicest of wares.")
|
||||
(actions/talk entities :ego "What 'wares' are you selling?")
|
||||
(actions/talk entities :peddler "I have all types of wares...")
|
||||
(actions/talk entities :peddler "...I'm well stocked on used earplugs...")
|
||||
(actions/talk entities :peddler "...glass eyes, motivational tapes... ")
|
||||
(actions/talk entities :peddler "...and useful books like this:")
|
||||
(actions/talk entities :peddler "'Checkers Mastery in Less Than 10 Seconds'"))}}
|
||||
:layers [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
|
||||
:entities [(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150)]
|
||||
:entities {:peddler (assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil :talk peddler-talk)}
|
||||
:collision "outside-castle/collision.png"
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))}))
|
||||
|
||||
@@ -205,8 +217,8 @@
|
||||
:current :main
|
||||
:last :main
|
||||
:override nil}
|
||||
:background (:outside-house backgrounds)
|
||||
:ego (get-ego screen)
|
||||
:background (assoc-in (:outside-house backgrounds)
|
||||
[:entities :ego] (get-ego screen))
|
||||
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 9000)
|
||||
}))
|
||||
|
||||
@@ -217,9 +229,13 @@
|
||||
#_(.glEnable (.getGL30 Gdx/graphics) GL30/GL_BLEND)
|
||||
(let [entities (update-cursor screen entities)
|
||||
entities (update-from-script screen entities)
|
||||
entities (update-in entities [:background :entities] (fn [entities] (map #(animate % screen) entities)))
|
||||
entities (update-in entities [:ego] #(animate % screen))
|
||||
all-entities (concat (vals entities) (get-in entities [:background :layers]) (get-in entities [:background :entities]))]
|
||||
entities (update-in entities [:background :entities] (fn [entities]
|
||||
(into entities
|
||||
(for [[id entity] entities]
|
||||
(if (:anim entity)
|
||||
[id (animate entity screen)]
|
||||
[id entity])))))
|
||||
all-entities (concat (vals entities) (get-in entities [:background :layers]) (vals (get-in entities [:background :entities])))]
|
||||
(label! (:fps entities) :set-text (str (game :fps)))
|
||||
(render! screen (sort-by :baseline all-entities))
|
||||
entities))
|
||||
|
||||
Reference in New Issue
Block a user