aboutsummaryrefslogtreecommitdiff
path: root/fx.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-05 13:44:23 +1000
committerquou <quou@disroot.org>2023-05-05 13:44:23 +1000
commitfb104368dd33b66e0575dcc0327cbae7046a4e1e (patch)
tree67a1a66182aa8417b8fbb431576528c28f4a5ab8 /fx.c
parent280552fa4750b5dac9243782f9c0a7e0b7eea6f8 (diff)
Add killing enemies.
Diffstat (limited to 'fx.c')
-rw-r--r--fx.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/fx.c b/fx.c
new file mode 100644
index 0000000..f2a5f54
--- /dev/null
+++ b/fx.c
@@ -0,0 +1,40 @@
+#include "components.h"
+#include "fx.h"
+#include "world.h"
+
+int new_enemy_bullet_explosion(
+ World* world,
+ int x,
+ int y
+) {
+ Entity e;
+ CPosition* pos;
+ CSprite* sprite;
+ CAnimated* animated;
+
+ e = new_entity(world);
+ add_components(
+ world,
+ e,
+ ctype_sprite |
+ ctype_position |
+ ctype_animated |
+ ctype_destroy_on_anim_done
+ );
+
+ pos = &world->positions[e];
+ sprite = &world->sprites[e];
+ animated = &world->animateds[e];
+
+ pos->x = x;
+ pos->y = y;
+
+ sprite->id = asset_id_bullet;
+ sprite->rect = make_rect(0, 0, 16, 16);
+
+ animated->id = animation_enemy_bullet_explode;
+ animated->frame = 0;
+ animated->timer = 0;
+
+ return e;
+}