Initial dlang rewrite
This commit is contained in:
commit
ac98291a9c
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Directories
|
||||
.dub
|
||||
*/docs/
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
*.a
|
||||
*.lib
|
||||
*-test-*
|
||||
*.exe
|
||||
*.pdb
|
||||
*.o
|
||||
*.obj
|
||||
*.lst
|
||||
|
||||
# Files
|
||||
docs.json
|
||||
__dummy.html
|
||||
dub.selections.json
|
10
dub.sdl
Normal file
10
dub.sdl
Normal file
|
@ -0,0 +1,10 @@
|
|||
name "gameengine"
|
||||
description "Game engine written in D"
|
||||
authors "Tulpenkiste"
|
||||
copyright "Copyright © 2023, Tulpenkiste"
|
||||
license "LGPL-3.0"
|
||||
targetType "none"
|
||||
dependency "gameengine:engine" version="*"
|
||||
dependency "gameengine:rsdl" version="*"
|
||||
subPackage "engine"
|
||||
subPackage "renderer/rsdl"
|
4
engine/dub.sdl
Normal file
4
engine/dub.sdl
Normal file
|
@ -0,0 +1,4 @@
|
|||
name "engine"
|
||||
license "LGPL-3.0"
|
||||
targetType "dynamicLibrary"
|
||||
targetName "gameengine"
|
44
engine/source/core/engine.d
Normal file
44
engine/source/core/engine.d
Normal file
|
@ -0,0 +1,44 @@
|
|||
module gameengine.core.engine;
|
||||
|
||||
import gameengine.renderer;
|
||||
import gameengine.node.node;
|
||||
import core.time;
|
||||
|
||||
class Engine {
|
||||
this(IRenderer* renderer) {
|
||||
this.renderer = renderer;
|
||||
previousProcessTick = MonoTime.currTime();
|
||||
previousPhysicsProcessTick = MonoTime.currTime();
|
||||
}
|
||||
|
||||
void runNodeProcesses() {
|
||||
MonoTime currentTime = MonoTime.currTime();
|
||||
|
||||
Duration difference = currentTime - previousProcessTick;
|
||||
|
||||
float delta = difference.total!"hnsecs" / 10_000_000.0;
|
||||
|
||||
// Temp
|
||||
debug { import std.stdio : writeln; import std.format; try { writeln(format("%f", delta)); } catch (Exception) {} }
|
||||
foreach (Node* node ; nodeList) {
|
||||
node.process(delta);
|
||||
}
|
||||
|
||||
this.previousProcessTick = MonoTime.currTime();
|
||||
}
|
||||
|
||||
void runNodePhysicsProcesses() {
|
||||
// Schade!
|
||||
this.previousPhysicsProcessTick = MonoTime.currTime();
|
||||
}
|
||||
|
||||
void drawNodes() {}
|
||||
|
||||
string engineVersion() const { return "0.0.0"; }
|
||||
|
||||
private IRenderer* renderer;
|
||||
private MonoTime previousProcessTick;
|
||||
private MonoTime previousPhysicsProcessTick;
|
||||
|
||||
private Node*[] nodeList;
|
||||
}
|
6
engine/source/graphics/drawable.d
Normal file
6
engine/source/graphics/drawable.d
Normal file
|
@ -0,0 +1,6 @@
|
|||
module gameengine.graphics.drawable;
|
||||
import gameengine.renderer;
|
||||
|
||||
abstract class Drawable {
|
||||
abstract void draw(IRenderer* renderer);
|
||||
}
|
34
engine/source/math/types.d
Normal file
34
engine/source/math/types.d
Normal file
|
@ -0,0 +1,34 @@
|
|||
module gameengine.math.types;
|
||||
|
||||
// Structs
|
||||
/// Image
|
||||
|
||||
// RGBA value struct
|
||||
struct Color {
|
||||
float r, g, b, a;
|
||||
}
|
||||
|
||||
// 2D
|
||||
|
||||
// Defines a point within a 2D space.
|
||||
struct Point2D {
|
||||
float x, y;
|
||||
}
|
||||
|
||||
// Defines a given area with a width and height at the given point.
|
||||
struct Rect {
|
||||
float x, y, w, h;
|
||||
}
|
||||
|
||||
// X and Y values using floats.
|
||||
struct Vec2 {
|
||||
float x, y;
|
||||
}
|
||||
|
||||
// X and Y values using integers.
|
||||
struct IntVec2 {
|
||||
int x, y;
|
||||
}
|
||||
|
||||
// Functions
|
||||
// TODO
|
6
engine/source/node/node.d
Normal file
6
engine/source/node/node.d
Normal file
|
@ -0,0 +1,6 @@
|
|||
module gameengine.node.node;
|
||||
|
||||
abstract class Node {
|
||||
abstract void process(float delta);
|
||||
abstract void physicsProcess(float delta);
|
||||
}
|
5
engine/source/renderer.d
Normal file
5
engine/source/renderer.d
Normal file
|
@ -0,0 +1,5 @@
|
|||
module gameengine.renderer;
|
||||
|
||||
interface IRenderer {
|
||||
void setWindowTitle(string str);
|
||||
}
|
6
renderer/rsdl/dub.sdl
Normal file
6
renderer/rsdl/dub.sdl
Normal file
|
@ -0,0 +1,6 @@
|
|||
name "rsdl"
|
||||
dependency "gameengine:engine" version=">=0.0.0"
|
||||
dependency "bindbc-sdl" version="~>1.3.5"
|
||||
targetType "dynamicLibrary"
|
||||
targetName "gameengine_rsdl"
|
||||
sourcePaths "./" "../../engine/source"
|
7
renderer/rsdl/source/rsdl.d
Normal file
7
renderer/rsdl/source/rsdl.d
Normal file
|
@ -0,0 +1,7 @@
|
|||
module gameengine.renderer.sdl;
|
||||
|
||||
import gameengine.renderer;
|
||||
|
||||
class RSDL : IRenderer {
|
||||
|
||||
}
|
Loading…
Reference in a new issue