[add] Added SelectScene.
This commit is contained in:
parent
3f05669fbd
commit
d3b02a184f
BIN
res/sounds/spotlight.wav
Normal file
BIN
res/sounds/spotlight.wav
Normal file
Binary file not shown.
@ -17,6 +17,7 @@ class AbstractScene : SceneInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override SceneInterface TakeNextScene() {
|
override SceneInterface TakeNextScene() {
|
||||||
|
scope(exit) next_ = null;
|
||||||
return next_;
|
return next_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import sj.AbstractGame,
|
|||||||
sj.FontSet,
|
sj.FontSet,
|
||||||
sj.LobbyWorld,
|
sj.LobbyWorld,
|
||||||
sj.ProgramSet,
|
sj.ProgramSet,
|
||||||
|
sj.SelectScene,
|
||||||
sj.TitleScene;
|
sj.TitleScene;
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -17,8 +18,11 @@ class Game : AbstractGame {
|
|||||||
|
|
||||||
lobby_ = new LobbyWorld(programs_);
|
lobby_ = new LobbyWorld(programs_);
|
||||||
|
|
||||||
title_ = new TitleScene(lobby_, programs_);
|
title_ = new TitleScene(lobby_, programs_);
|
||||||
title_.SetupSceneDependency(title_); // TODO: specify proper next scene
|
select_ = new SelectScene(lobby_, programs_);
|
||||||
|
|
||||||
|
title_.SetupSceneDependency(select_);
|
||||||
|
select_.SetupSceneDependency(title_);
|
||||||
|
|
||||||
super(title_);
|
super(title_);
|
||||||
}
|
}
|
||||||
@ -40,4 +44,6 @@ class Game : AbstractGame {
|
|||||||
LobbyWorld lobby_;
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
TitleScene title_;
|
TitleScene title_;
|
||||||
|
|
||||||
|
SelectScene select_;
|
||||||
}
|
}
|
||||||
|
61
src/sj/SelectScene.d
Normal file
61
src/sj/SelectScene.d
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/// License: MIT
|
||||||
|
module sj.SelectScene;
|
||||||
|
|
||||||
|
import derelict.sfml2.audio;
|
||||||
|
|
||||||
|
import sj.AbstractScene,
|
||||||
|
sj.KeyInput,
|
||||||
|
sj.LobbyWorld,
|
||||||
|
sj.ProgramSet,
|
||||||
|
sj.SceneInterface;
|
||||||
|
|
||||||
|
///
|
||||||
|
class SelectScene : AbstractScene {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
enum SpotlightSound = cast(ubyte[]) import("sounds/spotlight.wav");
|
||||||
|
|
||||||
|
///
|
||||||
|
this(LobbyWorld lobby, ProgramSet program) {
|
||||||
|
lobby_ = lobby;
|
||||||
|
|
||||||
|
const buf = SpotlightSound;
|
||||||
|
spotlight_buffer_ = sfSoundBuffer_createFromMemory(buf.ptr, buf.length);
|
||||||
|
sound_ = sfSound_create();
|
||||||
|
|
||||||
|
first_ = true;
|
||||||
|
}
|
||||||
|
~this() {
|
||||||
|
sfSound_destroy(sound_);
|
||||||
|
sfSoundBuffer_destroy(spotlight_buffer_);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void SetupSceneDependency(SceneInterface title_scene) {
|
||||||
|
title_scene_ = title_scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
override void Update(KeyInput input) {
|
||||||
|
if (first_) {
|
||||||
|
sfSound_setBuffer(sound_, spotlight_buffer_);
|
||||||
|
sfSound_play(sound_);
|
||||||
|
}
|
||||||
|
first_ = false;
|
||||||
|
|
||||||
|
if (input.up) GoNextScene(title_scene_);
|
||||||
|
}
|
||||||
|
override void Draw() {
|
||||||
|
lobby_.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SceneInterface title_scene_;
|
||||||
|
|
||||||
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
|
sfSoundBuffer* spotlight_buffer_;
|
||||||
|
|
||||||
|
sfSound* sound_;
|
||||||
|
|
||||||
|
bool first_;
|
||||||
|
}
|
@ -38,6 +38,8 @@ class TitleScene : AbstractScene {
|
|||||||
|
|
||||||
override void Update(KeyInput input) {
|
override void Update(KeyInput input) {
|
||||||
lobby_.cube_matrix.rotation += vec3(PI/600, PI/600, PI/600);
|
lobby_.cube_matrix.rotation += vec3(PI/600, PI/600, PI/600);
|
||||||
|
|
||||||
|
if (input.down) GoNextScene(next_scene_);
|
||||||
}
|
}
|
||||||
override void Draw() {
|
override void Draw() {
|
||||||
lobby_.Draw();
|
lobby_.Draw();
|
||||||
|
Reference in New Issue
Block a user