diff options
author | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-10 14:47:17 +0100 |
---|---|---|
committer | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-10 14:47:17 +0100 |
commit | bcf9bd69f173ecee0104c84e4eadc990f17569c6 (patch) | |
tree | 712d36dec5257a5524269dde85345ceaf90504d1 /game/missile/MissileSubScene.cpp | |
parent | 433c840c14782d84b4b95265b3e6f7a1f67ade3b (diff) | |
parent | 798237b661e8e49284e78ffb1a16599cf6a46a6d (diff) |
Merge remote-tracking branch 'origin/master' into max/game2
Diffstat (limited to 'game/missile/MissileSubScene.cpp')
-rw-r--r-- | game/missile/MissileSubScene.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/game/missile/MissileSubScene.cpp b/game/missile/MissileSubScene.cpp index 6719c3d..d325050 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,15 @@ 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)), + .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); } |