#include #include "../Config.h" #include "EnemyConfig.h" #include #include #include #include #include #include #include #include #include #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::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(vec2(60, 30)); //bullet_collider.active = false; Asset bullet_asset {"asset/other_effects/effect_smgbullet_x2.png"}; Sprite & bullet_sprite = bullet.add_component( 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().set_script(); return counter; }