aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-02 21:37:07 +1000
committerquou <quou@disroot.org>2023-05-02 21:37:07 +1000
commit65fa1051585f5345c3270db73ab53b7a0dbbaa50 (patch)
tree30fed63168b86f8de48698174b265ffbdfae4343 /main.c
parentd3745895ca0107c705b2d89b8b80e254536dad86 (diff)
Add ECS.
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/main.c b/main.c
index c9cede7..499f313 100644
--- a/main.c
+++ b/main.c
@@ -1,20 +1,33 @@
#include "asset.h"
#include "render.h"
+#include "systems.h"
+#include "world.h"
+
+World world;
+Entity player;
void on_init(int argc, char** argv) {
+ CSprite* sprite;
+ CPosition* pos;
+
init_renderer();
load_assets();
-}
-void on_update() {
- const Bitmap* b = get_bitmap(asset_id_usr);
- Rectangle r;
+ init_world(&world);
- r = make_rect(0, 0, 189, 89);
+ player = new_entity(&world);
+ add_components(&world, player, ctype_sprite | ctype_position);
+ sprite = &world.sprites[player];
+ pos = &world.positions[player];
+ pos->x = 32;
+ pos->y = 70;
+ sprite->id = asset_id_char;
+ sprite->rect = make_rect(0, 16, 16, 16);
+}
- renderer_begin_frame();
- render_bitmap(b, 0, 0, &r);
+void on_update() {
+ sprite_system(&world);
}
void on_deinit() {