aboutsummaryrefslogtreecommitdiff
path: root/game/enemy/EnemyBulletSubScene.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:57:09 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:57:09 +0100
commit714c8798dd0998ea15b1ba697962a97c586457fe (patch)
tree86d36b17a71845cd4b5d16a0e9abd11df0d55c03 /game/enemy/EnemyBulletSubScene.cpp
parentfbd7c84e13381922bf327e20c1abc65337142445 (diff)
parent0de6692dcb029540f4502c5a2f1a0c6634f7b61f (diff)
Merge remote-tracking branch 'origin/wouter/enemyAI' into niels/game
Diffstat (limited to 'game/enemy/EnemyBulletSubScene.cpp')
-rw-r--r--game/enemy/EnemyBulletSubScene.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp
new file mode 100644
index 0000000..5c31f1d
--- /dev/null
+++ b/game/enemy/EnemyBulletSubScene.cpp
@@ -0,0 +1,51 @@
+#include <string>
+
+#include "../Config.h"
+#include "EnemyConfig.h"
+#include <crepe/api/AI.h>
+#include <crepe/api/Animator.h>
+#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/BoxCollider.h>
+#include <crepe/api/CircleCollider.h>
+#include <crepe/api/GameObject.h>
+#include <crepe/api/Rigidbody.h>
+#include <crepe/api/Scene.h>
+#include <crepe/api/Sprite.h>
+
+#include "../Random.h"
+#include "EnemyBulletScript.h"
+#include "EnemyBulletSubScene.h"
+#include "EnemyScript.h"
+using namespace crepe;
+using namespace std;
+int EnemyBulletSubScene::create(Scene & scn, int counter) {
+ string unique_name = "enemy_bullet_" + to_string(counter++);
+ GameObject bullet = scn.new_object(
+ unique_name.c_str(), "enemy_bullet", ENEMY_BULLET_POOL_LOCATION, 0, 1
+ );
+
+ Rigidbody & bullet_body = bullet.add_component<Rigidbody>(Rigidbody::Data {
+ .gravity_scale = 0,
+ .body_type = Rigidbody::BodyType::KINEMATIC,
+
+ .linear_velocity = vec2 {-250, 0},
+ .kinematic_collision = false,
+ .collision_layers = {COLL_LAY_MISSILE,COLL_LAY_ZAPPER},
+ .collision_layer = COLL_LAY_BULLET
+ });
+ bullet_body.active = false;
+ BoxCollider & bullet_collider = bullet.add_component<BoxCollider>(vec2(60, 30));
+ //bullet_collider.active = false;
+ Asset bullet_asset {"asset/other_effects/effect_smgbullet_x2.png"};
+ Sprite & bullet_sprite = bullet.add_component<Sprite>(
+ bullet_asset,
+ Sprite::Data {
+ .flip = {true, false},
+ .sorting_in_layer = SORT_IN_LAY_OBSTACLES,
+ .order_in_layer = 1,
+ .size = vec2(60, 0),
+ }
+ );
+ bullet.add_component<BehaviorScript>().set_script<EnemyBulletScript>();
+ return counter;
+}