trimmed mobile.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
|
||||
[clojure.string :as s]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.set :as set]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
[advent.screens.safe :as safe]
|
||||
[advent.screens.fade :as fade]
|
||||
[advent.steam :as steam]
|
||||
[clojure.pprint]
|
||||
|
||||
[advent.pathfind])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
@@ -22,19 +22,26 @@
|
||||
[java.io FileOutputStream File PrintStream])
|
||||
)
|
||||
|
||||
(defn g []
|
||||
(log/info "ABC"))
|
||||
|
||||
(defn a []
|
||||
(g))
|
||||
|
||||
(defonce am (asset-manager))
|
||||
|
||||
(set-asset-manager! am)
|
||||
(defn create-game [advent]
|
||||
(log/log-capture! *ns* :warn :error)
|
||||
(log/info "Starting game on version v" (advent.version/version))
|
||||
(utils/listen-for-screenshots)
|
||||
|
||||
(set-screen! advent splash/splash-screen))
|
||||
|
||||
(defgame advent
|
||||
:on-create
|
||||
(fn [this]
|
||||
(log/log-capture! *ns* :warn :error)
|
||||
(log/info "Starting game on version v" (advent.version/version))
|
||||
(utils/listen-for-screenshots)
|
||||
(steam/init)
|
||||
|
||||
(set-screen! @(resolve 'advent.core/advent) splash/splash-screen)))
|
||||
(create-game advent)))
|
||||
|
||||
(defn reload []
|
||||
(on-gl (set-screen! advent title/title-screen)))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
(ns advent.pathfind
|
||||
(:require [play-clj.core :refer :all])
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[clojure.tools.logging :as log])
|
||||
(:import (java.lang Math)))
|
||||
|
||||
(def scale 2)
|
||||
@@ -120,18 +122,21 @@
|
||||
(println path)))
|
||||
|
||||
(defn map-from-resource [filename]
|
||||
(log/info "Loading collision from" filename)
|
||||
(let [pm (pixmap filename)
|
||||
black (color 0 0 0 255)
|
||||
painful (color 255 0 0 255)
|
||||
result (transient [])
|
||||
scale (long scale)
|
||||
height (long (pixmap! pm :get-height))]
|
||||
(doseq [^long x (range (/ (pixmap! pm :get-width) scale))
|
||||
^long y (range (/ height scale))
|
||||
:let [
|
||||
current-color (color (pixmap! pm :get-pixel (unchecked-multiply scale x) (unchecked-subtract height (unchecked-multiply scale y))))]]
|
||||
(conj! result (cond
|
||||
(color! current-color :equals black) 0
|
||||
(color! current-color :equals painful) 2
|
||||
:else 1)))
|
||||
(partition (/ (pixmap! pm :get-height) scale) (persistent! result) )))
|
||||
height (long (pixmap! pm :get-height))
|
||||
_ (doseq [^long x (range (/ (pixmap! pm :get-width) scale))
|
||||
^long y (range (/ height scale))
|
||||
:let [current-color (color (pixmap! pm :get-pixel (unchecked-multiply scale x) (unchecked-subtract height (unchecked-multiply scale y))))]]
|
||||
(conj! result (cond
|
||||
(color! current-color :equals black) 0
|
||||
(color! current-color :equals painful) 2
|
||||
:else 1)))
|
||||
result (partition (/ (pixmap! pm :get-height) scale) (persistent! result) )]
|
||||
(.unload *asset-manager* filename)
|
||||
(log/info "Finished loading collision from" filename)
|
||||
result))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
|
||||
[advent.pathfind]
|
||||
[advent.tween :as tween]
|
||||
[advent.zone :as zone]
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
[clojure.set :as set]
|
||||
[advent.pathfind]
|
||||
[advent.tween :as tween]
|
||||
[advent.utils :as utils]
|
||||
[clojure.core.async :refer [put! <! <!! >! >!! chan go thread take! alts!!]]
|
||||
#_[advent.screens.scene :as scene])
|
||||
[clojure.core.async :refer [put! <! <!! >! >!! chan go thread take! alts!!]])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.utils.viewport FitViewport]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
|
||||
[advent.pathfind]
|
||||
[advent.zone :as zone]
|
||||
[advent.utils :as utils])
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.pprint]
|
||||
|
||||
[advent.pathfind]
|
||||
[advent.actions :as actions]
|
||||
[advent.zone :as zone]
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
{:id id}))
|
||||
entities (into {} (for [[id entity] entities]
|
||||
[id (make-entity id entity)]))]
|
||||
(println "MAKING")
|
||||
(merge params {:collision (advent.pathfind/map-from-resource collision)
|
||||
:interactions interactions-as-list
|
||||
:entities entities})))
|
||||
|
||||
@@ -266,8 +266,8 @@
|
||||
puke (particle-effect "particles/puke")]
|
||||
(rooms/make :music {:day :town-2 :night :night}
|
||||
:name "Tree"
|
||||
:sounds {:cat (utils/load-sound "cat-tree/cat.ogg")
|
||||
:kiss (utils/load-sound "cat-tree/kiss.ogg")}
|
||||
:sounds {#_#_:cat (utils/load-sound "cat-tree/cat.ogg")
|
||||
#_#_:kiss (utils/load-sound "cat-tree/kiss.ogg")}
|
||||
:ladder ladder-entity
|
||||
:blank (rooms/make-entity :blank
|
||||
{:object nil :x 0 :y 0 :width 320 :height 240 :baseline 240
|
||||
|
||||
@@ -225,9 +225,9 @@
|
||||
:shopkeep "My son would be stricken with grief to find it missing."))))]
|
||||
(rooms/make :music :inside-antique
|
||||
:name "Antique shop"
|
||||
:sounds {:fire-1 (utils/load-sound "inside-antique/fire-1.ogg")
|
||||
:fire-2 (utils/load-sound "inside-antique/fire-2.ogg")
|
||||
:fire-3 (utils/load-sound "inside-antique/fire-3.ogg")
|
||||
:sounds {#_#_:fire-1 (utils/load-sound "inside-antique/fire-1.ogg")
|
||||
#_#_:fire-2 (utils/load-sound "inside-antique/fire-2.ogg")
|
||||
#_#_:fire-3 (utils/load-sound "inside-antique/fire-3.ogg")
|
||||
}
|
||||
:return-portrait (rooms/make-entity :return-portrait {:box [103 70 206 116]
|
||||
:label "Desk"
|
||||
|
||||
@@ -659,7 +659,7 @@
|
||||
:talk game-player-talk-up}
|
||||
:get-to-work game-player-get-to-work
|
||||
:pause-from-work game-player-pause-from-work
|
||||
:flex-sound (utils/load-sound "inside-castle/flex.ogg")
|
||||
#_#_:flex-sound (utils/load-sound "inside-castle/flex.ogg")
|
||||
:anim-sound-frames {game-player-stand-up {11 [:blink 0.3 1.1] }
|
||||
game-player-talk-up {11 [:blink 0.3 1.1]
|
||||
22 [:blink 0.3 1.1]
|
||||
|
||||
@@ -232,8 +232,8 @@
|
||||
(rooms/make :music :inside-antique
|
||||
:name "In jail"
|
||||
:sounds {
|
||||
:squeek (utils/load-sound "inside-jail/squeak.ogg")
|
||||
:crowbar-sound (utils/load-sound "ego/crowbar.ogg")
|
||||
#_#_:squeek (utils/load-sound "inside-jail/squeak.ogg")
|
||||
#_#_:crowbar-sound (utils/load-sound "ego/crowbar.ogg")
|
||||
}
|
||||
:interactions {
|
||||
:lock {:box [172 102 190 124]
|
||||
|
||||
@@ -626,7 +626,7 @@
|
||||
(rooms/make :music {:day :town-2 :night :night}
|
||||
:name "Outside house"
|
||||
:update-fn jump-around
|
||||
:cauldron-sound {:object nil :sound (utils/load-sound "outsidehouse/cauldron.ogg")}
|
||||
#_#_:cauldron-sound {:object nil :sound (utils/load-sound "outsidehouse/cauldron.ogg")}
|
||||
:interactions
|
||||
{:door {:box [250 100 281 160]
|
||||
:only-script
|
||||
@@ -774,8 +774,8 @@
|
||||
(actions/talk entities :ego "That's just cruel."))
|
||||
nil)
|
||||
|
||||
:eat-sound (utils/load-sound "outsidehouse/sheep-eat.ogg")
|
||||
:bleet-sound (utils/load-sound "outsidehouse/sheep-bleet.ogg")
|
||||
#_#_:eat-sound (utils/load-sound "outsidehouse/sheep-eat.ogg")
|
||||
#_#_:bleet-sound (utils/load-sound "outsidehouse/sheep-bleet.ogg")
|
||||
:anim-sound-frames {sheep-stand {11 [:eat-sound 0.3]
|
||||
35 [:bleet-sound 0.5]}}
|
||||
:left {:walk (utils/flip sheep-walk)
|
||||
@@ -794,7 +794,7 @@
|
||||
:door (assoc (animation->texture screen door)
|
||||
:x 252 :y 88 :baseline 122
|
||||
:open door
|
||||
:door-sound (utils/load-sound "door.ogg")
|
||||
#_#_:door-sound (utils/load-sound "door.ogg")
|
||||
:anim-sound-frames {door {1 [:door-sound 0.1]}}
|
||||
)
|
||||
:lamb (assoc (utils/get-texture "outsidehouse/lamb.png")
|
||||
|
||||
@@ -196,10 +196,10 @@
|
||||
grow-explode (particle-effect "particles/grow-explode")]
|
||||
(rooms/make :music :fight
|
||||
:name "Duel"
|
||||
:sounds {:shock (utils/load-sound "space/shock.ogg")
|
||||
:shock-short (utils/load-sound "space/shock-short.ogg")
|
||||
:jump (utils/load-sound "space/jump.ogg")
|
||||
:swing-sword (utils/load-sound "space/swingsword.ogg")}
|
||||
:sounds {#_#_:shock (utils/load-sound "space/shock.ogg")
|
||||
#_#_:shock-short (utilw/load-sound "space/shock-short.ogg")
|
||||
#_#_:jump (utils/load-sound "space/jump.ogg")
|
||||
#_#_:swing-sword (utils/load-sound "space/swingsword.ogg")}
|
||||
:interactions
|
||||
{}
|
||||
:layers [(assoc (utils/get-texture "space/background.png") :x 0 :y 0 :baseline 0)]
|
||||
@@ -235,9 +235,9 @@
|
||||
:bloodclot (assoc (animation->texture screen blergh-stand-anim)
|
||||
:x 180 :y 50 :baseline 190
|
||||
:stand blergh-stand-anim
|
||||
:inhale-sound (utils/load-sound "space/bloodclot-inhale.ogg")
|
||||
:exhale-sound (utils/load-sound "space/bloodclot-exhale.ogg")
|
||||
:explode-sound (utils/load-sound "space/bloodclot-explode.ogg")
|
||||
#_#_:inhale-sound (utils/load-sound "space/bloodclot-inhale.ogg")
|
||||
#_#_ :exhale-sound (utils/load-sound "space/bloodclot-exhale.ogg")
|
||||
#_#_ :explode-sound (utils/load-sound "space/bloodclot-explode.ogg")
|
||||
:anim-sound-frames {blergh-stand-anim {0 [:inhale-sound grunt-vol]
|
||||
1 [:exhale-sound grunt-vol]}
|
||||
bloodclot-explode {35 [:grow-sound (constantly 0.5)]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
|
||||
[advent.pathfind]
|
||||
[advent.zone :as zone]
|
||||
[advent.utils :as utils])
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[play-clj.entities :as entities]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.pprint]
|
||||
|
||||
[clojure.java.io :as io]
|
||||
[clojure.tools.logging :as log]
|
||||
[advent.pathfind]
|
||||
@@ -41,7 +41,7 @@
|
||||
[advent.screens.dialogue :refer [talking-screen toast-screen tooltip-screen]]
|
||||
[advent.screens.inventory :refer [inventory-screen]]
|
||||
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!! poll! dropping-buffer]])
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!! dropping-buffer]])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap$Format Pixmap Pixmap$Filter Texture Texture$TextureFilter GL20 GL30]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion Animation Batch]
|
||||
[com.badlogic.gdx.math Vector3 Matrix4]
|
||||
@@ -53,8 +53,7 @@
|
||||
[java.lang Object]
|
||||
[com.badlogic.gdx Gdx]
|
||||
[com.badlogic.gdx.graphics Camera Color GL20 OrthographicCamera
|
||||
PerspectiveCamera Pixmap Pixmap$Format PixmapIO Texture
|
||||
VertexAttributes$Usage]
|
||||
PerspectiveCamera Pixmap Pixmap$Format PixmapIO Texture ]
|
||||
[com.badlogic.gdx.scenes.scene2d Actor Stage]))
|
||||
|
||||
#_(set! *unchecked-math* :warn-on-boxed)
|
||||
@@ -655,28 +654,28 @@
|
||||
:origin-x 9
|
||||
:origin-y 0
|
||||
:scaled true
|
||||
:drop-sound (utils/load-sound "ego/drop.ogg")
|
||||
:milk-sound (utils/load-sound "outsidehouse/milk.ogg")
|
||||
:step-sound-1 (utils/load-sound "ego/step-1.ogg")
|
||||
:step-sound-2 (utils/load-sound "ego/step-2.ogg")
|
||||
:step-sound-3 (utils/load-sound "ego/step-3.ogg")
|
||||
:step-sound-4 (utils/load-sound "ego/step-4.ogg")
|
||||
:shoot-sound (utils/load-sound "ego/slingshot.ogg")
|
||||
:glad-sound (utils/load-sound "ego/glad.ogg")
|
||||
#_#_:drop-sound (utils/load-sound "ego/drop.ogg")
|
||||
#_#_:milk-sound (utils/load-sound "outsidehouse/milk.ogg")
|
||||
#_#_:step-sound-1 (utils/load-sound "ego/step-1.ogg")
|
||||
#_#_:step-sound-2 (utils/load-sound "ego/step-2.ogg")
|
||||
#_#_:step-sound-3 (utils/load-sound "ego/step-3.ogg")
|
||||
#_#_:step-sound-4 (utils/load-sound "ego/step-4.ogg")
|
||||
#_#_:shoot-sound (utils/load-sound "ego/slingshot.ogg")
|
||||
#_#_:glad-sound (utils/load-sound "ego/glad.ogg")
|
||||
|
||||
:get-sick-sound (utils/load-sound "ego/get-sick.ogg")
|
||||
:scratch-sound (utils/load-sound "ego/scratch.ogg")
|
||||
:scared-step-sound (utils/load-sound "ego/scared-step.ogg")
|
||||
#_#_:get-sick-sound (utils/load-sound "ego/get-sick.ogg")
|
||||
#_#_:scratch-sound (utils/load-sound "ego/scratch.ogg")
|
||||
#_#_:scared-step-sound (utils/load-sound "ego/scared-step.ogg")
|
||||
|
||||
:inside-step-sound-1 (utils/load-sound "ego/inside-step-1.ogg")
|
||||
:inside-step-sound-2 (utils/load-sound "ego/inside-step-2.ogg")
|
||||
:inside-step-sound-3 (utils/load-sound "ego/inside-step-3.ogg")
|
||||
:inside-step-sound-4 (utils/load-sound "ego/inside-step-4.ogg")
|
||||
:crowbar-sound (utils/load-sound "ego/crowbar.ogg")
|
||||
:sigh-sound (utils/load-sound "ego/sigh.ogg")
|
||||
:axe-sound (utils/load-sound "ego/axe.ogg")
|
||||
:breakglass-sound (utils/load-sound "ego/breakglass.ogg")
|
||||
:idea-sound (utils/load-sound "ego/idea.ogg")
|
||||
#_#_:inside-step-sound-1 (utils/load-sound "ego/inside-step-1.ogg")
|
||||
#_#_:inside-step-sound-2 (utils/load-sound "ego/inside-step-2.ogg")
|
||||
#_#_:inside-step-sound-3 (utils/load-sound "ego/inside-step-3.ogg")
|
||||
#_#_:inside-step-sound-4 (utils/load-sound "ego/inside-step-4.ogg")
|
||||
#_#_:crowbar-sound (utils/load-sound "ego/crowbar.ogg")
|
||||
#_#_:sigh-sound (utils/load-sound "ego/sigh.ogg")
|
||||
#_#_:axe-sound (utils/load-sound "ego/axe.ogg")
|
||||
#_#_:breakglass-sound (utils/load-sound "ego/breakglass.ogg")
|
||||
#_#_:idea-sound (utils/load-sound "ego/idea.ogg")
|
||||
:scale-x start-scale
|
||||
:scale-y start-scale
|
||||
:talk-color (color 0.6 1.0 1.0 1.0)
|
||||
@@ -774,7 +773,7 @@
|
||||
(let [{{:keys [script-running? script-chan]} key} entities]
|
||||
(if script-running?
|
||||
entities
|
||||
(let [next-script (poll! script-chan)]
|
||||
(let [next-script (<! script-chan)]
|
||||
(if next-script
|
||||
(do
|
||||
(next-script entities)
|
||||
@@ -796,7 +795,7 @@
|
||||
(update-in terminated [key] assoc :current nil :started? false)
|
||||
key))
|
||||
(assoc-in entities [key :started?] true)))
|
||||
(let [current (poll! channel)]
|
||||
(let [current (<! channel)]
|
||||
|
||||
(-> entities
|
||||
(assoc-in [key :started?] false)
|
||||
@@ -1089,6 +1088,7 @@
|
||||
has-start-pos? (:x state)
|
||||
|
||||
_ (update! screen :shader shader)
|
||||
log-assets (fn [r] r)
|
||||
rooms {:inside-house (rooms.inside-house/make screen)
|
||||
:inside-stash (rooms.inside-stash/make screen)
|
||||
:outside-house (rooms.outside-house/make screen)
|
||||
@@ -1123,14 +1123,14 @@
|
||||
:inside-antique (utils/make-music "music/inside-antique.ogg")
|
||||
:town-1 (utils/make-music "music/town-music-1.ogg")
|
||||
:town-2 (utils/make-music "music/town-music-2.ogg")
|
||||
:love (utils/make-music "music/love.ogg")
|
||||
:inside-fangald (utils/make-music "music/inside-fangald.ogg")
|
||||
:fight (utils/make-music "music/megaboss.mp3")
|
||||
:pull-sword (utils/make-music "music/pull-sword.ogg")
|
||||
:night (utils/make-music "music/night.ogg")
|
||||
:dream (utils/make-music "dream/music.ogg")
|
||||
:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
||||
:wind (utils/make-music "music/wind.ogg")}
|
||||
#_#_:love (utils/make-music "music/love.ogg")
|
||||
#_#_:inside-fangald (utils/make-music "music/inside-fangald.ogg")
|
||||
#_#_:fight (utils/make-music "music/megaboss.mp3")
|
||||
#_#_:pull-sword (utils/make-music "music/pull-sword.ogg")
|
||||
#_#_:night (utils/make-music "music/night.ogg")
|
||||
#_#_:dream (utils/make-music "dream/music.ogg")
|
||||
#_#_:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
||||
#_#_:wind (utils/make-music "music/wind.ogg")}
|
||||
:state state
|
||||
:time-profiles {:object nil
|
||||
:default utils/default-night-merge
|
||||
@@ -1139,10 +1139,10 @@
|
||||
|
||||
:closing? {:object nil
|
||||
:value false}
|
||||
:sounds {:blink (utils/load-sound "ego/blink2.ogg")
|
||||
:pickup (utils/load-sound "pickup.ogg")
|
||||
:disappear (utils/load-sound "inside-house/disappear.ogg")
|
||||
:grow-sound (utils/load-sound "ego/potion.ogg")
|
||||
:sounds {#_#_:blink (utils/load-sound "ego/blink2.ogg")
|
||||
#_#_:pickup (utils/load-sound "pickup.ogg")
|
||||
#_#_:disappear (utils/load-sound "inside-house/disappear.ogg")
|
||||
#_#_:grow-sound (utils/load-sound "ego/potion.ogg")
|
||||
:object nil}
|
||||
:fade {:object nil
|
||||
:opacity 0.0}
|
||||
@@ -1189,6 +1189,8 @@
|
||||
(if has-start-pos?
|
||||
start-pos
|
||||
(:start-pos room))))))}]
|
||||
(log/info "assets so far", (.getDiagnostics *asset-manager*) )
|
||||
|
||||
|
||||
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
|
||||
(add-timer! screen k start time))
|
||||
@@ -1268,7 +1270,7 @@
|
||||
|
||||
:on-render
|
||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} {{:keys [last-pos ] [cursor-offset-x cursor-offset-y] :offset} :cursor :keys [tweens] :as entities} options]
|
||||
(steam/update)
|
||||
#_(steam/update)
|
||||
(.apply viewport)
|
||||
|
||||
(if (get-in entities [:closing? :value])
|
||||
|
||||
@@ -87,6 +87,10 @@
|
||||
{:can-skip false
|
||||
:do (fn [screen entities]
|
||||
(utils/stop-music (:pop-music entities))
|
||||
|
||||
(log/info "clearing assets" (into [] (.getAssetNames *asset-manager*)) (.getDiagnostics *asset-manager*))
|
||||
(.clear *asset-manager* )
|
||||
(log/info "cleared assets" (into [] (.getAssetNames *asset-manager*)) (.getDiagnostics *asset-manager*))
|
||||
(set-screen! @(resolve 'advent.core/advent) title/title-screen)
|
||||
entities)
|
||||
:duration 0.0}])
|
||||
@@ -102,7 +106,7 @@
|
||||
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
|
||||
|
||||
(let [screen (assoc screen :total-time 0)
|
||||
pop-anim (make-anim-seq "POPPixelLogo_02" [320 240] 0.05 (range 200))
|
||||
#_#_pop-anim (make-anim-seq "POPPixelLogo_02" [320 240] 0.05 (range 200))
|
||||
entities {:background (assoc (utils/get-texture "black.png")
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
@@ -110,8 +114,7 @@
|
||||
:origin-x 0
|
||||
:origin-y 0
|
||||
:z 0)
|
||||
:pop-logo (assoc (animation->texture screen pop-anim)
|
||||
:main-anim pop-anim
|
||||
:pop-logo (assoc (utils/get-texture "black.png")
|
||||
:x 0 :y 0
|
||||
:origin-x 0 :origin-y 0
|
||||
:scale-x 4 :scale-y 4
|
||||
@@ -126,11 +129,11 @@
|
||||
|
||||
:on-render
|
||||
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
||||
(steam/update)
|
||||
#_(steam/update)
|
||||
(.apply viewport)
|
||||
(clear!)
|
||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))
|
||||
entities (update-in entities [:pop-logo] animate screen)
|
||||
#_#_entities (update-in entities [:pop-logo] animate screen)
|
||||
entities (if (and (:queued-skip? entities) (get-in entities [:current-step :can-skip]))
|
||||
(assoc entities :queued-skip? false :current-step nil)
|
||||
entities)
|
||||
|
||||
@@ -445,7 +445,7 @@
|
||||
|
||||
:on-render
|
||||
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
||||
(steam/update)
|
||||
#_(steam/update)
|
||||
(.apply viewport)
|
||||
(clear!)
|
||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))
|
||||
|
||||
@@ -1,151 +1,56 @@
|
||||
(ns advent.steam
|
||||
(:require [play-clj.core :refer :all]
|
||||
[clojure.edn :as edn]
|
||||
[clojure.tools.logging :as log]
|
||||
)
|
||||
(:import [java.nio ByteBuffer CharBuffer]
|
||||
[java.io ByteArrayOutputStream]
|
||||
[com.badlogic.gdx.graphics Pixmap PixmapIO$PNG]
|
||||
[com.badlogic.gdx.files FileHandle]
|
||||
))
|
||||
(:require [play-clj.core :refer :all])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap PixmapIO$PNG]
|
||||
[com.badlogic.gdx.files FileHandle]))
|
||||
|
||||
(def has-steam?
|
||||
(try
|
||||
(import '[com.codedisaster.steamworks SteamUserStats SteamUserStatsCallback SteamAPI SteamRemoteStorage])
|
||||
true
|
||||
(catch Exception e
|
||||
false)))
|
||||
|
||||
(def is-app-store? (System/getProperty "app-store"))
|
||||
|
||||
(defmacro steamify [steam-version & [regular-version]]
|
||||
(if has-steam?
|
||||
`(if (and has-steam? (not (System/getProperty "no-steam")))
|
||||
~steam-version
|
||||
~regular-version)
|
||||
regular-version))
|
||||
|
||||
(defn init []
|
||||
(steamify
|
||||
(if (SteamAPI/init)
|
||||
(log/info "Steam initialized")
|
||||
(do
|
||||
(log/info "Steam not initialized")
|
||||
(def has-steam? false)))))
|
||||
|
||||
(defn update []
|
||||
(steamify
|
||||
(when (SteamAPI/isSteamRunning)
|
||||
(SteamAPI/runCallbacks))))
|
||||
|
||||
(if has-steam?
|
||||
(eval
|
||||
'(do
|
||||
(defn achievement-fn [f achievement]
|
||||
(steamify
|
||||
(let [stats (atom nil)]
|
||||
(log/info "Getting stats...")
|
||||
(reset! stats (SteamUserStats. (reify SteamUserStatsCallback
|
||||
(onUserStatsReceived [_ _ _ _]
|
||||
(f @stats achievement)
|
||||
)
|
||||
(onUserStatsStored [_ _ _])
|
||||
(onUserAchievementStored [_ _ _ _ _ _]))))
|
||||
(.requestCurrentStats @stats))))
|
||||
|
||||
(def set-achievement (partial achievement-fn
|
||||
(fn [^SteamUserStats stats ^String achievement]
|
||||
(log/info "Setting achievement" achievement)
|
||||
(.setAchievement stats achievement)
|
||||
(.storeStats stats)
|
||||
(log/info "Done setting achievement" achievement))))
|
||||
|
||||
(def clear-achievement (partial achievement-fn
|
||||
(fn [^SteamUserStats stats ^String achievement]
|
||||
(log/info "Clearing achievement" achievement)
|
||||
(.clearAchievement stats achievement)
|
||||
(.storeStats stats)
|
||||
(log/info "Done clearing achievement" achievement)))))
|
||||
|
||||
)
|
||||
(do
|
||||
(defn set-achievement [achievement])
|
||||
(defn clear-achievement [achievement])))
|
||||
false
|
||||
)
|
||||
|
||||
(def is-app-store? false)
|
||||
(def all-achievements ["PARDON" "EX_CON" "PRO_WRESTLER" "SHEEP_HORDER" "SAFE_AND_SOUND" "DESTINY" "WISE_UP" "BLOODCLOT" "KITTY_KISS"])
|
||||
|
||||
(defn clear-achievement [])
|
||||
|
||||
(defn set-achievement [x])
|
||||
|
||||
(defn clear-all-achievements []
|
||||
(doall (map clear-achievement all-achievements)))
|
||||
|
||||
(defn get-bytes [filename]
|
||||
(steamify
|
||||
(let [rs (SteamRemoteStorage. nil)
|
||||
len (.getFileSize rs filename)
|
||||
bb (ByteBuffer/allocateDirect len)
|
||||
bytes (make-array Byte/TYPE len)]
|
||||
(.fileRead rs filename bb len)
|
||||
(.get bb bytes)
|
||||
bytes)
|
||||
(.readBytes (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename)))))
|
||||
(.readBytes (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))))
|
||||
|
||||
(defn write-bytes [filename bytes]
|
||||
(steamify
|
||||
(let [rs (SteamRemoteStorage. nil)
|
||||
bb (ByteBuffer/allocateDirect (* 2 (count bytes)))]
|
||||
(-> bb (.put bytes) )
|
||||
(.fileWrite rs filename bb (* 2 (count bytes))))
|
||||
(let [f (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))]
|
||||
(.writeBytes f bytes false))))
|
||||
(let [f (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))]
|
||||
(.writeBytes f bytes false)))
|
||||
|
||||
(defn list-edn-files []
|
||||
(steamify
|
||||
(let [rs (SteamRemoteStorage. nil)]
|
||||
(for [i (range (.getFileCount rs))
|
||||
:let [n (.getFileNameAndSize rs i (make-array Integer/TYPE 1))]
|
||||
:when (.endsWith n ".edn")]
|
||||
n))
|
||||
(if is-app-store?
|
||||
(for [save-file (.list (files! :external "saves/") ".edn")]
|
||||
(str "saves/" (.name ^FileHandle save-file)))
|
||||
(for [save-file (.list (files! :local "saves/") ".edn")]
|
||||
(str "saves/" (.name ^FileHandle save-file))))))
|
||||
(if is-app-store?
|
||||
(for [save-file (.list (files! :external "saves/") ".edn")]
|
||||
(str "saves/" (.name ^FileHandle save-file)))
|
||||
(for [save-file (.list (files! :local "saves/") ".edn")]
|
||||
(str "saves/" (.name ^FileHandle save-file)))))
|
||||
|
||||
(defn save-screenshot [^Pixmap pm ^String filename]
|
||||
(steamify
|
||||
(let [rs (SteamRemoteStorage. nil)
|
||||
png (PixmapIO$PNG. (* (.getWidth pm) (.getHeight pm) 1.5))
|
||||
baos (ByteArrayOutputStream. (* (.getWidth pm) (.getHeight pm) 1.5))
|
||||
_ (.write png baos pm)
|
||||
bytes (.toByteArray baos)
|
||||
bb (ByteBuffer/allocateDirect (count bytes))]
|
||||
(.put bb bytes)
|
||||
(.fileWrite rs filename bb (count bytes)))
|
||||
(let [f (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))
|
||||
png (PixmapIO$PNG. (* (.getWidth pm) (.getHeight pm) 1.5))]
|
||||
|
||||
(let [f (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))
|
||||
png (PixmapIO$PNG. (* (.getWidth pm) (.getHeight pm) 1.5))]
|
||||
|
||||
(.write png f pm)
|
||||
(.dispose png))))
|
||||
(.write png f pm)
|
||||
(.dispose png)))
|
||||
|
||||
(defn delete-file [filename]
|
||||
(steamify
|
||||
(.fileDelete (SteamRemoteStorage. nil) filename)
|
||||
(.delete (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename)))))
|
||||
(.delete (if is-app-store?
|
||||
(files! :external filename)
|
||||
(files! :local filename))))
|
||||
|
||||
(defn save-screenshot-file-name [name]
|
||||
(steamify
|
||||
(str "screenshot-" (clojure.core/name name) ".png" )
|
||||
(str "saves/screenshot-" (clojure.core/name name) ".png" )))
|
||||
(str "saves/screenshot-" (clojure.core/name name) ".png" ))
|
||||
|
||||
(defn save-file-name [id]
|
||||
(steamify
|
||||
(str id ".edn")
|
||||
(str "saves/" id ".edn")))
|
||||
(str "saves/" id ".edn"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns advent.utils
|
||||
(:refer-clojure :exclude [load])
|
||||
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
@@ -12,7 +12,7 @@
|
||||
[clojure.string :as str]
|
||||
[advent.saves :as saves]
|
||||
[advent.steam :as steam]
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go go-loop thread take! alts!! poll! dropping-buffer]])
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go go-loop thread take! alts!! dropping-buffer]])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Format Pixmap$Blending Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion Animation]
|
||||
[com.badlogic.gdx.utils.viewport FitViewport]
|
||||
@@ -427,7 +427,8 @@
|
||||
(doto (music (str r ".mp3")) (music! :set-looping true)))))
|
||||
|
||||
(defn load-sound [f]
|
||||
(try
|
||||
nil
|
||||
#_(try
|
||||
(iosify
|
||||
(sound (str f ".mp3"))
|
||||
(sound f)
|
||||
@@ -674,23 +675,29 @@
|
||||
(play-sound! screen entities snd volume-fn pan type 1.0))
|
||||
|
||||
([screen entities snd volume-fn pan type pitch]
|
||||
(if (if (keyword? snd)
|
||||
(or (-> entities :room :sounds snd)
|
||||
(-> entities :sounds snd))
|
||||
snd)
|
||||
|
||||
(let [vol (volume-fn entities)
|
||||
snd (if (keyword? snd)
|
||||
(or (-> entities :room :sounds snd)
|
||||
(-> entities :sounds snd))
|
||||
snd)
|
||||
|
||||
sound-id (if (= :once type)
|
||||
(sound! snd :play (scale-vol-from-fade entities (current-sound-volume vol)) (or pitch 1.0) pan )
|
||||
(sound! snd :loop 0.0 (or pitch 1.0) pan )) ]
|
||||
(update-in entities [:current-sounds :value]
|
||||
conj {:id sound-id
|
||||
:sound snd
|
||||
:sound snd
|
||||
:volume-fn volume-fn
|
||||
:type type
|
||||
:ends-at (if (= type :once)
|
||||
(+ (:total-time screen) 1.0 #_(sound! snd :duration))
|
||||
nil)}))))
|
||||
nil)}))
|
||||
entities)))
|
||||
|
||||
(defn stop-all-sounds! [entities]
|
||||
(doseq [snd (get-in entities [:current-sounds :value])]
|
||||
|
||||
Reference in New Issue
Block a user