commit b8d3207aad5054fe40a47caf8f64056abb1cc7cf
parent bd92d7123edbfa24efb9f176460712702830b854
Author: bsandro <email@bsandro.tech>
Date: Tue, 25 Aug 2026 01:39:57 +0300
base file layout for stuff
Diffstat:
7 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/components/health.h b/components/health.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "ecs/component.h"
+
+typedef struct Health {
+ Component c;
+ int hp;
+} Health;
diff --git a/components/melee.h b/components/melee.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "ecs/component.h"
+
+typedef struct Melee {
+ Component c;
+ int strength;
+} Melee;
diff --git a/components/unit.h b/components/unit.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "ecs/component.h"
+
+typedef struct Unit {
+ Component c;
+ int x;
+ int y;
+} Unit;
diff --git a/core/ecs/component.h b/core/ecs/component.h
@@ -0,0 +1,7 @@
+#pragma once
+
+typedef struct Component {
+ int id;
+ struct Component *prev;
+ struct Component *next;
+} Component;
diff --git a/core/ecs/entity.c b/core/ecs/entity.c
@@ -0,0 +1,19 @@
+#include <string.h>
+#include <stdlib.h>
+#include "core/ecs/entity.h"
+
+Entity * Entity_New(int id) {
+ Entity *e = malloc(sizeof(Entity));
+ bzero(e, sizeof(Entity));
+ e->id = id;
+ return e;
+}
+
+bool Entity_Add_Component(Entity *e, Component *c) {
+ if (e->components!=NULL) return false;
+ return true;
+}
+
+bool Entity_Add_System(Entity *e, System *s) {
+ return true;
+}
diff --git a/core/ecs/entity.h b/core/ecs/entity.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "core/ecs/component.h"
+#include "core/ecs/system.h"
+
+typedef struct Entity {
+ int id;
+ Component *components;
+ System *systems;
+} Entity;
+
+Entity * Entity_New(int id);
+bool Entity_Add_Component(Entity *e, Component *c);
+bool Entity_Add_System(Entity *e, System *s);
diff --git a/core/ecs/system.h b/core/ecs/system.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <stdbool.h>
+#include "core/world.h"
+
+typedef bool (System_Run)(World *w);
+
+typedef struct System {
+ System_Run *run;
+} System;