mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 15:53:42 +00:00
Compare commits
2 Commits
a583e2d2f1
...
2d19ffb512
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d19ffb512 | ||
|
|
4ead20ecb7 |
@ -5,7 +5,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "TextureEnumBase.h"
|
||||
#include "Textures.h"
|
||||
#include "AnimationHandler.h"
|
||||
#include "Component.h"
|
||||
#include "Direction.h"
|
||||
@ -35,8 +35,9 @@ private:
|
||||
int textureXOffset;
|
||||
int textureYOffset;
|
||||
|
||||
//should be changed in the future as this is only for the tiles
|
||||
const char* path;
|
||||
//might be a better solution as this variable is only used for the loading of the tmx map
|
||||
//TODO: improve this in the future
|
||||
const char* path; //empty string if texture has a texture enum value, otherwise the path of the texture
|
||||
|
||||
public:
|
||||
SpriteComponent(Textures texture, int zIndex);
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
/*!
|
||||
* \file Textures.h
|
||||
* \brief Forward declaration of the \c Textures enum class.
|
||||
*
|
||||
* This file contains a forward declaration of the \c Textures enum class, which is used as a base
|
||||
* class for texture identifiers in the engine. It allows developers to define their own set of texture
|
||||
* types in their own implementation, providing flexibility in texture management within the engine.
|
||||
*
|
||||
* \details
|
||||
* The \c Textures enum class is intended to be implemented by the developer within their own scope.
|
||||
* This allows for customized texture entries to be defined based on the specific needs of the project.
|
||||
* The base declaration ensures that the enum class can be referenced and used consistently throughout
|
||||
* the engine while leaving the details of the texture identifiers up to the implementation.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
enum class Textures;
|
||||
@ -6,7 +6,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "TextureEnumBase.h"
|
||||
#include "Textures.h"
|
||||
|
||||
/*!
|
||||
* \class TextureManager
|
||||
@ -16,12 +16,8 @@
|
||||
* and rendering in the engine. It provides functions to add, load, and draw textures
|
||||
* from files, as well as manage sprite sheets.
|
||||
*
|
||||
* It uses two caches: one for regular textures (`texture_cache`) and one for
|
||||
* map tile textures (`mapTile_texture_cache`). This allows for efficient texture reuse
|
||||
* and management across different parts of the game.
|
||||
*
|
||||
* \note Textures are identified by an enum class `Textures` which is user-defined.
|
||||
* Developers are expected to define the texture types in their own implementation.
|
||||
* \sa \ref Textures "Textures" are used to identify textures within the engine.
|
||||
* It is expected that they are implemented within the games scope.
|
||||
*/
|
||||
|
||||
class TextureManager
|
||||
@ -43,7 +39,7 @@ class TextureManager
|
||||
* \param filePath The file path to the texture file.
|
||||
*
|
||||
* This function loads the texture from the specified file and stores it in
|
||||
* the `texture_cache`. If loading the texture fails, an exception is thrown.
|
||||
* a cache. If loading the texture fails, an exception is thrown.
|
||||
*/
|
||||
void addSingleTexture(Textures texture, const char* filePath);
|
||||
|
||||
@ -52,8 +48,8 @@ class TextureManager
|
||||
* \param textures A map of texture identifiers and corresponding file paths.
|
||||
*
|
||||
* This function iterates over the provided map of textures and loads each
|
||||
* texture using `addSingleTexture`. It allows developers to add several
|
||||
* textures at once.
|
||||
* texture using `addSingleTexture`. It allows for several
|
||||
* textures to be added at once.
|
||||
*/
|
||||
void addTextures(const std::map<Textures, const char*>& textures);
|
||||
|
||||
@ -62,7 +58,7 @@ class TextureManager
|
||||
* \param texture The texture identifier.
|
||||
* \return A pointer to the `SDL_Texture` if found, or `nullptr` if not found.
|
||||
*
|
||||
* This function looks up a texture in the `texture_cache` and returns the
|
||||
* This function looks up a texture within the cache and returns the
|
||||
* corresponding `SDL_Texture*`. If the texture is not found, it logs an error
|
||||
* message and returns `nullptr`.
|
||||
*/
|
||||
@ -73,7 +69,7 @@ class TextureManager
|
||||
/*!
|
||||
* \brief Loads a map tile texture from the file system and caches it.
|
||||
* \param path The file path to the texture.
|
||||
* \return A pointer to the `SDL_Texture` representing the map tile.
|
||||
* \return `SDL_Texture*` representing the map tile.
|
||||
*
|
||||
* This function checks if the map tile texture is already cached. If not, it
|
||||
* loads the texture from the file system and stores it in the cache.
|
||||
|
||||
14
include/Textures.h
Normal file
14
include/Textures.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
* \class Textures
|
||||
* \brief Forward declaration of the \c Textures enum class.
|
||||
*
|
||||
* The \c Textures enum class is intended to be implemented within the game scope.
|
||||
* This allows for customized texture entries to be defined based on the specific needs of the project.
|
||||
* The base declaration ensures that the enum class can be referenced and used consistently throughout
|
||||
* the engine while leaving the details of the texture identifiers up to the implementation.
|
||||
* \sa \ref TextureManager "TextureManager" for how the enum is used.
|
||||
*/
|
||||
|
||||
enum class Textures;
|
||||
@ -6,7 +6,7 @@
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
|
||||
#include "Component.h"
|
||||
#include "TextureEnumBase.h"
|
||||
#include "Textures.h"
|
||||
|
||||
class SpriteComponent;
|
||||
class TransformComponent;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include "PowerupComponent.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "TextureEnumBase.h"
|
||||
#include "Textures.h"
|
||||
|
||||
AssetManager::AssetManager(Manager* manager) : man(manager) {}
|
||||
|
||||
|
||||
@ -5,9 +5,7 @@
|
||||
#include "Entity.h"
|
||||
#include "TransformComponent.h"
|
||||
#include "SpriteComponent.h"
|
||||
#include "TileComponent.h"
|
||||
|
||||
#include "TextureEnumBase.h"
|
||||
|
||||
TileComponent::TileComponent(int x, int y, int w, int h, int id, const std::map<int, std::pair<Textures, bool>>* textureDict)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user