diff --git a/.bin/music/test-60bpm.sj b/.bin/music/test-60bpm.sj index 36db2c1..1b010c4 100644 --- a/.bin/music/test-60bpm.sj +++ b/.bin/music/test-60bpm.sj @@ -1,9 +1,9 @@ -actor [0..100] { +actor [0..1] { color_a := 1; clip_left := 0.1; } -background [0..100] { +background [0..1] { inner_r = 0.8; inner_g = 0.8; inner_b = 0.8; @@ -14,7 +14,7 @@ background [0..100] { outer_b = 0; outer_a = 1; } -posteffect [0..100] { +posteffect [0..1] { clip_left := 0.1; clip_right := 0.1; } diff --git a/src/sj/Game.d b/src/sj/Game.d index ddd96c4..457e1f4 100644 --- a/src/sj/Game.d +++ b/src/sj/Game.d @@ -14,6 +14,7 @@ import sj.AbstractGame, sj.Music, sj.PlayScene, sj.ProgramSet, + sj.ResultScene, sj.SelectScene, sj.TitleScene; @@ -38,12 +39,14 @@ class Game : AbstractGame { title_ = new TitleScene(lobby_, programs_); select_ = new SelectScene(lobby_, programs_, fonts_, music_list_); load_ = new LoadingScene(args, lobby_, programs_, fonts_); - play_ = new PlayScene(); + play_ = new PlayScene; + result_ = new ResultScene(lobby_, programs_, fonts_); title_ .SetupSceneDependency(select_); select_.SetupSceneDependency(title_, load_); load_ .SetupSceneDependency(play_); - play_ .SetupSceneDependency(); // TODO: pass result scene + play_ .SetupSceneDependency(result_); + result_.SetupSceneDependency(); title_.Initialize(); super(title_); @@ -54,6 +57,7 @@ class Game : AbstractGame { select_.destroy(); load_.destroy(); play_.destroy(); + result_.destroy(); lobby_.destroy(); @@ -75,4 +79,5 @@ class Game : AbstractGame { SelectScene select_; LoadingScene load_; PlayScene play_; + ResultScene result_; } diff --git a/src/sj/PlayScene.d b/src/sj/PlayScene.d index ae5239a..739e2e5 100644 --- a/src/sj/PlayScene.d +++ b/src/sj/PlayScene.d @@ -7,6 +7,7 @@ static import sjplayer; import sj.KeyInput, sj.Music, + sj.ResultScene, sj.SceneInterface; /// @@ -20,7 +21,8 @@ class PlayScene : SceneInterface { } /// - void SetupSceneDependency() { // TODO: add result scene + void SetupSceneDependency(ResultScene result) { + result_scene_ = result; } /// @@ -31,7 +33,15 @@ class PlayScene : SceneInterface { music_.PlayForGame(); } override SceneInterface Update(KeyInput input) { - context_.OperateScheduledControllers(music_.beat); + const beat = music_.beat; + + if (beat >= context_.length) { + music_.StopPlaying(); + result_scene_.Initialize(music_, 0); // TODO: pass a proper score + return result_scene_; + } + + context_.OperateScheduledControllers(beat); // TODO: actor accelaration @@ -52,6 +62,8 @@ class PlayScene : SceneInterface { } private: + ResultScene result_scene_; + Music music_; sjplayer.Context context_; } diff --git a/src/sj/ResultScene.d b/src/sj/ResultScene.d new file mode 100644 index 0000000..83e0a8b --- /dev/null +++ b/src/sj/ResultScene.d @@ -0,0 +1,48 @@ +/// License: MIT +module sj.ResultScene; + +import gl4d; + +import sj.FontSet, + sj.KeyInput, + sj.LobbyWorld, + sj.Music, + sj.ProgramSet, + sj.SceneInterface; + +/// +class ResultScene : SceneInterface { + public: + /// + this(LobbyWorld lobby, ProgramSet programs, FontSet fonts) { + lobby_ = lobby; + programs_ = programs; + fonts_ = fonts; + } + ~this() { + } + + /// + void SetupSceneDependency() { + } + + /// + void Initialize(Music music, int score) { + music_ = music; + } + override SceneInterface Update(KeyInput input) { + return this; + } + override void Draw() { + lobby_.Draw(); + } + + private: + LobbyWorld lobby_; + + ProgramSet programs_; + + FontSet fonts_; + + Music music_; +}