[add] Added LobbyWorld.

This commit is contained in:
falsycat 2019-10-10 00:00:00 +00:00
parent 887f456a8b
commit 361678a94f
4 changed files with 84 additions and 4 deletions

View File

@ -2,6 +2,8 @@
module sj.Game;
import sj.AbstractGame,
sj.LobbyWorld,
sj.ProgramSet,
sj.TitleScene;
///
@ -9,12 +11,28 @@ class Game : AbstractGame {
public:
///
this() {
title_ = new TitleScene;
title_.Initialize(title_); // TODO: specify proper next scene
programs_ = new ProgramSet;
lobby_ = new LobbyWorld(programs_);
title_ = new TitleScene(lobby_);
title_.SetupSceneDependency(title_); // TODO: specify proper next scene
super(title_);
}
~this() {
title_.destroy();
lobby_.destroy();
programs_.destroy();
}
private:
ProgramSet programs_;
LobbyWorld lobby_;
TitleScene title_;
}

28
src/sj/LobbyWorld.d Normal file
View File

@ -0,0 +1,28 @@
/// License: MIT
module sj.LobbyWorld;
import sjplayer.Background;
import sj.ProgramSet;
///
class LobbyWorld {
public:
///
this(ProgramSet programs) {
background_ = new Background(programs.forPlayers.Get!BackgroundProgram);
}
///
void Draw() {
background_.Draw();
}
///
@property Background background() {
return background_;
}
private:
Background background_;
}

24
src/sj/ProgramSet.d Normal file
View File

@ -0,0 +1,24 @@
/// License: MIT
module sj.ProgramSet;
static import sjplayer = sjplayer.ProgramSet;
///
class ProgramSet {
public:
///
this() {
for_players_ = new sjplayer.ProgramSet;
}
~this() {
for_players_.destroy();
}
///
@property sjplayer.ProgramSet forPlayers() {
return for_players_;
}
private:
sjplayer.ProgramSet for_players_;
}

View File

@ -3,25 +3,35 @@ module sj.TitleScene;
import sj.AbstractScene,
sj.KeyInput,
sj.LobbyWorld,
sj.SceneInterface;
///
class TitleScene : AbstractScene {
public:
///
this() {
this(LobbyWorld lobby) {
lobby_ = lobby;
// TODO: test
import gl4d;
lobby_.background.outer_color = vec4(0.8, 0.8, 0.8, 1);
lobby_.background.inner_color = vec4(1, 1, 1, 1);
}
///
void Initialize(SceneInterface next_scene) {
void SetupSceneDependency(SceneInterface next_scene) {
next_scene_ = next_scene;
}
override void Update(KeyInput input) {
}
override void Draw() {
lobby_.Draw();
}
private:
SceneInterface next_scene_;
LobbyWorld lobby_;
}