diff --git a/assets/walls/portal1.png b/assets/walls/portal1.png new file mode 100644 index 00000000..d7d1f637 Binary files /dev/null and b/assets/walls/portal1.png differ diff --git a/assets/walls/portal2.png b/assets/walls/portal2.png new file mode 100644 index 00000000..9bec4929 Binary files /dev/null and b/assets/walls/portal2.png differ diff --git a/assets/walls/portal3,png.png b/assets/walls/portal3,png.png new file mode 100644 index 00000000..13f64363 Binary files /dev/null and b/assets/walls/portal3,png.png differ diff --git a/assets/walls/portal4.png b/assets/walls/portal4.png new file mode 100644 index 00000000..63920943 Binary files /dev/null and b/assets/walls/portal4.png differ diff --git a/assets/walls/teleport.png b/assets/walls/teleport.png new file mode 100644 index 00000000..28292024 Binary files /dev/null and b/assets/walls/teleport.png differ diff --git a/assets/weapons/10.png b/assets/weapons/10.png new file mode 100644 index 00000000..ee30a145 Binary files /dev/null and b/assets/weapons/10.png differ diff --git a/assets/weapons/15.png b/assets/weapons/15.png new file mode 100644 index 00000000..5ef81bde Binary files /dev/null and b/assets/weapons/15.png differ diff --git a/assets/weapons/2.png b/assets/weapons/2.png new file mode 100644 index 00000000..d764f765 Binary files /dev/null and b/assets/weapons/2.png differ diff --git a/assets/weapons/6.png b/assets/weapons/6.png new file mode 100644 index 00000000..4c6e464d Binary files /dev/null and b/assets/weapons/6.png differ diff --git a/assets/weapons/8.png b/assets/weapons/8.png new file mode 100644 index 00000000..c5f0c5aa Binary files /dev/null and b/assets/weapons/8.png differ diff --git a/source/Interfaces/Button.cpp b/source/Interfaces/Button.cpp index e50593c9..e1c480bf 100644 --- a/source/Interfaces/Button.cpp +++ b/source/Interfaces/Button.cpp @@ -31,7 +31,6 @@ void i_2D::Button::setMFont(const sf::Font &font) { */ void i_2D::Button::setPosition(sf::Vector2f pos) { button.setPosition(pos); - float xPos = (pos.x + button.getGlobalBounds().width / 2) - (text->getLocalBounds().width/2); float yPos = (pos.y + button.getGlobalBounds().height / 2) - (text->getLocalBounds().height/2); text->setPosition({xPos, yPos}); @@ -51,10 +50,10 @@ bool i_2D::Button::isMouseOver(sf::RenderWindow &window) { float btnPosX = button.getPosition().x; float btnPosY = button.getPosition().y; - float btnxPosWidth = button.getPosition().x + button.getLocalBounds().width; - float btnyPosHeight = button.getPosition().y + button.getLocalBounds().height; + float btnXPosWidth = button.getPosition().x + button.getLocalBounds().width; + float btnYPosHeight = button.getPosition().y + button.getLocalBounds().height; - if(mouseX < btnxPosWidth && mouseX > btnPosX && mouseY < btnyPosHeight && mouseY > btnPosY){ + if(mouseX < btnXPosWidth && mouseX > btnPosX && mouseY < btnYPosHeight && mouseY > btnPosY){ return true; } return false; diff --git a/source/Interfaces/Component.hpp b/source/Interfaces/Component.hpp index b16c534b..670ee641 100644 --- a/source/Interfaces/Component.hpp +++ b/source/Interfaces/Component.hpp @@ -13,8 +13,7 @@ namespace i_2D { - class Component : public sf::Drawable - , public sf::Transformable + class Component : public sf::Drawable, public sf::Transformable { public: typedef std::shared_ptr Ptr; diff --git a/source/Interfaces/Group3_README.md b/source/Interfaces/Group3_README.md index 92207be1..8f1533ae 100644 --- a/source/Interfaces/Group3_README.md +++ b/source/Interfaces/Group3_README.md @@ -54,4 +54,44 @@ The function ensures that the user's interactions with the maze application are
Functionalities: ### Button Constructor +
+ + + + + + + + + + +# TextureHolder Class + + +## Description + +The `TextureHolder` class is responsible for creating and storing references to sf::Texture objects. It is given a file, generates an sf::Texture, and readily gives a reference to the generated texture when asked. +
Functionalities + +### LoadTexture Function + +The `LoadTexture` function is a part of the `TextureHolder` class and is responsible for generating sf::Textures from a given file path. + +The `LoadTexture` function consists of the following main functionalities: +- Attempt to generate sf::Texture using given file path +- Store the generated sf::Texture in a map using the id as a key + +The function allows new sf::Textures to be instantiated and stored to the class for future reference calling by id. + + +### GetTexture Function + +The `GetTexture` function is a part of the `TextureHolder` class and is responsible for getting a reference to the initialized sf::Texture with the matching id. + +The `GetTexture` function performs the following key tasks: +- Determine if there is a loaded texture with the given id +- Return the dereferenced sf::Texture that matches the id + +The function allows for easy reference to any of the loaded sf::Textures without having to instantiate new ones for each use. +
\ No newline at end of file diff --git a/source/Interfaces/Inventory.cpp b/source/Interfaces/Inventory.cpp index 134a992d..d67f4180 100644 --- a/source/Interfaces/Inventory.cpp +++ b/source/Interfaces/Inventory.cpp @@ -16,12 +16,16 @@ void i_2D::Inventory::ConstructInventory(sf::Font &font) { mInventoryWindow->setSize({mWorldSize.x,mWorldSize.y/2}); mInventoryWindow->setFillColor(sf::Color::Black); mInventoryWindow->setPosition(sf::Vector2f{0.f,50.f}); + + // Set row & col sizes if(mWorldSize.x > 1800){ mCol = 5; }else mCol = 3; if(mWorldSize.y > 900){ mRow = 4; }else mRow = 3; + + // Create 2d vector of buttons for(int i = 0; i < mRow; i++) { std::vector> v1; for (int j = 0; j < mCol; j++) { diff --git a/source/Interfaces/MainInterface.cpp b/source/Interfaces/MainInterface.cpp index a54c0338..ef15b8a5 100644 --- a/source/Interfaces/MainInterface.cpp +++ b/source/Interfaces/MainInterface.cpp @@ -8,6 +8,9 @@ namespace i_2D { + sf::Clock timer; + float elapsedTime = 0.0f; + /** * @brief Constructs a `MainInterface` object. * @@ -25,12 +28,7 @@ namespace i_2D { mTextBox = std::make_unique(mFont); auto a = mWindow.getSize().x; auto b = mWindow.getSize().y; - mMenu.initialize(mFont,sf::Vector2f {static_cast(a),static_cast(b)}); -// mTestButton = std::make_unique