Singleton Design Patter
This commit is contained in:
parent
63e6315fae
commit
72b2a6d92d
|
@ -4,10 +4,12 @@
|
|||
],
|
||||
"copyright": "no copyright",
|
||||
"dependencies": {
|
||||
"raylib-d": "~>3.0.2"
|
||||
"raylib-d": "~>3.0.3"
|
||||
},
|
||||
"libs": [ "raylib" ],
|
||||
"description": "2D game with roguelike elements",
|
||||
"description": "2D game",
|
||||
"libs": [
|
||||
"raylib"
|
||||
],
|
||||
"license": "no license",
|
||||
"name": "ourgame"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"fileVersion": 1,
|
||||
"versions": {
|
||||
"ddmp": "0.0.1-0.dev.3",
|
||||
"fluent-asserts": "0.13.3",
|
||||
"libdparse": "0.14.0",
|
||||
"raylib-d": "3.0.3",
|
||||
"stdx-allocator": "2.77.5"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,25 @@
|
|||
import std.stdio;
|
||||
import data;
|
||||
import gstatemanager;
|
||||
|
||||
void main()
|
||||
{
|
||||
writeln("Edit source/app.d to start your project.");
|
||||
void main() {
|
||||
// init
|
||||
InitWindow(windowWidth, windowHeight, "Mission X");
|
||||
scope(exit) CloseWindow();
|
||||
|
||||
// set frames per second
|
||||
SetTargetFPS(60);
|
||||
|
||||
while(!WindowShouldClose()) {
|
||||
// process events
|
||||
|
||||
// update
|
||||
GStateManager.getInstance().hello_world();
|
||||
|
||||
// render
|
||||
BeginDrawing();
|
||||
scope(exit) EndDrawing();
|
||||
|
||||
ClearBackground(Colors.WHITE);
|
||||
// .. draw ..
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
module data;
|
||||
|
||||
public import raylib;
|
||||
public import std.stdio: writeln, write;
|
||||
|
||||
immutable windowWidth = 720;
|
||||
immutable windowHeight = 640;
|
|
@ -0,0 +1,19 @@
|
|||
import data;
|
||||
|
||||
class GStateManager {
|
||||
private static GStateManager instance;
|
||||
|
||||
private this() {}
|
||||
|
||||
static GStateManager getInstance() {
|
||||
if(instance is null) {
|
||||
instance = new GStateManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void hello_world() {
|
||||
writeln("Hello World!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue