aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Animator.cpp2
-rw-r--r--src/crepe/api/Animator.h2
-rw-r--r--src/crepe/api/BehaviorScript.h3
-rw-r--r--src/crepe/api/CMakeLists.txt1
-rw-r--r--src/crepe/api/Camera.h2
-rw-r--r--src/crepe/api/Config.h17
-rw-r--r--src/crepe/api/LoopManager.hpp4
-rw-r--r--src/crepe/api/LoopTimer.h1
-rw-r--r--src/crepe/api/Rigidbody.h2
-rw-r--r--src/crepe/api/SceneManager.h3
-rw-r--r--src/crepe/api/Script.cpp3
-rw-r--r--src/crepe/api/Script.hpp8
-rw-r--r--src/crepe/api/Sprite.h1
-rw-r--r--src/crepe/api/Transform.h8
14 files changed, 22 insertions, 35 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index 54b2ec3..cccbc67 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -1,6 +1,4 @@
-#include <cstdint>
-
#include "util/Log.h"
#include "Animator.h"
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index 75b8139..3573403 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -1,7 +1,5 @@
#pragma once
-#include <cstdint>
-
#include "Component.h"
#include "Sprite.h"
diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h
index 2982358..1a8910d 100644
--- a/src/crepe/api/BehaviorScript.h
+++ b/src/crepe/api/BehaviorScript.h
@@ -3,6 +3,7 @@
#include <memory>
#include "../Component.h"
+
#include "GameObject.h"
namespace crepe {
@@ -47,8 +48,6 @@ protected:
std::unique_ptr<Script> script = nullptr;
//! Reference to component manager
ComponentManager & component_manager;
-
-private:
//! Script accesses the component manager directly via its parent
// (BehaviorScript) reference
friend class Script;
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 85696c4..f9b370f 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -1,7 +1,6 @@
target_sources(crepe PUBLIC
# AudioSource.cpp
BehaviorScript.cpp
- Script.cpp
GameObject.cpp
Rigidbody.cpp
ParticleEmitter.cpp
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index d8c08a6..bf97731 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -1,7 +1,5 @@
#pragma once
-#include <cstdint>
-
#include "Color.h"
#include "Component.h"
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h
index e3f86bf..92b20b7 100644
--- a/src/crepe/api/Config.h
+++ b/src/crepe/api/Config.h
@@ -4,16 +4,21 @@
namespace crepe {
+/**
+ * \brief Global configuration interface
+ *
+ * This class stores engine default settings. Properties on this class are only
+ * supposed to be modified *before* execution is handed over from the game
+ * programmer to the engine (i.e. the main loop is started).
+ */
class Config {
-private:
- Config() = default;
-
-public:
- ~Config() = default;
-
public:
//! Retrieve handle to global Config instance
static Config & get_instance();
+
+private:
+ Config() = default;
+
// singleton
Config(const Config &) = delete;
Config(Config &&) = delete;
diff --git a/src/crepe/api/LoopManager.hpp b/src/crepe/api/LoopManager.hpp
index 8fb9aa3..85a329b 100644
--- a/src/crepe/api/LoopManager.hpp
+++ b/src/crepe/api/LoopManager.hpp
@@ -2,8 +2,8 @@
#include <cassert>
#include <memory>
+#include <format>
-#include "../Exception.h"
#include "../system/System.h"
#include "LoopManager.h"
@@ -18,7 +18,7 @@ T & LoopManager::get_system() {
const type_info & type = typeid(T);
if (!this->systems.contains(type))
- throw Exception("LoopManager: %s is not initialized", type.name());
+ throw runtime_error(format("LoopManager: {} is not initialized", type.name()));
System * system = this->systems.at(type).get();
T * concrete_system = dynamic_cast<T *>(system);
diff --git a/src/crepe/api/LoopTimer.h b/src/crepe/api/LoopTimer.h
index 85687be..aff4bf7 100644
--- a/src/crepe/api/LoopTimer.h
+++ b/src/crepe/api/LoopTimer.h
@@ -1,7 +1,6 @@
#pragma once
#include <chrono>
-#include <cstdint>
namespace crepe {
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 2e20288..11544e5 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -1,7 +1,5 @@
#pragma once
-#include <cstdint>
-
#include "../Component.h"
#include "Vector2.h"
diff --git a/src/crepe/api/SceneManager.h b/src/crepe/api/SceneManager.h
index 553194f..e854794 100644
--- a/src/crepe/api/SceneManager.h
+++ b/src/crepe/api/SceneManager.h
@@ -13,7 +13,6 @@ class ComponentManager;
class SceneManager {
public:
SceneManager(ComponentManager & mgr);
- virtual ~SceneManager() = default;
public:
/**
@@ -38,8 +37,6 @@ public:
private:
std::vector<std::unique_ptr<Scene>> scenes;
std::string next_scene;
-
-protected:
ComponentManager & component_manager;
};
diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp
deleted file mode 100644
index 390cec7..0000000
--- a/src/crepe/api/Script.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "Script.h"
-
-using namespace crepe;
diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp
index aceb38b..13b8077 100644
--- a/src/crepe/api/Script.hpp
+++ b/src/crepe/api/Script.hpp
@@ -1,7 +1,6 @@
#pragma once
#include "../ComponentManager.h"
-#include "../Exception.h"
#include "BehaviorScript.h"
#include "Script.h"
@@ -10,11 +9,10 @@ namespace crepe {
template <typename T>
T & Script::get_component() const {
- std::vector<std::reference_wrapper<T>> all_components
- = this->get_components<T>();
+ using namespace std;
+ vector<reference_wrapper<T>> all_components = this->get_components<T>();
if (all_components.size() < 1)
- throw Exception("Script: no component found with type = {}",
- typeid(T).name());
+ throw runtime_error(format("Script: no component found with type = {}", typeid(T).name()));
return all_components.back().get();
}
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index deb3f93..754184b 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -1,6 +1,5 @@
#pragma once
-#include <cstdint>
#include <memory>
#include "Color.h"
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index 902dafa..7d6f785 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -28,9 +28,11 @@ protected:
* \param rotation The rotation of the GameObject
* \param scale The scale of the GameObject
*/
- Transform(game_object_id_t id, const Vector2 & point, double rotation = 0,
- double scale = 0);
- //! There is always exactly one transform component per entity
+ Transform(game_object_id_t id, const Vector2 & point, double rotation, double scale);
+ /**
+ * There is always exactly one transform component per entity
+ * \return 1
+ */
virtual int get_instances_max() const { return 1; }
//! ComponentManager instantiates all components
friend class ComponentManager;