diff options
Diffstat (limited to 'game/missile/MissileSubScene.cpp')
-rw-r--r-- | game/missile/MissileSubScene.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/game/missile/MissileSubScene.cpp b/game/missile/MissileSubScene.cpp index 6719c3d..6df6c87 100644 --- a/game/missile/MissileSubScene.cpp +++ b/game/missile/MissileSubScene.cpp @@ -1,6 +1,8 @@ #include "MissileSubScene.h" #include "../Config.h" #include "../missile/MissileScript.h" +#include "Random.h" +#include "missile/AlertScript.h" #include <crepe/api/AI.h> #include <crepe/api/Animator.h> @@ -10,14 +12,10 @@ #include <crepe/api/Scene.h> #include <crepe/api/Sprite.h> #include <crepe/types.h> -#include <random> using namespace crepe; void MissileSubScene::create(crepe::Scene & scn) { - std::random_device rd; - std::mt19937 gen(rd()); - GameObject missle = scn.new_object("missile", "missile", {0, 0}, 0, 1); Asset missle_ss {"asset/obstacles/missile/missile.png"}; @@ -27,6 +25,7 @@ void MissileSubScene::create(crepe::Scene & scn) { Asset missile_fire {"asset/sfx/missile_launch.ogg"}; missle.add_component<BehaviorScript>().set_script<MissileScript>().active = false; + missle.add_component<BehaviorScript>().set_script<AlertScript>(); auto & sound = missle.add_component<AudioSource>(missile_fire); sound.volume = 0.5; @@ -88,16 +87,16 @@ void MissileSubScene::create(crepe::Scene & scn) { missile_explosion_sprite.active = false; explosion_anim.active = false; - std::uniform_int_distribution<> dist(200, 250); - missle.add_component<Rigidbody>(Rigidbody::Data { - .body_type = Rigidbody::BodyType::KINEMATIC, - .max_linear_velocity = static_cast<float>(dist(gen)), - .kinematic_collision = false, - .collision_layers = {COLL_LAY_PLAYER, COLL_LAY_BOT_TOP}, - .collision_layer = COLL_LAY_MISSILE, - }); + missle + .add_component<Rigidbody>(Rigidbody::Data { + .body_type = Rigidbody::BodyType::KINEMATIC, + .max_linear_velocity = Random::f(250, 200), + .kinematic_collision = false, + .collision_layers = {COLL_LAY_PLAYER, COLL_LAY_BOT_TOP}, + .collision_layer = COLL_LAY_MISSILE, + }); - missle.add_component<CircleCollider>(3); + missle.add_component<CircleCollider>(3).active = false; auto & missle_ai = missle.add_component<AI>(1000); } |