diff --git a/src/sj/Game.d b/src/sj/Game.d index 457e1f4..e85efdd 100644 --- a/src/sj/Game.d +++ b/src/sj/Game.d @@ -46,7 +46,7 @@ class Game : AbstractGame { select_.SetupSceneDependency(title_, load_); load_ .SetupSceneDependency(play_); play_ .SetupSceneDependency(result_); - result_.SetupSceneDependency(); + result_.SetupSceneDependency(title_); title_.Initialize(); super(title_); diff --git a/src/sj/ResultScene.d b/src/sj/ResultScene.d index 83e0a8b..82200f7 100644 --- a/src/sj/ResultScene.d +++ b/src/sj/ResultScene.d @@ -1,6 +1,8 @@ /// License: MIT module sj.ResultScene; +import std.math; + import gl4d; import sj.FontSet, @@ -8,11 +10,27 @@ import sj.FontSet, sj.LobbyWorld, sj.Music, sj.ProgramSet, - sj.SceneInterface; + sj.SceneInterface, + sj.TitleScene, + sj.util.Animation, + sj.util.Easing; /// class ResultScene : SceneInterface { public: + /// + enum AnimationFrame = 60; + + /// + enum CubeLoadingRotationSpeed = vec3(PI/100, PI/10, PI/100); + /// + enum CubeLoadingInterval = 0.06; + + /// + enum CubeRotationSpeed = vec3(PI/1000, PI/500, PI/1000); + /// + enum CubeInterval = 0.005; + /// this(LobbyWorld lobby, ProgramSet programs, FontSet fonts) { lobby_ = lobby; @@ -23,14 +41,32 @@ class ResultScene : SceneInterface { } /// - void SetupSceneDependency() { + void SetupSceneDependency(TitleScene title) { + title_scene_ = title; } /// void Initialize(Music music, int score) { music_ = music; + + anime_ = Animation(AnimationFrame); + + cube_interval_ease_ = + Easing!float(CubeLoadingInterval, CubeInterval); + cube_rotation_speed_ease_ = + Easing!vec3(CubeLoadingRotationSpeed, CubeRotationSpeed); } override SceneInterface Update(KeyInput input) { + const ratio = anime_.Update(); + + with (lobby_) { + cube_matrix.rotation += cube_rotation_speed_ease_.Calculate(ratio); + cube_interval = cube_interval_ease_ .Calculate(ratio); + } + if (anime_.isFinished && input.down) { + title_scene_.Initialize(); + return title_scene_; + } return this; } override void Draw() { @@ -38,6 +74,8 @@ class ResultScene : SceneInterface { } private: + TitleScene title_scene_; + LobbyWorld lobby_; ProgramSet programs_; @@ -45,4 +83,8 @@ class ResultScene : SceneInterface { FontSet fonts_; Music music_; + + Animation anime_; + Easing!vec3 cube_rotation_speed_ease_; + Easing!float cube_interval_ease_; }