0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 07:53:43 +00:00

Docs: Formatting and more content
Some checks failed
/ deploy (push) Failing after 33s

This commit is contained in:
Nimac0 2025-05-02 13:45:07 +02:00
parent 4c2ddb7ff4
commit 70080681e0
25 changed files with 197 additions and 84 deletions

View File

@ -1,7 +1,7 @@
{ {
"fullscreen": false, "fullscreen": false,
"title": "VGG (Very Good Game)", "title": "VGG (Very Good Game)",
"screen_height": 600, "screen_height": 640,
"screen_width": 800, "screen_width": 800,
"icon": "./engine/internalAssets/iconImage.bmp" "icon": "./engine/internalAssets/iconImage.bmp"
} }

View File

@ -548,7 +548,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation. # included in the documentation.
# The default value is: NO. # The default value is: NO.
EXTRACT_STATIC = NO EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO, # locally in source files will be included in the documentation. If set to NO,
@ -573,7 +573,7 @@ EXTRACT_LOCAL_METHODS = NO
# are hidden. # are hidden.
# The default value is: NO. # The default value is: NO.
EXTRACT_ANON_NSPACES = NO EXTRACT_ANON_NSPACES = YES
# If this flag is set to YES, the name of an unnamed parameter in a declaration # If this flag is set to YES, the name of an unnamed parameter in a declaration
# will be determined by the corresponding definition. By default unnamed # will be determined by the corresponding definition. By default unnamed
@ -1060,7 +1060,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the # that contain images that are to be included in the documentation (see the
# \image command). # \image command).
IMAGE_PATH = IMAGE_PATH = ./docs/img
# The INPUT_FILTER tag can be used to specify a program that doxygen should # The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program # invoke to filter for each input file. Doxygen will invoke the filter program

BIN
docs/img/Animations1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
docs/img/Tiled1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/img/Tiled2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
docs/img/Tiled3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
docs/img/Tiled4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
docs/img/Tiled5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
docs/img/Tiled6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

12
docs/md-pages/config.md Normal file
View File

@ -0,0 +1,12 @@
# Configuring the game
By either adding your own configuration .json file and overwriting its path in setConfigFilePath() found in Chickengame.cpp or editing configs/mainConfig.json you can configure some aspects of the game. These are:
- **fullscreen**: bool to determine if you want your game to be displayed in fullscreen or not. Maintains the screen size set in screen_width and screen_height and stretches it out
- **screen_width**: int, in pixels
- **screen_height**: int, in pixels
- **title**: string, the title of the game/the name displayed on the top left of the window
- **icon**: string, path to the bitmap (.btm) you want to use as the app icon of your game

View File

