aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-06 10:46:11 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-06 10:46:11 +0100
commit36942c357663a033582a1dfb39af0d3ab15afd0c (patch)
tree4edf5b5dcdd5fe6ec5011c89583324d291a00850
parentcf6ca6be5a9deac4de921f50d0aedf6a6156e0f4 (diff)
start of enemypool and creation
-rw-r--r--game/CMakeLists.txt2
-rw-r--r--game/enemy/EnemyPool.cpp7
-rw-r--r--game/enemy/EnemyPool.h10
-rw-r--r--game/enemy/EnemySubScene.cpp29
-rw-r--r--game/enemy/EnemySubScene.h10
5 files changed, 58 insertions, 0 deletions
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 937b5e6..a5218a5 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -9,6 +9,8 @@ project(game C CXX)
add_subdirectory(../src crepe)
add_executable(main
+ enemy/EnemyPool.cpp
+ enemy/EnemySubScene.cpp
background/AquariumSubScene.cpp
background/BackgroundSubScene.cpp
background/ForestParallaxScript.cpp
diff --git a/game/enemy/EnemyPool.cpp b/game/enemy/EnemyPool.cpp
new file mode 100644
index 0000000..b5160db
--- /dev/null
+++ b/game/enemy/EnemyPool.cpp
@@ -0,0 +1,7 @@
+#include "EnemySubScene.h"
+#include "EnemyPool.h"
+using namespace std;
+void EnemyPool::create_enemies(crepe::Scene & scn) {
+ EnemySubScene enemy;
+ while(enemy.create(scn) < this->MAXIMUM_AMOUNT);
+}
diff --git a/game/enemy/EnemyPool.h b/game/enemy/EnemyPool.h
new file mode 100644
index 0000000..e2b9ddd
--- /dev/null
+++ b/game/enemy/EnemyPool.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <crepe/api/Scene.h>
+
+class EnemyPool {
+public:
+ void create_enemies(crepe::Scene & scn);
+private:
+ static constexpr int MAXIMUM_AMOUNT = 100;
+};
diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp
new file mode 100644
index 0000000..4187411
--- /dev/null
+++ b/game/enemy/EnemySubScene.cpp
@@ -0,0 +1,29 @@
+#include <string>
+
+#include "EnemySubScene.h"
+#include <crepe/api/GameObject.h>
+#include <crepe/api/Scene.h>
+#include <crepe/api/BoxCollider.h>
+#include <crepe/api/Rigidbody.h>
+#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/Sprite.h>
+using namespace crepe;
+using namespace std;
+int EnemySubScene::create(Scene & scn){
+ vec2 size = {20, 20};
+
+ static int coin_counter = 0;
+ string unique_name = "enemy_" + to_string(coin_counter++);
+ GameObject enemy = scn.new_object(unique_name.c_str(),"enemy",vec2{650,0},0,1);
+ enemy.add_component<Rigidbody>(Rigidbody::Data{
+ .body_type = Rigidbody::BodyType::DYNAMIC,
+ });
+ crepe::OptionalRef<Sprite> enemy_sprite = enemy.add_component<Sprite>(Asset{"asset/coin/coin1_TVOS.png"}, Sprite::Data{
+ .sorting_in_layer = 100,
+ .order_in_layer = 100,
+ .size = vec2(0, 50),
+ });
+ enemy.add_component<>
+
+ return coin_counter;
+}
diff --git a/game/enemy/EnemySubScene.h b/game/enemy/EnemySubScene.h
new file mode 100644
index 0000000..a24020b
--- /dev/null
+++ b/game/enemy/EnemySubScene.h
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace crepe {
+class Scene;
+}
+
+class EnemySubScene {
+public:
+ int create(crepe::Scene & scn);
+};