Compare commits

..
1 Commits
Author SHA1 Message Date
harper 7fd3c96d01 Delete .DS_Store 2026-10-09 17:36:50 -07:00
4 changed files with 2 additions and 15 deletions
-1
View File
@@ -1 +0,0 @@
.DS_Store
+1 -4
View File
@@ -13,18 +13,15 @@ App :: struct {
entities: [dynamic]Entity,
}
// add a new system to the app that will run based on the provided schedule
add_system :: proc(app: ^App, schedule: int, system: proc()) {
append(&app.systems[schedule], system)
}
// add a new plugin to the app. a modular way to add new functionality from beyond the main procedure
add_plugin :: proc(app: ^App, plugin: proc(app: ^App)) {
append(&app.plugins, plugin)
}
// run the app
run :: proc(app: ^App) {
run :: proc(app: ^App, entity_limit: int = 1000) {
for p in app.plugins {
p(app)
}
-9
View File
@@ -8,7 +8,6 @@ Storage :: struct($T: typeid) {
data: map[Entity]T,
}
// adds a new entity id to app and returns it
spawn_entity :: proc(app: ^App) -> Entity {
entity_num := len(&app.entities)
entity: Entity = Entity(entity_num)
@@ -16,30 +15,23 @@ spawn_entity :: proc(app: ^App) -> Entity {
return entity
}
// create a new component of type and add to Storage
add_component :: proc {
add_fresh_component,
add_component_with_data,
}
// initializes new component of type and add to Storage
add_fresh_component :: proc(entity: Entity, storage: ^Storage($T)) {
storage.data[entity] = T{}
}
// creates a copy of component type with data and add to Storage
add_component_with_data :: proc(entity: Entity, storage: ^Storage($T), component: T) {
storage.data[entity] = component
}
// get components saved in Storage
// returns storage.data
slice :: proc(storage: ^Storage($T)) -> map[Entity]T {
return storage.data
}
// get component saved in Storage
// returns Entity and component of type
single :: proc(storage: ^Storage($T)) -> (Entity, ^T) {
for i, &v in slice(storage) {
return i, &v
@@ -47,7 +39,6 @@ single :: proc(storage: ^Storage($T)) -> (Entity, ^T) {
return Entity{}, new(T)
}
// get component of type from entity
get_component :: proc(entity: Entity, storage: ^Storage($T)) -> ^T {
if c, exists := &storage.data[entity]; exists {
return c
+1 -1
View File
@@ -13,7 +13,7 @@ DefaultPlugin :: proc(app: ^App) {
)
}
@(private)
draw_sprite :: proc() {
for i, &v in slice(&Sprite) {
sprite_transform := get_component(i, &Transform)