more ecs
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package shoal
|
package shoal
|
||||||
|
|
||||||
import "core:text/table"
|
|
||||||
import rl "vendor:raylib"
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
STARTUP := 0
|
STARTUP := 0
|
||||||
@@ -12,7 +11,7 @@ App :: struct {
|
|||||||
update_systems: [dynamic]proc(),
|
update_systems: [dynamic]proc(),
|
||||||
draw_systems: [dynamic]proc(),
|
draw_systems: [dynamic]proc(),
|
||||||
plugins: [dynamic]proc(app: ^App),
|
plugins: [dynamic]proc(app: ^App),
|
||||||
entities: [dynamic]Entity,
|
entities: map[int][dynamic]struct{},
|
||||||
}
|
}
|
||||||
|
|
||||||
add_system :: proc(app: ^App, schedule: int, system: proc()) {
|
add_system :: proc(app: ^App, schedule: int, system: proc()) {
|
||||||
@@ -30,6 +29,12 @@ add_plugin :: proc(app: ^App, plugin: proc(app: ^App)) {
|
|||||||
append(&app.plugins, plugin)
|
append(&app.plugins, plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spawn_entity :: proc(app: ^App, components: [dynamic]struct{}) {
|
||||||
|
entity_len := len(&app.entities)
|
||||||
|
|
||||||
|
app.entities[entity_len] = components
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
run :: proc(app: ^App) {
|
run :: proc(app: ^App) {
|
||||||
rl.InitWindow(800, 600, "shoal window")
|
rl.InitWindow(800, 600, "shoal window")
|
||||||
|
|||||||
+13
-1
@@ -1,6 +1,18 @@
|
|||||||
package shoal
|
package shoal
|
||||||
|
|
||||||
Entity :: struct {
|
Entity :: struct {
|
||||||
id: i32,
|
id: int,
|
||||||
components: [dynamic]struct{},
|
components: [dynamic]struct{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spawn_entity :: proc(app: ^App) -> Entity {
|
||||||
|
entity: Entity
|
||||||
|
entity_len := len(&app.entities)
|
||||||
|
entity.id = entity_len
|
||||||
|
|
||||||
|
return entity
|
||||||
|
}
|
||||||
|
|
||||||
|
add_collection :: proc(app: ^App, component: $T) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1 @@
|
|||||||
package shoal
|
package shoal
|
||||||
|
|
||||||
Query :: struct {
|
|
||||||
with: [dynamic]struct{},
|
|
||||||
}
|
|
||||||
|
|
||||||
query :: proc(app: ^App, query: Query) {
|
|
||||||
for e in app.entities {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user