2023-10-02 10:41:01 +00:00
|
|
|
import std.stdio: writeln;
|
|
|
|
import std.exception;
|
|
|
|
|
|
|
|
import raylib;
|
|
|
|
import grimoire;
|
|
|
|
import utils.log;
|
|
|
|
import std.string : toStringz;
|
|
|
|
import std.format;
|
|
|
|
import std.conv : to;
|
|
|
|
import core.time;
|
2023-10-02 12:03:13 +00:00
|
|
|
import toki.symbols;
|
2023-10-02 13:11:24 +00:00
|
|
|
import world;
|
2023-10-02 12:03:13 +00:00
|
|
|
|
2023-10-02 10:41:01 +00:00
|
|
|
|
|
|
|
extern(C) __gshared string[] rt_options = [ "gcopt=initReserve:128 minPoolSize:256 parallel:2 profile:1" ];
|
|
|
|
|
|
|
|
int main(string[] args) {
|
|
|
|
try {
|
2023-10-02 13:11:24 +00:00
|
|
|
worldContents = new WorldObjectList;
|
2023-10-02 10:41:01 +00:00
|
|
|
InitWindow(800,600,"Unnamed project");
|
|
|
|
log(LogLevel.INFOHIGH, "Window Initialized...");
|
2023-10-02 13:03:07 +00:00
|
|
|
Screen.x = Screen.y = 0;
|
|
|
|
Screen.width = Screen.px_width = 800;
|
|
|
|
Screen.height = Screen.px_height = 600;
|
2023-10-02 10:41:01 +00:00
|
|
|
log(LogLevel.INFOHIGH, "Readying the engine...");
|
|
|
|
GrEngine engine = new GrEngine();
|
|
|
|
auto grstd = grLoadStdLibrary();
|
|
|
|
auto grloglib = getLogLibrary();
|
|
|
|
engine.addLibrary(grstd);
|
|
|
|
engine.addLibrary(grloglib);
|
|
|
|
log(LogLevel.INFOHIGH, "Readying the compiler...");
|
|
|
|
GrCompiler compiler = new GrCompiler();
|
|
|
|
compiler.addLibrary(grstd);
|
|
|
|
compiler.addLibrary(grloglib);
|
|
|
|
compiler.addFile("./assets/scripts/dummy.gr");
|
|
|
|
log(LogLevel.INFOHIGH, "Compiling Scripts...");
|
|
|
|
auto bytecode = compiler.compile(GrOption.symbols);
|
|
|
|
if(! bytecode) {
|
|
|
|
throw new Exception(compiler.getError().prettify(GrLocale.en_US));
|
|
|
|
}
|
|
|
|
log(LogLevel.INFOHIGH, "Booting Scripts...");
|
|
|
|
engine.load(bytecode);
|
|
|
|
log(LogLevel.INFOHIGH, "Go Hot Dog, Go...");
|
|
|
|
engine.process();
|
|
|
|
|
|
|
|
auto reference = MonoTime.currTime();
|
|
|
|
auto deltaTime = 1f/60f;
|
|
|
|
|
|
|
|
while(! WindowShouldClose()) {
|
|
|
|
if(engine.isPanicking()) {
|
|
|
|
throw new Exception(engine.panicMessage());
|
|
|
|
}
|
|
|
|
log(LogLevel.INFOLOW, format("Frame begin %fs...", deltaTime));
|
|
|
|
log(LogLevel.INFOLOW, "Processing inputs...");
|
|
|
|
log(LogLevel.INFOLOW, "Processing coros...");
|
|
|
|
engine.process();
|
|
|
|
log(LogLevel.INFOLOW, "Processing changes...");
|
|
|
|
|
|
|
|
log(LogLevel.INFOLOW, "Render start...");
|
|
|
|
BeginDrawing();{
|
|
|
|
ClearBackground(Colors.WHITE);
|
2023-10-02 13:11:24 +00:00
|
|
|
|
|
|
|
foreach (obj; worldContents)
|
|
|
|
{
|
|
|
|
obj.render(deltaTime);
|
|
|
|
}
|
|
|
|
|
2023-10-02 10:41:01 +00:00
|
|
|
DrawFPS(0,0);
|
|
|
|
auto pos = GetMousePosition();
|
|
|
|
DrawText(toStringz(format("%f, %f", pos.x, pos.y)), 0, 24, 20, Colors.GREEN);
|
|
|
|
}EndDrawing();
|
|
|
|
auto new_reference = MonoTime.currTime();
|
|
|
|
deltaTime = (new_reference - reference).total!("hnsecs")/10_000_000.0;
|
|
|
|
reference = new_reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseWindow();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
catch(Exception e) {
|
|
|
|
log(LogLevel.ERROR, e.msg);
|
|
|
|
foreach (trace; e.info)
|
|
|
|
log(LogLevel.ERROR, format("at: %s", trace));
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|