Initial dlang rewrite

This commit is contained in:
Tulpen 2023-05-20 19:37:04 +01:00
commit ac98291a9c
10 changed files with 141 additions and 0 deletions

19
.gitignore vendored Normal file
View 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
View 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
View file

@ -0,0 +1,4 @@
name "engine"
license "LGPL-3.0"
targetType "dynamicLibrary"
targetName "gameengine"

View 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;
}

View file

@ -0,0 +1,6 @@
module gameengine.graphics.drawable;
import gameengine.renderer;
abstract class Drawable {
abstract void draw(IRenderer* renderer);
}

View 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

View 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
View file

@ -0,0 +1,5 @@
module gameengine.renderer;
interface IRenderer {
void setWindowTitle(string str);
}

6
renderer/rsdl/dub.sdl Normal file
View 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"

View file

@ -0,0 +1,7 @@
module gameengine.renderer.sdl;
import gameengine.renderer;
class RSDL : IRenderer {
}