[update] Implemented animations for ResultScene.
This commit is contained in:
parent
bda8e5d594
commit
41c91edb72
@ -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_);
|
||||
|
@ -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_;
|
||||
}
|
||||
|
Reference in New Issue
Block a user