@ -1,31 +1,52 @@
# Entities and Components # Entities and Components
## Entities ## Entities
In the scope of this library entities essentially function like empty containers that you can add components or properties to. So an entity can be whatever you want it to be, give it a texture, make it pickupable, give it collision or all of the above and more. In the scope of this library entities essentially function like empty containers that you can add components or properties to. So an entity can be whatever you want it to be, give it a texture, make it pickupable, give it collision or all of the above and more.
Here is a quick overview over relevant classes containing functions pertaining to the creation and editing of entities: Here is a quick overview over relevant classes containing functions pertaining to the creation and editing of entities:
- Manager - [Manager](@ref Manager)
- Entity - [Entity](@ref Entity)
## Components ## Components
The following components are currently available to you to use in your entities: The following components are currently available to you to use in your entities (the associated managers/handlers are also linked):
- Collider Component
Adds collision functionality to an Entity meaning functionality can be assigned to happen when two Entities collision boxes intersect --> this is used by the library, the developer themselves cannot (yet) add custom functionality to happen on collision. It is used to stop entities from running through tiles given the "collision" tag (see [Tiled](@ref md_docs_2md-pages_2tilemaps) section) and to enable picking up other entities. ---
- Data Component ### [Collider Component](@ref ColliderComponent)
see also [Collision Handler](@ref CollisionHandler)
Custom Data such as Stats can be added to an Entity and accessed using this Component. If an Entity is supposed to have movement the stat "speed" **has to be added**! Adds collision functionality to an Entity meaning functionality can be assigned to happen when two Entities collision boxes intersect --> this is used by the library, the developer themselves cannot (yet) add custom functionality to happen on collision unless the [Collision handler](@ref CollisionHandler) itself is directly used. It is used to stop entities from running through tiles given the "collision" tag (see [Tiled](@ref md_docs_2md-pages_2tilemaps) section) and to enable picking up other entities.
- Interaction Component
---
### [Data Component](@ref DataComponent)
Custom Data such as Stats can be added to an Entity and accessed using this Component.
> [!important]
> If an Entity is supposed to have movement the stat "speed" has to be added and set to a positive int!
---
### [Interaction Component](@ref InteractionComponent)
see also [InteractionEventdataStruct](@ref InteractionEventdataStruct)
Adding this component to an entity tells it to react to triggered Interactions e.g. by button press. For this a custom lambda or function pointer is passed to determine what exactly should happen once an entities ineraction was triggered. Adding this component to an entity tells it to react to triggered Interactions e.g. by button press. For this a custom lambda or function pointer is passed to determine what exactly should happen once an entities ineraction was triggered.
- Pickup Component
> [!note]
> This component is only used to assign a functionality to an entity to be triggered when it is interacted with, to actually map a button to do something such as trigger an interaction refer to [Input Management](@ref md_docs_2md-pages_2inputhandling) and [Eventhandling](@ref md_docs_2md-pages_2eventhandling)
---
### [Pickup Component](@ref PickupComponent)
see also [Pickup Manager](@ref PickupManager)
Entities with pickup components will disappear once another collision having entity with the [Group Label](@ref Entity#GroupLabel) "Player" intersects with it and executes the custom functionality given to it via constructor. Entities with pickup components will disappear once another collision having entity with the [Group Label](@ref Entity#GroupLabel) "Player" intersects with it and executes the custom functionality given to it via constructor.
- Sprite Component
Textures and Animations can be added via this component
- Stateffects Component
Temporary stateffects can be added using this component. Using the time and function passed it will execute whatever is in the function after the given time. It is used to e.g. reset stats after raising them in order to allow for temporary stat raises
- Transform Component
---
### [Transform Component](@ref TransformComponent)
The Transform Component manages the position and movement of an Entity. Multiple overloaded constructors exist depending on whether or not the entity is stationary The Transform Component manages the position and movement of an Entity. Multiple overloaded constructors exist depending on whether or not the entity is stationary
---
### [Sprite Component](@ref SpriteComponent)
Textures and Animations can be added via this component.
> [!important]
> A [Transform Component](@ref TransformComponent) is first needed before adding a Texture as the coordinates from the transform component are needed to tell the game where to render the texture
---
### [Stat Effects Component](@ref StatEffectsComponent)
Temporary stateffects can be added using this component. Using the time and function passed it will execute whatever is in the function after the given time. It is used to e.g. reset stats after raising them in order to allow for temporary stat raises

View File

@ -1,3 +1,5 @@
# Input Management # Input Management
Using the function [registerAction()](@ref InputManager#registerAction) Keys (both key press and key release) can be mapped to do certain actions such as moving an entity. Example code can be found within the template Using the function [registerAction()](@ref InputManager#registerAction) Keys (both key press and key release) can be mapped to do certain actions such as moving an entity. Example code can be found within the template under `Controls.h` and `Controls.cpp`.
**Tip: If you want to apply any Inputs to a specific entity e.g. movement, simply pass the entity as a parameter in the initControls() function**

View File

@ -2,13 +2,18 @@
Here you will (hopefully) find any information necessary to use the different classes and components of this engine to develop your own simple 2D games. Here you will (hopefully) find any information necessary to use the different classes and components of this engine to develop your own simple 2D games.
If you are using this library for the first time it is recommended you follow the following sections step by step.
Alternatively you could also just look at the code in the templates include and src folders and look at the example implementations there. The best place to start is `GameImplementation.h` and `GameImplementation.cpp`. All .cpp files have an associated .h file, please always start in the .h file with the same name as the .cpp file, otherwise you might get confused at some of the inline explanations provided in the files.
The base functionality can be split into a few major sections: The base functionality can be split into a few major sections:
- [Quickstart guide for setting up the library](@ref md_docs_2md-pages_2quickstart) 1. [Quickstart guide for setting up the library](@ref md_docs_2md-pages_2quickstart)
- [Building an environment using Tiled and tmx](@ref md_docs_2md-pages_2tilemaps) 2. [Configuring game settings](@ref md_docs_2md-pages_2config)
- [Entities and Components](@ref md_docs_2md-pages_2entitiesAndComponents) 3. [Building a map using Tiled and tmx and loading it](@ref md_docs_2md-pages_2tilemaps)
- [Input Management](@ref md_docs_2md-pages_2inputhandling) 4. [Entities and Components](@ref md_docs_2md-pages_2entitiesAndComponents)
- [Eventhandling](@ref md_docs_2md-pages_2eventhandling) 5. [Input Management](@ref md_docs_2md-pages_2inputhandling)
6. [Eventhandling](@ref md_docs_2md-pages_2eventhandling)
You can also of course just browse the classes on your own this just act as a more structured separation and docuementation of relevant features You can also of course just browse the classes on your own this just act as a more structured separation and docuementation of relevant features
Example code and quick start docu for each relevant function can be found within the template files themselves, use GameImplementation.cpp as a starting point. **DISCLAIMER: EVERYTHING IN THE GIVEN TEMPLATE CODE IS OPTIONAL EVERYTHING FOUND IN THERE IS JUST A GUIDE AND CAN BE CHANGED AND/OR DELETED WITHOUT A PROBLEM**

View File

@ -1,41 +1,56 @@
# Building an environment using Tiled and tmx # Building a map using Tiled and tmx and loading it
In order to create a map for your game the library has .tmx format support. In order to get .tmx files you use the associated tile editor "Tiled" which gets automatically downloaded when executing the VEGO libraries setup file (the installer is provided the installation itself must be finalized by the user). This section will walk you step by step through the creation of your first map/background using Tiled.
see also: [the official Tiled documentation](https://doc.mapeditor.org/en/stable/manual/introduction/#getting-started) see also: [the official Tiled documentation](https://doc.mapeditor.org/en/stable/manual/introduction/#getting-started)
After opening Tiled, select "New Map", a custom size measured in tiles and as tile size select 32x32 as this is the size the library currently supports. ### Getting started
After opening Tiled, select "New Map", a custom size measured in tiles and as tile size select 32x32 as this is
the size the library currently supports. Also choose the size of your canvas, it is recommended you choose the same size as the one you defined in the [games config](@ref md_docs_2md-pages_2config) (default is 25w x 20h, measured in tiles, to get the pixel size just multiply by 32 as that is the tilesize the library uses)
![](@ref Tiled1.jpg){html: width=50%}
![](@ref Tiled2.jpg){html: width=50%}
### Create a New Tileset ### Create a New Tileset
1. In the editor, go to the lower-right corner and select "New Tileset".
In the editor, go to the lower-right corner and select "New Tileset". 2. Give your tileset a name.
3. Make sure to select "Embed in map".
Give your tileset a name. 4. Choose your tilesheet as the source.
5. Leave the rest of the settings on default
Make sure to select "Embed in map". ![](@ref Tiled3.jpg){html: width=50%}
![](@ref Tiled4.jpg){html: width=50%}
Choose your tilesheet as the source.
### Draw Your Environment ### Draw Your Environment
Once imported, you can select tiles from the tileset and use them to build your environment.
Once imported, you can select tiles from the tileset and use them to build your environment.
### Understand Layers in Tiled ### Understand Layers in Tiled
Tiled allows you to use multiple layers for organizing your map. Tiled allows you to use multiple layers for organizing your map.
You need to give your Layers seperate z-Indices to decide their rendering order, the lower the number the earlier it gets rendered. You need to give your Layers seperate z-Indices to decide their rendering order, the lower the number the earlier it gets rendered.
In order to do this:
1. Select a layer.
1. Right-click "Custom Properties" and go to "Add Property".
1. Add a new int property named "zIndex" and give it a number starting with 0 to decide when to render it (the lower the number the more the layer is in the background i.e. tiles on layer 0 will be covered by tiles on layer 1 if they occupy the same space).
In order to do this select a layer. ![](@ref Tiled5.jpg){html: width=50%}
Add a new int property named "zIndex" and give it a number starting with 0 to decide when to render it (0 gets rendered first etc.). **Important: Tiles that should have collision must be placed on a separate layer as custom properties are per layer not per tile.**
Important: Tiles that should have collision must be placed on a separate layer.
### Set Up Collision ### Set Up Collision
To add collision to a layer:
Select the layer you want to have collision. 1. Select the layer you want to have collision.
1. Right-click and go to "Custom Properties".
1. Add a new boolean property named "collision" and tick the checkbox.
Right-click and go to "Custom Properties". ![](@ref Tiled5.jpg){html: width=50%}
Add a new boolean property named "collision" and tick the checkbox. Any tile placed on this layer will now automatically have collision—meaning moving entities cannot pass through them.
Any tile placed on this layer will now automatically have collision—meaning moving entities cannot pass through them. ### Saving your work
After completeing your map, save it in the asset folder of the library (or any place really the asset folder just exists as a recommendation to easily find all of your maps and textures)
![](@ref Tiled6.jpg){html: width=50%}
### Loading your work into the game
The map gets loaded into the game in `GameImplementation.cpp`, simply add the path of the map .tmx file to the [Map](@ref Map) constructor

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
//! \brief Animation struct to hold animation data
//! \param index The row in the sprite sheet (every 32 pixels on the y-axis is a new row)
//! \param frames The number of frames in the animation
//! \param speed The speed of the animation in milliseconds
struct Animation struct Animation
{ {
uint8_t index; uint8_t index;

View File

@ -21,7 +21,7 @@ public:
//! \brief Constructor for ColliderComponent //! \brief Constructor for ColliderComponent
//! \param tag The tag of the collider, can be any char* //! \param tag The tag of the collider, can be any char*
//! \param hitboxScale The scale of the collider, used to scale the collider size, default is 1.0f and takes up the 32x32 pixels //! \param hitboxScale The scale of the collider, used to scale the collider size (this is independent of the sprite size), default is 1.0f and takes up the 32x32 pixels
ColliderComponent(const char* tag, float hitboxScale); ColliderComponent(const char* tag, float hitboxScale);
void init() override; void init() override;

View File

@ -6,6 +6,7 @@
#include <optional> #include <optional>
#include "Component.h" #include "Component.h"
//! \brief DataComponent class to centrally store data about an entity such as stats
class DataComponent : public Component class DataComponent : public Component
{ {
public: public:
@ -13,7 +14,7 @@ public:
~DataComponent() {}; ~DataComponent() {};
/** /**
* @brief Set a key-value pair of any type in the data map * @brief Set a key-value pair of any type in the data map
* @details e.g. setEntry("speed", 180); in this case the key is "speed" and the value is set to an integer of 180 * @details e.g. \code{.cpp}setEntry("speed", 180);\endcode in this case the key is "speed" and the value is set to an integer of 180
* @param key The name to store the value under * @param key The name to store the value under
* @param value The value to store of type T * @param value The value to store of type T
*/ */
@ -22,7 +23,7 @@ public:
/** /**
* @brief Get a value of type T from the data map * @brief Get a value of type T from the data map
* @details e.g. getEntry<int>("speed"); in this case the key is "speed" and the value is returned as an integer * @details e.g. \code{.cpp}getEntry<int>("speed");\endcode in this case the key is "speed" and the value is returned as an integer
* @param key The name to retrieve the value from * @param key The name to retrieve the value from
* @return An optional of type T containing the value if it exists and matches in typeid, otherwise std::nullopt * @return An optional of type T containing the value if it exists and matches in typeid, otherwise std::nullopt
*/ */

View File

@ -11,6 +11,8 @@
class Vector2D; class Vector2D;
class Manager; class Manager;
//! \brief PickupManager class to handle the creation and management of pickups in the game
class PickupManager class PickupManager
{ {
public: public:
@ -18,7 +20,12 @@ public:
PickupManager(Manager* manager); PickupManager(Manager* manager);
~PickupManager(); ~PickupManager();
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, Textures texture); //! \brief Creates a pickupable item and adds it to the manager
//! \param pos The position of the pickupable item
//! \param pickupFunc The function to be called when the pickupable item is picked up
//! \param texture The texture of the pickupable item
//! \details This function creates a pickupable item entity and adds it to the manager. The pickupable item is created with a transform component, a sprite component, a collider component and a pickup component. The pickup function is called when the powerup is picked up by an entity.
void createPickupable(Vector2D pos, std::function<void (Entity*)> pickupFunc, Textures texture);
Vector2D calculateSpawnPosition(); Vector2D calculateSpawnPosition();

View File

@ -12,8 +12,8 @@
#include "RenderObject.h" #include "RenderObject.h"
class TransformComponent; class TransformComponent;
//! \brief SpriteComponent class to handle sprite rendering and animation
//! \brief SpriteComponent class to handle sprite rendering and animation of entities
class SpriteComponent : public Component, public RenderObject class SpriteComponent : public Component, public RenderObject
{ {
public: public:
@ -48,31 +48,50 @@ public:
//! \brief Constructor for SpriteComponent //! \brief Constructor for SpriteComponent
//! \param texture The texture to be used for the sprite, must be a Texture enum //! \param texture The texture to be used for the sprite, must be a Texture enum
//! \brief zIndex The 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 //! \param zIndex The 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(Textures texture, int zIndex); SpriteComponent(Textures texture, int zIndex);
//! \param texture The texture to be used for the sprite, must be a Texture enum //! \param texture The texture to be used for the sprite, must be a Texture enum
//! \param xOffset The x offset of the sprite, used for rendering position //! \param xOffset The x offset of the sprite relative to the transform component position, used for rendering position
//! \param yOffset The y offset of the sprite, used for rendering position //! \param yOffset The y offset of the sprite relative to the transform component position, used for rendering position
//! \brief zIndex The 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(Textures texture, int xOffset, int yOffset, int zIndex);
//! \param texture The texture to be used for the sprite, must be a char* path
//! \param xOffset The x offset of the sprite, used for rendering position
//! \param yOffset The y offset of the sprite, used for rendering position
//! \brief zIndex The 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(const char* path, int xOffset, int yOffset, int zIndex);
//! \brief used for animated sprites
//! \param texture The texture to be used for the sprite, must be a Texture enum
//! \param isAnimated Whether the sprite is animated or not
//! \param animationList The list of animations to be used for the sprite
//! \param defaultAnimation The default animation to be used for the sprite when it first gets loaded
//! \param zIndex The 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 //! \param zIndex The 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(Textures texture, int xOffset, int yOffset, int zIndex);
//! \param path The path to the texture to be used for the entity (for performance reasons, prefer enums instead)
//! \param xOffset The x offset of the sprite relative to the transform component position, used for rendering position
//! \param yOffset The y offset of the sprite relative to the transform component position, used for rendering position
//! \param zIndex The 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(const char* path, int xOffset, int yOffset, int zIndex);
/**
* \brief Constructor used for **animated** sprites
* \param texture The texture to be used for the sprite, must be a Texture enum
* \param isAnimated Whether the sprite is animated or not
* \param animationList The list of animations to be used for the sprite (list of maps mapping a string to an \ref Animation struct)
* \param defaultAnimation The default animation to be used for the sprite when it first gets loaded
* \param zIndex The 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
* \param xOffset The x offset of the sprite relative to the transform component position, used for rendering position
* \param yOffset The y offset of the sprite relative to the transform component position, used for rendering position
* ### How to spritesheet animation:
*
* An animation sprite sheet consists of multiple sprites of the specified size (library supports 32x32) arranged in a grid.
* Each row of the grid represents one animation, and each column in a row is one frame of the animation.
* If a sprite sheet contains multiple animations with different frame counts,
* you can just leave the rest of the row blank.
* Be aware to specify the correct frame count in the animation struct!
* \sa Animation
*
* \image html Animations1.jpg "Example of a sprite sheet with 2 animations of 2 frames each"
*/
SpriteComponent( SpriteComponent(
Textures texture, Textures texture,
bool isAnimated, bool isAnimated,
std::map<std::string, std::unique_ptr<Animation>>* animationList, std::map<std::string, std::unique_ptr<Animation>>* animationList,
std::string defaultAnimation, std::string defaultAnimation,
int zIndex); int zIndex,
int xOffset = 0,
int yOffset = 0);
~SpriteComponent(); ~SpriteComponent();
void setTexture(Textures texture); void setTexture(Textures texture);
@ -81,6 +100,9 @@ public:
void init() override; void init() override;
void update(uint_fast16_t diffTime) override; void update(uint_fast16_t diffTime) override;
void draw() override; void draw() override;
//! \brief By name select which animation should be played (gets looped)
//! \param type name previously set to an animation in animationList
void playAnimation(std::string type); void playAnimation(std::string type);
void setDirection(Direction direction); void setDirection(Direction direction);
}; };

View File

@ -14,6 +14,7 @@ struct StatEffect {
uint32_t startTime; uint32_t startTime;
}; };
//! \brief Manages the lifecycle of temporary effects
class StatEffectsComponent : public Component{ class StatEffectsComponent : public Component{
public: public:
StatEffectsComponent() {}; StatEffectsComponent() {};

View File

@ -5,8 +5,7 @@
#include "Constants.h" #include "Constants.h"
#include "DataComponent.h" #include "DataComponent.h"
//! \brief Adds a transform to an entity when added via entity.addComponent() //! \brief 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.
//! \details 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.
class TransformComponent : public Component class TransformComponent : public Component
{ {
public: public:
@ -15,12 +14,24 @@ public:
int height = 32; int height = 32;
int width = 32; int width = 32;
int scale = 1; float scale = 1;
//! \attention in order to allow an entity to move the stat "speed" must be set in the DataComponent (written exactly like that and set to any positive int value, 0 will lead to no movement, negative numbers to backwards movement) //! \attention in order to allow an entity to move the stat "speed" must be set in the DataComponent (written exactly like that and set to any positive int value, 0 will lead to no movement, negative numbers to backwards movement)
explicit TransformComponent(int scale = 1);
TransformComponent(float x, float y, int scale = 1); //! \param scale base value is 1 (32x32px), size gets multiplied with scale
TransformComponent(float x, float y, int w, int h, int scale = 1); explicit TransformComponent(float scale = 1);
//! \param x x coordinate of spawnposition
//! \param y y coordinate of spawnposition
//! \param scale base value is 1 (32x32px per default), size gets multiplied with scale
TransformComponent(float x, float y, float scale = 1);
//! \param x x coordinate of spawnposition
//! \param y y coordinate of spawnposition
//! \param w add custom width
//! \param h add custom height
//! \param scale base value is 1 (32x32px per default), size gets multiplied with scale
TransformComponent(float x, float y, int w, int h, float scale = 1);
void init() override; void init() override;
void update(uint_fast16_t diffTime) override; void update(uint_fast16_t diffTime) override;

View File

@ -4,6 +4,16 @@ namespace vego {
extern GameInternal* game; extern GameInternal* game;
} }
/**
* \brief gives access to internal resources such as managers and handlers
* \details gives access to the following useful managers and handlers
* - this is a list
* - using markdown
* - since markdown is supported :)
*
* 1. also numbered
* 2. lists works
*/
inline GameInternal& VEGO_Game() { inline GameInternal& VEGO_Game() {
return *vego::game; return *vego::game;
}; };

View File

@ -22,7 +22,7 @@ PickupManager::PickupManager(Manager* manager) : man(manager) {}
PickupManager::~PickupManager() {} PickupManager::~PickupManager() {}
void PickupManager::createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, Textures texture) { void PickupManager::createPickupable(Vector2D pos, std::function<void (Entity*)> pickupFunc, Textures texture) {
auto& powerups(man->addEntity()); auto& powerups(man->addEntity());
powerups.addComponent<TransformComponent>(pos.x, pos.y, 32, 32, 1); //32x32 is standard size for objects powerups.addComponent<TransformComponent>(pos.x, pos.y, 32, 32, 1); //32x32 is standard size for objects

View File

@ -37,7 +37,9 @@ SpriteComponent::SpriteComponent(
bool isAnimated, bool isAnimated,
std::map<std::string, std::unique_ptr<Animation>>* animationMap, std::map<std::string, std::unique_ptr<Animation>>* animationMap,
std::string defaultAnimation, std::string defaultAnimation,
int zIndex) : RenderObject(zIndex, VEGO_Game().renderManager), textureXOffset(0), textureYOffset(0) int zIndex,
int xOffset,
int yOffset) : RenderObject(zIndex, VEGO_Game().renderManager), textureXOffset(xOffset), textureYOffset(yOffset)
{ {
animated = isAnimated; animated = isAnimated;

View File

@ -13,20 +13,20 @@
#include "SoundManager.h" #include "SoundManager.h"
TransformComponent::TransformComponent(int scale) TransformComponent::TransformComponent(float scale)
{ {
position.zero(); position.zero();
this->scale = scale; this->scale = scale;
} }
TransformComponent::TransformComponent(float x, float y, int scale) TransformComponent::TransformComponent(float x, float y, float scale)
{ {
this->position.x = x; this->position.x = x;
this->position.y = y; this->position.y = y;
this->scale = scale; this->scale = scale;
} }
TransformComponent::TransformComponent(float x, float y, int w, int h, int scale) TransformComponent::TransformComponent(float x, float y, int w, int h, float scale)
{ {
this->position.x = x; this->position.x = x;
this->position.y = y; this->position.y = y;