first attempt at an intro screen.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
[play-clj.g2d :refer :all]
|
||||
[advent.screens.scene :as scene]
|
||||
[advent.screens.dialogue :as dialogue]
|
||||
[advent.screens.title :as title]
|
||||
[advent.screens.inventory :as inventory]
|
||||
[advent.screens.safe :as safe]
|
||||
[clojure.pprint]
|
||||
@@ -17,8 +18,8 @@
|
||||
(defgame advent
|
||||
:on-create
|
||||
(fn [this]
|
||||
(set-screen! this scene/scene dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen)))
|
||||
(set-screen! this title/title-screen)))
|
||||
|
||||
|
||||
(defn reload []
|
||||
(on-gl (set-screen! advent scene/scene dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen)))
|
||||
(on-gl (set-screen! advent title/title-screen)))
|
||||
|
||||
@@ -321,11 +321,6 @@
|
||||
(merge entity (animation->texture (update-in screen [:total-time] #(- % (:anim-start entity)))
|
||||
(:anim entity))))
|
||||
|
||||
(defn play-sound [snd]
|
||||
(music! snd :play))
|
||||
|
||||
(defn stop-sound [snd]
|
||||
(music! snd :stop))
|
||||
|
||||
(defn get-layers [entities]
|
||||
(let [layers (get-in entities [:room :layers])]
|
||||
@@ -333,9 +328,6 @@
|
||||
((get-in entities [:state :time]) layers)
|
||||
layers)))
|
||||
|
||||
(defn make-music [r]
|
||||
(doto (music r) (music! :set-looping true)))
|
||||
|
||||
(defn get-state []
|
||||
(if (.exists (io/file "save.edn"))
|
||||
(utils/load)
|
||||
@@ -375,13 +367,13 @@
|
||||
:outside-castle (rooms.outside-castle/make screen)}
|
||||
entities {:rooms rooms
|
||||
:musics {:object nil
|
||||
:inside-antique (make-music "inside-antique.ogg")
|
||||
:town-1 (make-music "town-music-1.ogg")
|
||||
:town-2 (make-music "town-music-2.ogg")
|
||||
:inside-fangald (make-music "inside-fangald.ogg")
|
||||
:fight (make-music "megaboss.mp3")
|
||||
:pull-sword (make-music "pull-sword.ogg")
|
||||
:night (make-music "night.ogg")}
|
||||
:inside-antique (utils/make-music "inside-antique.ogg")
|
||||
:town-1 (utils/make-music "town-music-1.ogg")
|
||||
:town-2 (utils/make-music "town-music-2.ogg")
|
||||
:inside-fangald (utils/make-music "inside-fangald.ogg")
|
||||
:fight (utils/make-music "megaboss.mp3")
|
||||
:pull-sword (utils/make-music "pull-sword.ogg")
|
||||
:night (utils/make-music "night.ogg")}
|
||||
:state (get-state)
|
||||
:actions {:object nil
|
||||
:channel (chan)
|
||||
@@ -400,7 +392,7 @@
|
||||
:mouse-in? (zone/box 278 0 320 42))
|
||||
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}]
|
||||
|
||||
(play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
||||
(utils/play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
||||
|
||||
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
|
||||
(add-timer! screen k start time))
|
||||
@@ -451,7 +443,7 @@
|
||||
(doseq [snd (->> (get-in entities [:musics])
|
||||
vals
|
||||
(filter identity))]
|
||||
(stop-sound snd)))
|
||||
(utils/stop-sound snd)))
|
||||
|
||||
:on-mouse-moved
|
||||
(fn [screen [entities]]
|
||||
|
||||
66
desktop/src-common/advent/screens/title.clj
Normal file
66
desktop/src-common/advent/screens/title.clj
Normal file
@@ -0,0 +1,66 @@
|
||||
(ns advent.screens.title
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[advent.utils :as utils]
|
||||
[advent.screens.scene :as scene]
|
||||
[advent.screens.dialogue :as dialogue]
|
||||
[advent.screens.title :as title]
|
||||
[advent.screens.inventory :as inventory]
|
||||
[advent.screens.safe :as safe]
|
||||
)
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.scenes.scene2d.utils Align]
|
||||
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
||||
InputMultiplexer InputProcessor Net Preferences Screen]))
|
||||
|
||||
(defn update-fade [entities current-time]
|
||||
(if (:fade entities)
|
||||
(let [time-shown (- current-time (:start-time entities))
|
||||
entities (assoc-in entities [:fade :opacity] (max (- 1.0 time-shown) 0.0))]
|
||||
(if (= 0.0 (get-in entities [:fade :opacity]))
|
||||
(do (utils/play-sound (:music entities))
|
||||
(dissoc entities :fade))
|
||||
entities))
|
||||
entities))
|
||||
|
||||
(defscreen title-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
(update! screen :renderer (stage) :camera (orthographic))
|
||||
(let [start-playing (assoc (label "Start Game" (style :label (utils/get-font "ego/font.fnt") (color :red))) :x 0 :y 850 :width 1280)
|
||||
music (utils/make-music "intro.ogg")]
|
||||
(label! start-playing :set-alignment Align/center)
|
||||
|
||||
{:overlay (assoc (texture "title-overlay.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
||||
:fade (assoc (texture "black.png")
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
:opacity 1.0)
|
||||
:music music
|
||||
:start-showing? false
|
||||
:start-playing start-playing}))
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
(let [entities (-> entities
|
||||
(update-in [:start-time] #(or % (:total-time screen)))
|
||||
(update-fade (:total-time screen)))]
|
||||
(render! screen [ (:overlay entities) (:start-playing entities) (:fade entities)])
|
||||
entities))
|
||||
|
||||
:show-screen (fn [entities]
|
||||
entities)
|
||||
|
||||
:on-mouse-moved (fn [screen [entities]]
|
||||
nil)
|
||||
|
||||
:on-touch-up (fn [screen [entities]]
|
||||
(utils/stop-sound (:music entities))
|
||||
(set-screen! @(resolve 'advent.core/advent) scene/scene dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen)
|
||||
nil)
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(size! screen 1280 960)))
|
||||
@@ -116,4 +116,12 @@
|
||||
(update-in entities [:room :interactions] (fn [i] (remove #(= id (:id %)) i))))
|
||||
|
||||
|
||||
(defn play-sound [snd]
|
||||
(music! snd :play))
|
||||
|
||||
(defn stop-sound [snd]
|
||||
(music! snd :stop))
|
||||
|
||||
(defn make-music [r]
|
||||
(doto (music r) (music! :set-looping true)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user