diff --git a/DataComponent_8h_source.html b/DataComponent_8h_source.html index ebd734f..5ca372e 100644 --- a/DataComponent_8h_source.html +++ b/DataComponent_8h_source.html @@ -131,29 +131,31 @@ $(function(){initNavTree('DataComponent_8h_source.html',''); initResizable(true)
7#include "Component.h"
8
-
10class DataComponent : public Component
+
10class DataComponent : public Component
11{
12public:
-
13 DataComponent() {};
-
14 ~DataComponent() {};
-
21 template <typename T>
-
22 void setEntry(const std::string& key, const T& value) { dataMap.insert_or_assign(key, value); }
-
23
-
30 template<typename T>
-
-
31 std::optional<T> getEntry(std::string key) const {
-
32 if (!this->dataMap.contains(key)) return std::nullopt;
-
33 const std::any& value = this->dataMap.at(key);
-
34 if (value.type() != typeid(T)) { return std::nullopt; }
-
35 return std::any_cast<T>(value);
-
36 }
+ +
15 ~DataComponent() {};
+
22 template <typename T>
+
23 void setEntry(const std::string& key, const T& value) { dataMap.insert_or_assign(key, value); }
+
24
+
32 template<typename T>
+
+
33 std::optional<T> getEntry(std::string key) const {
+
34 if (!this->dataMap.contains(key)) return std::nullopt;
+
35 const std::any& value = this->dataMap.at(key);
+
36 if (value.type() != typeid(T)) { return std::nullopt; }
+
37 return std::any_cast<T>(value);
+
38 }
-
37private:
-
38 std::map<std::string, std::any> dataMap;
-
39};
+
39private:
+
40 std::map<std::string, std::any> dataMap;
+
41};
-
void setEntry(const std::string &key, const T &value)
Set a key-value pair of any type in the data map.
Definition DataComponent.h:22
-
std::optional< T > getEntry(std::string key) const
Get a value of type T from the data map.
Definition DataComponent.h:31
+
DataComponent class to centrally store data about an entity such as stats.
Definition DataComponent.h:11
+
DataComponent()
The data component only has a default constructor.
Definition DataComponent.h:14
+
void setEntry(const std::string &key, const T &value)
Set a key-value pair of any type in the data map.
Definition DataComponent.h:23
+
std::optional< T > getEntry(std::string key) const
Get a value of type T from the data map.
Definition DataComponent.h:33
diff --git a/SpriteComponent_8h_source.html b/SpriteComponent_8h_source.html index 223eab8..b0e5426 100644 --- a/SpriteComponent_8h_source.html +++ b/SpriteComponent_8h_source.html @@ -138,7 +138,7 @@ $(function(){initNavTree('SpriteComponent_8h_source.html',''); initResizable(tru
14class TransformComponent;
15
-
17class SpriteComponent : public Component, public RenderObject
+
17class SpriteComponent : public Component, public RenderObject
18{
19public:
20 int animationIndex = 0;
@@ -167,39 +167,35 @@ $(function(){initNavTree('SpriteComponent_8h_source.html',''); initResizable(tru
43public:
44 //debug
45 Textures getTexture() { return this->textureEnum; }
-
46
-
47
-
48
-
52 SpriteComponent(Textures texture, int zIndex);
-
53
-
58 SpriteComponent(Textures texture, int xOffset, int yOffset, int zIndex);
-
59
-
64 SpriteComponent(const char* path, int xOffset, int yOffset, int zIndex);
-
65
-
86 SpriteComponent(
-
87 Textures texture,
-
88 bool isAnimated,
-
89 std::map<std::string, std::unique_ptr<Animation>>* animationList,
-
90 std::string defaultAnimation,
-
91 int zIndex,
-
92 int xOffset = 0,
-
93 int yOffset = 0);
-
94
-
95 ~SpriteComponent();
-
96
-
97 void setTexture(Textures texture);
-
98 void setMapTileTexture(const char* path);
-
99
-
100 void init() override;
-
101 void update(uint_fast16_t diffTime) override;
-
102 void draw() override;
-
103
-
106 void playAnimation(std::string type);
-
107 void setDirection(Direction direction);
-
108};
+
46
+
51 SpriteComponent(Textures texture, int zIndex, int xOffset = 0, int yOffset = 0);
+
52
+
57 SpriteComponent(const char* path, int zIndex, int xOffset = 0, int yOffset = 0);
+
58
+
79 SpriteComponent(
+
80 Textures texture,
+
81 bool isAnimated,
+
82 std::map<std::string, std::unique_ptr<Animation>>* animationList,
+
83 std::string defaultAnimation,
+
84 int zIndex,
+
85 int xOffset = 0,
+
86 int yOffset = 0);
+
87
+
88 ~SpriteComponent();
+
89
+
90 void setTexture(Textures texture);
+
91 void setMapTileTexture(const char* path);
+
92
+
93 void init() override;
+
94 void update(uint_fast16_t diffTime) override;
+
95 void draw() override;
+
96
+
99 void playAnimation(std::string type);
+
100 void setDirection(Direction direction);
+
101};
-
SpriteComponent::playAnimation
void playAnimation(std::string type)
By name select which animation should be played (gets looped)
Definition SpriteComponent.cpp:101
-
SpriteComponent::SpriteComponent
SpriteComponent(Textures texture, int zIndex)
Constructor for SpriteComponent.
Definition SpriteComponent.cpp:18
+
SpriteComponent::SpriteComponent
SpriteComponent(Textures texture, int zIndex, int xOffset=0, int yOffset=0)
Definition SpriteComponent.cpp:18
+
SpriteComponent::playAnimation
void playAnimation(std::string type)
By name select which animation should be played (gets looped)
Definition SpriteComponent.cpp:95
Textures
Forward declaration of the Textures enum class.
TransformComponent
The transform component is responsible for the position, direction and size of an entity....
Definition TransformComponent.h:10
diff --git a/TransformComponent_8h_source.html b/TransformComponent_8h_source.html index a4bb4c4..5af8070 100644 --- a/TransformComponent_8h_source.html +++ b/TransformComponent_8h_source.html @@ -134,26 +134,28 @@ $(function(){initNavTree('TransformComponent_8h_source.html',''); initResizable(
10{
11public:
12 Vector2D position; // TODO: change to int to save CPU time -> possibly subpixel coordinates
-
13 Vector2D direction;
-
14
-
15 int height = 32;
-
16 int width = 32;
-
17 float scale = 1;
-
18
-
20
-
22 explicit TransformComponent(float scale = 1);
+
13
+
18 Vector2D direction;
+
19
+
20 int height = 32;
+
21 int width = 32;
+
22 float scale = 1;
23
-
27 TransformComponent(float x, float y, float scale = 1);
+
25
+
27 explicit TransformComponent(float scale = 1);
28
-
34 TransformComponent(float x, float y, int w, int h, float scale = 1);
-
35
-
36 void init() override;
-
37 void update(uint_fast16_t diffTime) override;
-
38 void setPositionAfterCollision(Vector2D& positionChange);
-
39 int getSpeed();
+
32 TransformComponent(float x, float y, float scale = 1);
+
33
+
39 TransformComponent(float x, float y, int w, int h, float scale = 1);
40
-
41};
+
41 void init() override;
+
42 void update(uint_fast16_t diffTime) override;
+
43 void setPositionAfterCollision(Vector2D& positionChange);
+
44 int getSpeed();
+
45
+
46};
+
TransformComponent::direction
Vector2D direction
The direction in which the entity is moving. (0, 0) is the default and signifies no movement.
Definition TransformComponent.h:18
TransformComponent::TransformComponent
TransformComponent(float scale=1)
Definition TransformComponent.cpp:16
diff --git a/classDataComponent-members.html b/classDataComponent-members.html index 30334b7..c7c424c 100644 --- a/classDataComponent-members.html +++ b/classDataComponent-members.html @@ -125,8 +125,9 @@ $(function(){initNavTree('classDataComponent.html',''); initResizable(true); });

This is the complete list of members for DataComponent, including all inherited members.

- - + + +
getEntry(std::string key) constDataComponentinline
setEntry(const std::string &key, const T &value)DataComponentinline
DataComponent()DataComponentinline
getEntry(std::string key) constDataComponentinline
setEntry(const std::string &key, const T &value)DataComponentinline
diff --git a/classDataComponent.html b/classDataComponent.html index 6a7bede..f9d846c 100644 --- a/classDataComponent.html +++ b/classDataComponent.html @@ -133,6 +133,10 @@ $(function(){initNavTree('classDataComponent.html',''); initResizable(true); }); + + + @@ -171,9 +175,10 @@ template<typename T>

Get a value of type T from the data map.

-

e.g.

getEntry<int>("speed");
-
std::optional< T > getEntry(std::string key) const
Get a value of type T from the data map.
Definition DataComponent.h:31
-

in this case the key is "speed" and the value is returned as an integer

Parameters
+

e.g.

getEntry<int>("speed").value();
+
std::optional< T > getEntry(std::string key) const
Get a value of type T from the data map.
Definition DataComponent.h:33
+

in this case the key is "speed" and the value is returned as an integer

+

the value() or value_or() is NEEDED to handle the optional return type

Parameters

Public Member Functions

DataComponent ()
 The data component only has a default constructor.
 
template<typename T>
void setEntry (const std::string &key, const T &value)
 Set a key-value pair of any type in the data map.
keyThe name to retrieve the value from
@@ -214,7 +219,7 @@ template<typename T>

Set a key-value pair of any type in the data map.

e.g.

setEntry("speed", 180);
-
void setEntry(const std::string &key, const T &value)
Set a key-value pair of any type in the data map.
Definition DataComponent.h:22
+
void setEntry(const std::string &key, const T &value)
Set a key-value pair of any type in the data map.
Definition DataComponent.h:23

in this case the key is "speed" and the value is set to an integer of 180

Parameters
diff --git a/classDataComponent.js b/classDataComponent.js index 44c3d22..7a91080 100644 --- a/classDataComponent.js +++ b/classDataComponent.js @@ -1,5 +1,6 @@ var classDataComponent = [ + [ "DataComponent", "classDataComponent.html#a1d9bc3a1c818e646be5d093119edeb01", null ], [ "getEntry", "classDataComponent.html#a6e71b0bec578a208eb716676e3ccf667", null ], [ "setEntry", "classDataComponent.html#a1dd53c6cb91e572090c2b6853881f8c9", null ] ]; \ No newline at end of file diff --git a/classSpriteComponent-members.html b/classSpriteComponent-members.html index 2fca3e8..3faa321 100644 --- a/classSpriteComponent-members.html +++ b/classSpriteComponent-members.html @@ -126,10 +126,9 @@ $(function(){initNavTree('classSpriteComponent.html',''); initResizable(true); }

This is the complete list of members for SpriteComponent, including all inherited members.

keyThe name to store the value under
- - - - + + +
playAnimation(std::string type)SpriteComponent
SpriteComponent(Textures texture, int zIndex)SpriteComponent
SpriteComponent(Textures texture, int xOffset, int yOffset, int zIndex)SpriteComponent
SpriteComponent(const char *path, int xOffset, int yOffset, int zIndex)SpriteComponent
SpriteComponent(Textures texture, bool isAnimated, std::map< std::string, std::unique_ptr< Animation > > *animationList, std::string defaultAnimation, int zIndex, int xOffset=0, int yOffset=0)SpriteComponent
SpriteComponent(Textures texture, int zIndex, int xOffset=0, int yOffset=0)SpriteComponent
SpriteComponent(const char *path, int zIndex, int xOffset=0, int yOffset=0)SpriteComponent
SpriteComponent(Textures texture, bool isAnimated, std::map< std::string, std::unique_ptr< Animation > > *animationList, std::string defaultAnimation, int zIndex, int xOffset=0, int yOffset=0)SpriteComponent
diff --git a/classSpriteComponent.html b/classSpriteComponent.html index f956c78..8a86b9c 100644 --- a/classSpriteComponent.html +++ b/classSpriteComponent.html @@ -133,13 +133,10 @@ $(function(){initNavTree('classSpriteComponent.html',''); initResizable(true); } - - - - - - - + + + + @@ -150,8 +147,8 @@ Public Member Functions

Detailed Description

SpriteComponent class to handle sprite rendering and animation of entities.

Constructor & Destructor Documentation

- -

◆ SpriteComponent() [1/4]

+ +

◆ SpriteComponent() [1/3]

@@ -164,47 +161,17 @@ Public Member Functions
- - -

Public Member Functions

 SpriteComponent (Textures texture, int zIndex)
 Constructor for SpriteComponent.
 
 SpriteComponent (Textures texture, int xOffset, int yOffset, int zIndex)
 
 SpriteComponent (const char *path, int xOffset, int yOffset, int zIndex)
 
 SpriteComponent (Textures texture, int zIndex, int xOffset=0, int yOffset=0)
 
 SpriteComponent (const char *path, int zIndex, int xOffset=0, int yOffset=0)
 
 SpriteComponent (Textures texture, bool isAnimated, std::map< std::string, std::unique_ptr< Animation > > *animationList, std::string defaultAnimation, int zIndex, int xOffset=0, int yOffset=0)
 Constructor used for animated sprites.
 
int zIndex )
-
- -

Constructor for SpriteComponent.

-
Parameters
- - - -
textureThe texture to be used for the sprite, must be a Texture enum
zIndexThe z-index of the sprite, used for rendering order, in order to show up on the map, the zIndex must be higher than the layer you want it to show up on
-
-
- -
- - -

◆ SpriteComponent() [2/4]

- -
-
- - - - - + - + - - - - - - +
SpriteComponent::SpriteComponent (Textures texture, int zIndex,
int xOffset, int xOffset = 0,
int yOffset,
int zIndex )int yOffset = 0 )
@@ -220,8 +187,8 @@ Public Member Functions
- -

◆ SpriteComponent() [3/4]

+ +

◆ SpriteComponent() [2/3]

@@ -234,17 +201,17 @@ Public Member Functions - int xOffset, + int zIndex, - int yOffset, + int xOffset = 0, - int zIndex ) + int yOffset = 0 )
@@ -261,7 +228,7 @@ Public Member Functions
-

◆ SpriteComponent() [4/4]

+

◆ SpriteComponent() [3/3]

diff --git a/classSpriteComponent.js b/classSpriteComponent.js index 386a096..e72108b 100644 --- a/classSpriteComponent.js +++ b/classSpriteComponent.js @@ -1,8 +1,7 @@ var classSpriteComponent = [ - [ "SpriteComponent", "classSpriteComponent.html#af767b0da914fc583613626ac58505d58", null ], - [ "SpriteComponent", "classSpriteComponent.html#a2c2b0ac3fc6418bb475d257597905e66", null ], - [ "SpriteComponent", "classSpriteComponent.html#a5987774516010e021703a02a37d0509b", null ], + [ "SpriteComponent", "classSpriteComponent.html#a986be57e30c06ed8df1479394d185563", null ], + [ "SpriteComponent", "classSpriteComponent.html#a776a161c30dbfd0f7dc7d42d477b45bb", null ], [ "SpriteComponent", "classSpriteComponent.html#a2c60f55924b1d18b9e6fb530b5c5346a", null ], [ "playAnimation", "classSpriteComponent.html#aa4ebb6763d8b994f412dec66ecf58c59", null ] ]; \ No newline at end of file diff --git a/classTransformComponent-members.html b/classTransformComponent-members.html index 1b1b634..29bfbe7 100644 --- a/classTransformComponent-members.html +++ b/classTransformComponent-members.html @@ -125,9 +125,10 @@ $(function(){initNavTree('classTransformComponent.html',''); initResizable(true)

This is the complete list of members for TransformComponent, including all inherited members.

- - - + + + +
TransformComponent(float scale=1)TransformComponentexplicit
TransformComponent(float x, float y, float scale=1)TransformComponent
TransformComponent(float x, float y, int w, int h, float scale=1)TransformComponent
directionTransformComponent
TransformComponent(float scale=1)TransformComponentexplicit
TransformComponent(float x, float y, float scale=1)TransformComponent
TransformComponent(float x, float y, int w, int h, float scale=1)TransformComponent
diff --git a/classTransformComponent.html b/classTransformComponent.html index 19e4bad..ba0ce0c 100644 --- a/classTransformComponent.html +++ b/classTransformComponent.html @@ -121,6 +121,7 @@ $(function(){initNavTree('classTransformComponent.html',''); initResizable(true)
TransformComponent Class Reference
@@ -139,6 +140,12 @@ Public Member Functions    TransformComponent (float x, float y, int w, int h, float scale=1)   + + + + +

+Public Attributes

Vector2D direction
 The direction in which the entity is moving. (0, 0) is the default and signifies no movement.
 

Detailed Description

The transform component is responsible for the position, direction and size of an entity. It is used to move the entity in the game world and to determine its size and position on the screen.

@@ -253,6 +260,26 @@ Public Member Functions
+ + +

Member Data Documentation

+ +

◆ direction

+ +
+
+ + + + +
Vector2D TransformComponent::direction
+
+ +

The direction in which the entity is moving. (0, 0) is the default and signifies no movement.

+

access direction with direction.x and direction.y for each direction

+

x = 1 for right, -1 for left

+

y = 1 for down, -1 for up

+

The documentation for this class was generated from the following files: diff --git a/functions_func.html b/functions_func.html index 84e758b..3e53b25 100644 --- a/functions_func.html +++ b/functions_func.html @@ -139,6 +139,7 @@ $(function(){initNavTree('functions_func.html',''); initResizable(true); });

- d -

@@ -218,7 +219,7 @@ $(function(){initNavTree('functions_func.html',''); initResizable(true); });
  • setEntry() : DataComponent
  • setMusicVolume() : SoundManager
  • setSoundVolume() : SoundManager
  • -
  • SpriteComponent() : SpriteComponent
  • +
  • SpriteComponent() : SpriteComponent
  • diff --git a/functions_vars.html b/functions_vars.html index 31bc1dc..800812c 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -122,6 +122,7 @@ $(function(){initNavTree('functions_vars.html',''); initResizable(true); });
    Here is a list of all documented variables with links to the class documentation for each member: