aboutsummaryrefslogtreecommitdiff
path: root/game/missile/MissileSubScene.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-10 14:50:50 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-10 14:50:50 +0100
commit7aa07561a52016007ff852acefa4db68260f0f1e (patch)
treeac438e906e581ee68f9d065dea90a2cbb8436d15 /game/missile/MissileSubScene.cpp
parentd7c8cc30e1d37526cf142f950038500b96760514 (diff)
parent0f8bf257d86b5532f3d6f559e5368668c255af7c (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/game-improvements
Diffstat (limited to 'game/missile/MissileSubScene.cpp')
-rw-r--r--game/missile/MissileSubScene.cpp12
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);
}