Hard to believe, but I think fullscreen truly works, even through sleep.

This commit is contained in:
Bryce Covert
2015-09-03 19:26:38 -07:00
parent 3dfbd9b408
commit a63a5352c1
12 changed files with 53 additions and 157 deletions

View File

@@ -24,7 +24,6 @@
(defgame advent
:on-create
(fn [this]
(Thread/sleep 1000)
(on-gl (set-screen! this title/title-screen))))

View File

@@ -11,6 +11,7 @@
(: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.utils.viewport FitViewport]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
InputMultiplexer InputProcessor Net Preferences Screen]))
@@ -32,7 +33,8 @@
)
:on-render
(fn [screen [entities]]
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
(render! screen [(:the-end entities) (:fade entities)])

View File

@@ -11,6 +11,7 @@
#_[advent.screens.scene :as scene])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx.math Vector3 Vector2 Matrix4]
[com.badlogic.gdx Screen]))
@@ -40,7 +41,8 @@
(utils/setup-viewport screen 1280 960)
{})
:on-render
(fn [{:keys [camera] :as screen} [entities]]
(fn [{:keys [camera ^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(render! screen (vals entities))
entities)
@@ -124,7 +126,8 @@
:x 5 :y 5 :width 1270)}}))
:on-render
(fn [screen [entities]]
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(when (seq (get-in entities [:state :choices]))
(render! screen [(get-in entities [:state :np])])
(render! screen (vals entities)))

View File

@@ -10,6 +10,7 @@
[advent.utils :as utils])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
InputMultiplexer InputProcessor Net Preferences Screen]))
@@ -45,7 +46,8 @@
:highlighted-text highlighted-text}))
:on-render
(fn [screen [entities]]
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(let [
entities (utils/apply-tweens screen entities (:tweens entities))
opacity (get-in entities [:opacity])

View File

@@ -1 +0,0 @@
brycecovert@brometheus.local.2657

View File

@@ -195,7 +195,7 @@
(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))))
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 7.0 :ease tween/ease-in-out-quintic))))
(continue [this screen entities]
entities)
@@ -245,8 +245,8 @@
(skip-type [this screen entities]
:none))
(Thread/sleep 2000)
(actions/transition-background entities :ending [165 49] :time 4.0)
(actions/do-stop entities :ego :face :left)
(actions/transition-background entities :ending [165 49] :time 4.0)
(actions/do-dialogue entities
:duke "Ladies and gentlemen."
:duke "As the Duke of Remington, I'm pleased to inform you..."
@@ -282,10 +282,6 @@
(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!")
@@ -314,6 +310,7 @@
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :reset)
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :start)
(disappear entities)
(Thread/sleep 2000)
(fade-out entities)
(on-gl (set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.credits/credits)))
))

View File

@@ -16,43 +16,6 @@
[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)
@@ -76,6 +39,8 @@
: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)]
:apply-state (fn [screen e]
(update-in e [:room :entities :ego] dissoc :talk-override ))
:entities {:peddler (assoc (animation->texture screen peddler-stand)
:x 245 :y 46 :baseline 200
:anim peddler-stand
@@ -104,78 +69,7 @@
: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)))))
:knight duke-knight)
:magic-frog-particle (doto (assoc (particle-effect "inside-house/magic-frog") :x 140 :y 49
:baseline 241)
(particle-effect! :set-position 150 49))

View File

