aboutsummaryrefslogtreecommitdiff
path: root/bullet.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-05 09:25:39 +1000
committerquou <quou@disroot.org>2023-05-05 09:25:39 +1000
commit280552fa4750b5dac9243782f9c0a7e0b7eea6f8 (patch)
tree6385dc740cc965dad7dc628e8b10738724ec0a42 /bullet.c
parent0a083f5a9a747083bbc3a1f0689e76ac5fc3a3b9 (diff)
Add a basic enemy.
Diffstat (limited to 'bullet.c')
-rw-r--r--bullet.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/bullet.c b/bullet.c
index 9acefc2..a2f1c66 100644
--- a/bullet.c
+++ b/bullet.c
@@ -60,6 +60,43 @@ Entity new_player_bullet(
return e;
}
+int new_enemy_bullet(
+ struct World* world,
+ int x,
+ int y,
+ int vx,
+ int vy
+) {
+ Entity e;
+ CBullet* bullet;
+ CPosition* pos;
+ CSprite* sprite;
+
+ e = new_entity(world);
+
+ add_components(
+ world,
+ e,
+ ctype_sprite |
+ ctype_position |
+ ctype_bullet |
+ ctype_enemy_bullet
+ );
+ pos = &world->positions[e];
+ sprite = &world->sprites[e];
+ bullet = &world->bullets[e];
+ pos->x = x;
+ pos->y = y;
+
+ bullet->vx = vx;
+ bullet->vy = vy;
+ bullet->life = 500;
+
+ init_csprite(sprite, sprite_enemy_bullet);
+
+ return e;
+}
+
void bullet_system(World* world) {
int i;
unsigned bits;