220 lines
17 KiB
Clojure
220 lines
17 KiB
Clojure
(ns advent.screens.rooms.ending
|
|
(:require
|
|
[clojure.core.async :as a]
|
|
[advent.screens.rooms :as rooms]
|
|
[advent.screens.rooms.common :as common]
|
|
[advent.actions :as actions]
|
|
[advent.screens.items :as items]
|
|
[advent.tween :as tween]
|
|
[advent.utils :as utils]
|
|
[clojure.zip :as zip]
|
|
[clojure.set :as set]
|
|
[clojure.string :as str]
|
|
[play-clj.core :refer :all]
|
|
[play-clj.math :refer :all]
|
|
[play-clj.ui :refer :all]
|
|
[play-clj.utils :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
(defn disappear [entities]
|
|
(actions/run-action entities
|
|
(begin [this screen entities]
|
|
(-> entities
|
|
|
|
(assoc-in [:tweens :disappear-ego]
|
|
(tween/tween :disappear-ego screen [:room :entities :ego :opacity] 1.0 0.0 0.5 :ease tween/ease-in-out-quintic))))
|
|
|
|
(continue [this screen entities]
|
|
entities)
|
|
|
|
(done? [this screen entities]
|
|
(= 0.0 (get-in entities [:room :entities :ego :opacity])))
|
|
|
|
(terminate [this screen entities]
|
|
entities)
|
|
(skip-type [this screen entities]
|
|
:none)))
|
|
|
|
(defn fade-out [entities]
|
|
(actions/run-action entities
|
|
(begin [this screen entities]
|
|
(-> entities
|
|
(assoc-in [:tweens :fade-out]
|
|
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 3.5 :ease tween/ease-in-out-quintic))))
|
|
(continue [this screen entities]
|
|
entities)
|
|
|
|
(done? [this screen entities]
|
|
(= 1.0 (get-in entities [:fade :opacity])))
|
|
|
|
(terminate [this screen entities]
|
|
entities)
|
|
(skip-type [this screen entities]
|
|
:none)))
|
|
|
|
|
|
(defn make [screen]
|
|
(let [
|
|
peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36)
|
|
peddler-stand (utils/flip (animation 0.2 (for [i (flatten [(repeat 8 0) 6 (repeat 8 0) 6 (repeat 5 0) 4 5 4 5 4 5])]
|
|
(aget peddler-sheet 0 i))))
|
|
warden-stand (utils/make-anim "ending-castle/warden-2.png" [21 41] 0.21 (flatten [(repeat 7 0) 1]))
|
|
|
|
game-player-stand (utils/make-anim "ending-castle/game-player.png" [14 39] 0.2 (flatten [(repeat 5 0) 1] ))
|
|
|
|
ladder-guard-stand-1 (animation 0.1 [(texture "inside-cafeteria/ladder-guard-2.png")])
|
|
ladder-guard-stand-2 (utils/flip (animation 0.1 [(texture "inside-cafeteria/ladder-guard-2.png")]))
|
|
grandma-stand (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1])
|
|
cat-stand (utils/make-anim "cat-tree/cat-stand.png" [22 10] 0.15 (flatten [(repeat 10 0) 1 1 (repeat 10 0) 2 3 4 3 0 0 2 3 4 3 (repeat 10 0) 1 1 (repeat 10 0) 5 5 6 6 7 (repeat 10 [7 8]) 6 5 0]))
|
|
duke-stand (utils/make-anim "ending-castle/duke.png" [40 48] 0.23 (flatten [(repeat 4 0) 1]))
|
|
duke-talk (utils/make-anim "ending-castle/duke.png" [40 48] 0.23 [0 2 0 2 1 2])
|
|
duke-reach (utils/make-anim "ending-castle/duke.png" [40 48] 0.23 [3 4 5 6])
|
|
duke-reach-talk (utils/make-anim "ending-castle/duke.png" [40 48] 0.23 [6 7])
|
|
duke-knight (utils/make-anim "ending-castle/duke.png" [40 48] 0.23 [8 9 10 9 8])
|
|
scaler (utils/scaler-fn-with-baseline 20 0.01 1.20)]
|
|
(rooms/make :music :dream
|
|
:interactions {}
|
|
:layers [(assoc (texture "ending-castle/ending-castle2-assets/background.png") :x 0 :y 0 :origin-x 0 :origin-y 0 :baseline 0)
|
|
(assoc (texture "ending-castle/ending-castle2-assets/foreground.png") :x 160 :y 0 :origin-x 165 :origin-y 5 :baseline 240 :parallax 1.4)]
|
|
:entities {:peddler (assoc (animation->texture screen peddler-stand)
|
|
:x 245 :y 46 :baseline 200
|
|
:anim peddler-stand
|
|
:anim-start 0
|
|
:scaled true)
|
|
:warden (assoc (animation->texture screen warden-stand)
|
|
:x 40 :y 50 :baseline (- 240 50)
|
|
:anim warden-stand
|
|
:anim-start 0
|
|
:scale-x 1.1
|
|
:scale-y 1.1
|
|
)
|
|
:gandarf (assoc (common/make-wizard screen {:x 205 :y 400 :baseline 199})
|
|
:update-fn (fn [screen entities gandarf]
|
|
(assoc gandarf :y (or (get-in entities [:gandarf-cloud :y])
|
|
(:y gandarf)))))
|
|
:gandarf-cloud (doto (assoc (particle-effect "wizard/gandarf-cloud") :x 215 :y 400
|
|
:baseline 200)
|
|
(particle-effect! :set-position 215 130))
|
|
:duke (assoc (animation->texture screen duke-stand)
|
|
:x 117 :y 50 :baseline (- 240 50)
|
|
:anim duke-stand
|
|
:anim-start 0
|
|
:talk-color (color 0.4 0.5 0.94 1.0)
|
|
:talk duke-talk
|
|
:stand duke-stand
|
|
:reach duke-reach
|
|
:reach-talk duke-reach-talk
|
|
:knight duke-knight
|
|
:script (actions/get-script entities
|
|
(actions/do-stop entities :ego :face :left)
|
|
(actions/do-dialogue entities
|
|
:duke "Ladies and gentlemen."
|
|
:duke "As the Duke of Remington, I'm pleased to inform you..."
|
|
:duke "The goblin by the name of Bloodclot has been destroyed!"
|
|
:duke "Our town is saved."
|
|
:duke "Thanks to this young boy, Tick."
|
|
:duke "It is my rightful duty as Duke of Remington to knight you."
|
|
:duke "You've proven yourself worthy."
|
|
:duke "Your sword, please.")
|
|
(actions/walk-straight-to entities :ego [150 49])
|
|
(actions/play-animation entities :ego :reach-start :stop? false)
|
|
(actions/play-animation entities :duke :reach :stop? false)
|
|
(actions/play-animation entities :ego :reach-stop :stop? false)
|
|
(actions/talk entities :duke "Kneel." :anim :reach-talk :stop? false)
|
|
(actions/play-animation entities :ego :start-squat-2 :stop? false)
|
|
(Thread/sleep 1000)
|
|
(actions/play-animation entities :duke :knight :stop? false)
|
|
(actions/update-entity entities :duke (fn [d] (assoc d :baseline (- 240 48))))
|
|
(actions/play-animation entities :duke :knight :stop? false)
|
|
(actions/talk entities :duke "In honor of your bravery..." :anim :reach-talk :stop? false)
|
|
(actions/talk entities :duke "I declare you Sir Tick of Remington." :anim :reach-talk)
|
|
(actions/play-animation entities :ego :end-squat :stop? true)
|
|
(Thread/sleep 500)
|
|
(actions/glad entities)
|
|
(Thread/sleep 200)
|
|
(actions/do-dialogue entities :ego "Wait...")
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :right)
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :left)
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :right)
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :left)
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :right)
|
|
(Thread/sleep 400)
|
|
(actions/do-stop entities :ego :face :left)
|
|
(Thread/sleep 400)
|
|
(actions/do-dialogue entities :ego "Where's Georgia McGorgeous?")
|
|
(actions/walk-straight-to entities :gandarf-cloud [215 100] :update-baseline? false)
|
|
(actions/do-dialogue entities :gandarf "Quickly, boy!")
|
|
(actions/do-stop entities :ego :face :right)
|
|
(actions/do-dialogue entities :ego "Gandarf?"
|
|
:gandarf "Yes, it is I!"
|
|
:ego "How did you escape?"
|
|
:gandarf "No time for that!"
|
|
:gandarf "Georgia McGorgeous has been captured!"
|
|
:ego "Captured?! By who?"
|
|
:gandarf "Bloodclot's second-in-command, Swinebreath."
|
|
:gandarf "I'm afraid that I can't save her."
|
|
:gandarf "This is a job for a knight."
|
|
:gandarf "If you are willing, Tick..."
|
|
:duke "That's 'Sir Tick'..."
|
|
:gandarf "Quite right, quite right."
|
|
:gandarf "If you are willing, Sir Tick..."
|
|
:gandarf "I can transport you to the land where her prision lies."
|
|
:gandarf "But it is far out of my sight, and I know not what you'll find."
|
|
:gandarf "Well? What say you?"
|
|
:ego "I'll do it! "
|
|
:gandarf "Very good."
|
|
:gandarf "Prepare yourself.")
|
|
(Thread/sleep 300)
|
|
(actions/talk entities :gandarf "Beamium Up!!!" :anim :talk-angry)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :reset)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :start)
|
|
(disappear entities)
|
|
(fade-out entities)
|
|
(on-gl (set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.credits/credits)))))
|
|
:magic-frog-particle (doto (assoc (particle-effect "inside-house/magic-frog") :x 140 :y 49
|
|
:baseline 241)
|
|
(particle-effect! :set-position 150 49))
|
|
:ladder-guard-1 (assoc (animation->texture screen ladder-guard-stand-1)
|
|
:x 75 :y 69 :baseline (- 240 69)
|
|
:anim ladder-guard-stand-1
|
|
:anim-start 0
|
|
:scaled true
|
|
:scale-x (scaler [71 150])
|
|
:scale-y (scaler [71 150]))
|
|
:ladder-guard-2 (assoc (animation->texture screen ladder-guard-stand-2)
|
|
:x 179 :y 69 :baseline (- 240 69)
|
|
:anim ladder-guard-stand-2
|
|
:anim-start 0
|
|
:scaled true
|
|
:scale-x (scaler [179 150])
|
|
:scale-y (scaler [179 150]))
|
|
:game-player (assoc (animation->texture screen game-player-stand)
|
|
:x 216 :y 69 :baseline (- 240 69)
|
|
:anim game-player-stand
|
|
:anim-start 0
|
|
:scale-x (scaler [179 69])
|
|
:scale-y (scaler [179 69])
|
|
:scaled true)
|
|
:grandma (assoc (animation->texture screen grandma-stand)
|
|
:x 56 :y 77 :baseline (- 240 77)
|
|
:anim grandma-stand
|
|
:anim-start 0
|
|
:scale-x (scaler [56 77])
|
|
:scale-y (scaler [56 77])
|
|
:scaled true)
|
|
:cat (assoc (animation->texture screen cat-stand)
|
|
:x 73 :y 194 :baseline (- 240 195)
|
|
:anim cat-stand
|
|
:anim-start 0
|
|
:scale-x 0.65
|
|
:scale-y 0.65
|
|
:scaled true)}
|
|
:collision "ending-castle/ending-castle2-assets/collision.png"
|
|
:scale-fn scaler
|
|
:start-pos [165 49])))
|