63 lines
4.8 KiB
Clojure
63 lines
4.8 KiB
Clojure
(ns advent.screens.rooms.space
|
|
(:require [advent.screens.rooms :as rooms]
|
|
[advent.actions :as actions]
|
|
[advent.screens.items :as items]
|
|
[advent.utils :as utils]
|
|
[clojure.zip :as zip]
|
|
[clojure.set :as set]
|
|
[clojure.string :as str]
|
|
[play-clj.core :refer :all]
|
|
[play-clj.ui :refer :all]
|
|
[play-clj.utils :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
(defn taunt [screen entities]
|
|
(when (and (not (get-in entities [:actions :script-running?]))
|
|
(get-in entities [:state :active?])
|
|
(not (get-in entities [:state :blergh-dead?])))
|
|
((actions/get-script entities (actions/do-dialogue entities :blergh (rand-nth ["Come on, little man! Try and hit me!"
|
|
"What's the matter? Cold feet?"
|
|
"Come here and fight me like man!"
|
|
"Your precious Georgia McGorgeous would be laughing if she saw you now."
|
|
"Pick up your weapon and fight!"]))) entities))
|
|
nil)
|
|
|
|
(defn make [screen]
|
|
(let [blergh-stand (texture "space/blergh-stand.png")
|
|
blergh-talk (texture "space/blergh-talk.png")
|
|
blergh-flex (texture "space/blergh-flex.png")
|
|
blergh-talk-anim (animation 0.3 [blergh-talk blergh-stand])
|
|
blergh-stand-anim (animation 0.7 [blergh-flex blergh-stand])
|
|
blergh-swing (utils/make-anim "space/blergh-swing.png" [106 165] 0.1 [0 0 1 2 3 4 ])
|
|
blergh-appear (utils/make-anim "space/blergh-appear.png" [106 165] 0.05 (flatten [(range 13) 12 12 12 12 12 12 12 12 12 12 12 12 12 ]))
|
|
blergh-grow (utils/make-anim "space/blergh-grow.png" [106 165] 0.10 [0 1 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 2 2 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 5 6 7 8 9 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11]) ]
|
|
(rooms/make :music :town-1
|
|
:interactions
|
|
{}
|
|
:layers [(assoc (texture "space/background.png") :x 0 :y 0 :baseline 0)]
|
|
:timers {:taunt [10.0 8.0 taunt]}
|
|
:blergh (rooms/make-entity :blergh (assoc (animation->texture screen blergh-appear)
|
|
:x 180 :y 50 :baseline 190
|
|
:stand blergh-stand-anim :talk blergh-talk-anim
|
|
:swing blergh-swing
|
|
:appear blergh-appear
|
|
:grow blergh-grow
|
|
:talk-color (color 0.95 0.4 0.2 1.0)
|
|
:script (actions/get-script entities (actions/do-dialogue entities :blergh "Come on! Try and hit me!"))
|
|
:scripts {:sword (actions/get-script entities
|
|
(actions/walk-straight-to entities :ego [205 45])
|
|
(actions/play-animation entities :ego :swing)
|
|
(actions/do-dialogue entities :blergh "Ha ha ha! Is that the best you can do?"
|
|
:blergh "Take this!")
|
|
(actions/play-animation entities :blergh :swing)
|
|
(actions/walk-straight-to entities :ego [100 45] :anim :squat :override-dir :right :speed 3.0)
|
|
(actions/do-dialogue entities :ego "Ouch!"
|
|
:blergh "My turn.")
|
|
(actions/transition-background entities :inside-jail [100 100]))}))
|
|
:entities {}
|
|
:collision "space/collision.png"
|
|
:scale-fn (constantly 1.5)
|
|
:start-pos [43 80]
|
|
:apply-state (fn [e]
|
|
(assoc-in e [:room :entities :blergh] (get-in e [:room :blergh]))))))
|