making the coin-getting puzzle.

This commit is contained in:
Bryce Covert
2015-07-29 22:35:47 -07:00
parent d3e75d4835
commit 3f354a6515
20 changed files with 368 additions and 2 deletions

View File

@@ -4,9 +4,13 @@
[advent.screens.items :as items]
[advent.screens.rooms.common :as common]
[advent.utils :as utils]
[advent.tween :as tween]
[clojure.zip :as zip]
[play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.math :refer :all]
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]))
@@ -94,6 +98,21 @@
:scripts {:walkie-talkies (actions/get-script entities
(actions/do-dialogue entities :frankie "Tin cans? What do I need walkie talkies for?"))})))
(defn make-coin-flip [screen]
(let [coin-flip (utils/make-anim "castle-gate/coinflip.png" [10 10] 0.05 (range 5))]
(assoc (animation->texture screen coin-flip)
:x 212 :y 114 :baseline 240
:opacity 0.0
:origin-x 5
:origin-y 5
:night-profile :none
:coinflip coin-flip
#_#_:anim coin-flip
#_#_:anim-start 0
#_#_:stand coin-flip)))
(defn make-goon-1 [screen]
(let [stand (utils/make-anim "castle-gate/goon-1.png" [12 33] 0.21 [0 0 0 0 0 0 0 0 0 1])]
(assoc (animation->texture screen stand)
@@ -106,12 +125,21 @@
:stand stand)))
(defn make-goon-2 [screen]
(let [stand (utils/make-anim "castle-gate/goon-2.png" [12 32] 0.175 [0 0 0 0 0 0 0 0 0 0 0 0 0 1])]
(let [stand (utils/make-anim "castle-gate/goon-2.png" [12 32] 0.175 [0 0 0 0 0 0 0 0 0 0 0 0 0 1])
flip (utils/make-anim "castle-gate/goon-2-flip.png" [12 32] 0.05 [1 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ])]
(assoc (animation->texture screen stand)
:x 208 :y 102 :baseline 138
:scale-x 1.4
:scale-y 1.4
:anim stand
:flip flip
:update-fn (fn [s es e]
(if (and (= (:flip e) (:anim e))
(animation! (:flip e)
:is-animation-finished
(- (:total-time s) (:anim-start e))))
(actions/start-animation s e :stand)
e))
:night-profile :sprite
:anim-start 0
:stand stand)))
@@ -122,12 +150,24 @@
(actions/transition-background entities :inside-castle [280 145])
(actions/walk-to entities :ego [245 90]))
(defn flip-coin [screen entities]
(-> entities
(update-in [:room :entities :coin-flip] (fn [cf] (-> (actions/start-animation screen cf :coinflip)
(assoc :opacity 1.0))))
(assoc-in [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] 112 175 0.5 :ease tween/ease-out-cubic
:finish (fn [e]
(assoc-in e [:tweens :coin-y-2] (tween/tween :coin-y-2 (assoc screen :total-time (+ 0.5 (:total-time screen))) [:room :entities :coin-flip :y] 174 112 0.5 :ease tween/ease-in-cubic
:finish (fn [e]
(assoc-in e [:room :entities :coin-flip :opacity] 0.0)))))))
(update-in [:room :entities :goon-2] (fn [g] (-> (actions/start-animation screen g :flip))))))
(defn make [screen]
(let [throw-walkie (utils/make-anim "castle-gate/throw-walkie.png" [205 136] 0.1 (flatten [(repeat 55 0) (range 9) (repeat 55 8)]))
walkie-visible (animation 1.0 [(last (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])
walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])]
(rooms/make :music {:day :town-2 :night :night}
:timers {:taunt [4.0 8.0 flip-coin]}
:interactions {:right-dir {:box [300 40 320 83]
:script (actions/get-script entities
(actions/walk-to entities :ego [301 46] :face :right)
@@ -163,6 +203,7 @@
:goon-1 (make-goon-1 screen)
:goon-2 (make-goon-2 screen)
:outside-particles (common/make-outside-particles)
:coin-flip (make-coin-flip screen)
}
:walkie-talkies (rooms/make-entity :walkie-talkies
(assoc (animation->texture screen walkie-visible)

View File

@@ -750,6 +750,7 @@ void main()
:on-timer
(fn [screen [entities]]
(when-let [timer-fn (get-in entities [:room :timers (:id screen) 2])]
(println "here")
(timer-fn screen entities)))
:on-show