Added a world state object

This commit is contained in:
Ludovic 'Archivist' Lagouardette 2023-10-02 15:11:24 +02:00
parent fc534fd8e1
commit ce09bd79e9
3 changed files with 15 additions and 3 deletions

View file

@ -9,13 +9,14 @@ import std.format;
import std.conv : to;
import core.time;
import toki.symbols;
import world.screen;
import world;
extern(C) __gshared string[] rt_options = [ "gcopt=initReserve:128 minPoolSize:256 parallel:2 profile:1" ];
int main(string[] args) {
try {
worldContents = new WorldObjectList;
InitWindow(800,600,"Unnamed project");
log(LogLevel.INFOHIGH, "Window Initialized...");
Screen.x = Screen.y = 0;
@ -58,6 +59,12 @@ int main(string[] args) {
log(LogLevel.INFOLOW, "Render start...");
BeginDrawing();{
ClearBackground(Colors.WHITE);
foreach (obj; worldContents)
{
obj.render(deltaTime);
}
DrawFPS(0,0);
auto pos = GetMousePosition();
DrawText(toStringz(format("%f, %f", pos.x, pos.y)), 0, 24, 20, Colors.GREEN);

View file

@ -4,4 +4,7 @@ public {
import world.world_object;
import world.entity;
import world.rigid;
import world.screen;
WorldObjectList worldContents;
}

View file

@ -1,12 +1,14 @@
module world.world_object;
import utils.shapes;
import utils.indexedarray;
alias WorldObjectList = IndexedArray!(WorldObject, 1<<15);
class WorldObject {
public Vec2f position;
public Rectf hitbox;
void update(float deltaTime);
void render(float deltaTime);
abstract void update(float deltaTime);
abstract void render(float deltaTime);
}