@@ -8,6 +8,7 @@
[advent.zone :as zone]
[advent.utils :as utils])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
@@ -58,7 +59,8 @@
:on-render
(fn [screen [entities]]
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(when (:shown? entities)
(render! screen [(:fade entities) (:safe entities)])
(render! screen (take (count (:button-choices entities)) (:entered-keys entities))))

View File

@@ -955,7 +955,8 @@ void main()
(add-timer! screen k start time)))
:on-render
(fn [{:keys [camera] :as screen} [entities]]
(fn [{:keys [camera ^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(if (get-in entities [:closing? :value])
(let [entities (utils/apply-tweens screen entities (:tweens entities))
@@ -1136,7 +1137,8 @@ void main()
{:label (assoc (label "Demo version - DO NOT COPY" (color :white) ) :y 460 :x 5 :baseline 0 :opacity 0.5)}))
:on-render
(fn [screen [entities]]
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(render! screen [(:label entities)])
entities)
@@ -1162,7 +1164,8 @@ void main()
:fps (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)}))
:on-render
(fn [screen [entities]]
(fn [{:keys [viewport] :as screen} [entities]]
(.apply viewport)
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
#_(label! (:fps entities) :set-text (str (game :fps)))
(render! screen [ (:inventory entities) (:close entities)])

View File

@@ -83,7 +83,7 @@
start-playing (center start-playing)
copyright (assoc (label "DEMO - Copyright Bryce Covert - Not for distribution" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y 0 :height 32 :origin-x 0 :origin-y 0)
copyright (center copyright)
fullscreen (assoc (label "Windowed" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y (- 280 (* 32 5)) :height 32 :origin-x 0 :origin-y 0)
fullscreen (assoc (label "Fullscreen" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y (- 280 (* 32 5)) :height 32 :origin-x 0 :origin-y 0)
fullscreen (center fullscreen)
quit (assoc (label "End quest" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y (- 280 (* 32 6)) :height 32 :origin-x 0 :origin-y 0)
quit (center quit)
@@ -157,24 +157,16 @@
:ease tween/ease-in-quadratic)}}))
:on-render
(fn [screen [entities]]
#_(try
(when (not @do-once)
(Thread/sleep 1000)
(println "test")
(utils/setup-viewport screen 1280 960)
(reset! do-once true))
(catch Exception e
(println e)))
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
(.apply viewport)
(clear!)
(let [entities (utils/apply-tweens screen entities (:tweens entities))
entities (fly-ego screen entities)]
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
(render! screen [(:background entities) (:particle-clouds entities) (:cloud-background entities) (:ego-jet entities) (:flying-ego entities) (:logo entities) (:toolbox entities) (:start-playing entities) (:quit entities) (:fullscreen entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:copyright entities) (:fade entities) ])
entities))
(when-not (:paused? entities)
(let [entities (utils/apply-tweens screen entities (:tweens entities))
entities (fly-ego screen entities)]
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
(render! screen [(:background entities) (:particle-clouds entities) (:cloud-background entities) (:ego-jet entities) (:flying-ego entities) (:logo entities) (:toolbox entities) (:start-playing entities) (:quit entities) (:fullscreen entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:copyright entities) (:fade entities) ])
entities)))
:show-screen (fn [entities]
entities)
@@ -229,8 +221,8 @@
(on-gl (.setDisplayMode Gdx/graphics 1280 960 false)
(label! (:fullscreen entities) set-text "Windowed"))
(on-gl (.setDisplayMode Gdx/graphics
(.width (.getDesktopDisplayMode Gdx/graphics))
(.height (.getDesktopDisplayMode Gdx/graphics))
(doto (.width (.getDesktopDisplayMode Gdx/graphics)) println)
(doto (.height (.getDesktopDisplayMode Gdx/graphics)) println)
true)
(set! (.foregroundFPS (-> (class Gdx/graphics)
(.getDeclaredField (name "config"))
@@ -241,13 +233,15 @@
nil))))
:on-resize (fn [screen [entities]]
:on-resize (fn [{:keys [viewport width height]} [entities]]
(.update viewport width height false)
nil)
:on-pause (fn [{:keys [viewport] :as screen} [entities]]
(assoc entities :paused? true))
:on-resume (fn [{:keys [viewport] :as screen} [entities]]
(utils/setup-viewport screen 1280 960)
#_(on-gl
(gl! :gl-viewport 0 0 1440 900)
(println "HERE")
(.update viewport width height true))
nil))
(assoc entities :paused? false))
)

View File

@@ -212,7 +212,7 @@
(defn setup-viewport [screen width height]
(let [cam (orthographic)
(let [cam (or (:cam screen) (orthographic))
viewport (FitViewport. width height cam)
stage (Stage. viewport)]
(update! screen :renderer stage :viewport viewport :camera cam)

View File

@@ -23,19 +23,20 @@
(when port (start-nrepl-expr (Integer/parseInt port)))
(catch Exception e))
(let [cfg (LwjglApplicationConfiguration.)]
(if false
(if true
(do
(set! (.width cfg) (doto (.width (LwjglApplicationConfiguration/getDesktopDisplayMode)) println))
(set! (.height cfg) (doto (.height (LwjglApplicationConfiguration/getDesktopDisplayMode)) println))
#_(set! (.resizable cfg) false)
(set! (.useHDPI cfg) true)
(set! (.resizable cfg) true)
(set! (.useHDPI cfg) false)
(set! (.fullscreen cfg) true))
(do
(set! (.width cfg) 1280)
(set! (.height cfg) 960)))
(set! (.foregroundFPS cfg) 60)
(set! (.backgroundFPS cfg) 60)
(System/setProperty "org.lwjgl.opengl.Display.enableHighDPI" "true")
(System/setProperty "org.lwjgl.opengl.Display.enableHighDPI" "false")
(System/setProperty "org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI" "true")
#_(System/setProperty "org.lwjgl.opengl.Window.undecorated", "true")
(LwjglApplication. advent cfg))