diff --git a/.gitignore b/.gitignore
index 4ea2a783..8da23996 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,7 @@ build/*
docs/*
emsdk/
build_web/*
-wasm-python.py
\ No newline at end of file
+wasm-python.py
+lua54*
+include/*
+save/*
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bd8bd46..989feb86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -122,10 +122,18 @@ set(SOURCES
sources/System/Sound/PlayerSoundManagerSystem.hpp
sources/System/Music/MusicSystem.hpp
sources/System/Music/MusicSystem.cpp
+ sources/Parser/ParserYaml.hpp
+ sources/Parser/ParserYaml.cpp
+ sources/Exception/Error.hpp
+ sources/Exception/Error.cpp
sources/System/Lobby/LobbySystem.cpp
sources/System/Lobby/LobbySystem.hpp
sources/Component/Lobby/LobbyComponent.cpp
sources/Component/Lobby/LobbyComponent.hpp
+ sources/System/Lobby/ResumeLobbySystem.cpp
+ sources/System/Lobby/ResumeLobbySystem.hpp
+ sources/Component/Lobby/ResumeLobbyComponent.cpp
+ sources/Component/Lobby/ResumeLobbyComponent.hpp
sources/Component/Gravity/GravityComponent.hpp
sources/Component/Gravity/GravityComponent.cpp
sources/System/Gravity/GravitySystem.hpp
@@ -156,6 +164,12 @@ set(SOURCES
sources/System/EndCondition/EndConditionSystem.hpp
sources/System/EndCondition/EndConditionSystem.cpp
sources/Runner/LobbyScene.cpp
+ sources/Runner/ResumeLobbyScene.cpp
+ sources/Runner/ScoreScene.cpp
+ sources/Parser/Node.cpp
+ sources/Parser/Node.hpp
+ sources/Utils/Utils.cpp
+ sources/Utils/Utils.hpp
sources/Runner/HowToPlayScene.cpp
sources/Runner/ScoreScene.cpp
sources/System/Shaders/ShaderSystem.cpp
@@ -180,6 +194,8 @@ set(SOURCES
sources/Map/LuaMap.hpp
sources/Component/Shaders/Items/AlphaCtxShaderComponent.cpp
sources/Component/Shaders/Items/AlphaCtxShaderComponent.hpp
+ sources/Component/Speed/SpeedComponent.cpp
+ sources/Component/Speed/SpeedComponent.hpp
)
add_executable(bomberman
diff --git a/README.md b/README.md
index c2c1003e..ab5eee3d 100644
--- a/README.md
+++ b/README.md
@@ -8,14 +8,17 @@ A recreation of the classic Bomberman arcade game
Repository link: https://github.com/AnonymusRaccoon/Bomberman/
-## Demo
-
-Very soon :)
+## Demo (Click to See on YouTube)
+[](http://www.youtube.com/watch?v=5tkaYtMpdKY "Indie Studio - Bomberman")
## Screenshots
-Very soon :)
+
## Run (compile from the sources)
@@ -56,14 +59,7 @@ Enjoy !
## Tech Stack
-**Bomberman:** C++20, raylib, Catch2, CMake, Doxygen
-## Contributing
-
-Contributions are always welcome!
-
-See `contributing.md` for ways to get started.
-
-Please adhere to this project's `code of conduct`.
+**Bomberman:** C++20, raylib, Catch2, CMake, Doxygen, Lua
## Authors
diff --git a/assets/ai_scripts/john.lua b/assets/ai_scripts/john.lua
index f63076a5..b4b9116c 100644
--- a/assets/ai_scripts/john.lua
+++ b/assets/ai_scripts/john.lua
@@ -9,7 +9,7 @@ mapinfo.dist { }
------------
------ Debug variables
-local debug = true
+local debug = false
if not debug then
log = function() end
diff --git a/assets/buttons/button_resume_game.png b/assets/buttons/button_resume_game.png
new file mode 100644
index 00000000..20cec8d2
Binary files /dev/null and b/assets/buttons/button_resume_game.png differ
diff --git a/assets/buttons/button_resume_game_hovered.png b/assets/buttons/button_resume_game_hovered.png
new file mode 100644
index 00000000..42719815
Binary files /dev/null and b/assets/buttons/button_resume_game_hovered.png differ
diff --git a/assets/buttons/button_save.png b/assets/buttons/button_save.png
new file mode 100644
index 00000000..0372a9b3
Binary files /dev/null and b/assets/buttons/button_save.png differ
diff --git a/assets/buttons/button_save_hovered.png b/assets/buttons/button_save_hovered.png
new file mode 100644
index 00000000..d66bc224
Binary files /dev/null and b/assets/buttons/button_save_hovered.png differ
diff --git a/assets/images/game.png b/assets/images/game.png
new file mode 100644
index 00000000..acbb2838
Binary files /dev/null and b/assets/images/game.png differ
diff --git a/assets/images/lobby.png b/assets/images/lobby.png
new file mode 100644
index 00000000..508bb087
Binary files /dev/null and b/assets/images/lobby.png differ
diff --git a/assets/images/titlescreen.png b/assets/images/titlescreen.png
new file mode 100644
index 00000000..68ec8902
Binary files /dev/null and b/assets/images/titlescreen.png differ
diff --git a/images/game.png b/images/game.png
new file mode 100644
index 00000000..acbb2838
Binary files /dev/null and b/images/game.png differ
diff --git a/images/lobby.png b/images/lobby.png
new file mode 100644
index 00000000..508bb087
Binary files /dev/null and b/images/lobby.png differ
diff --git a/images/titlescreen.png b/images/titlescreen.png
new file mode 100644
index 00000000..68ec8902
Binary files /dev/null and b/images/titlescreen.png differ
diff --git a/lib/Ray/sources/Vector/Vector3.cpp b/lib/Ray/sources/Vector/Vector3.cpp
index 8bf172c3..ca9ba556 100644
--- a/lib/Ray/sources/Vector/Vector3.cpp
+++ b/lib/Ray/sources/Vector/Vector3.cpp
@@ -31,4 +31,4 @@ RAY::Vector3::operator ::Vector3() const
v.y = this->y;
v.z = this->z;
return v;
-}
\ No newline at end of file
+}
diff --git a/lib/wal/sources/Entity/Entity.cpp b/lib/wal/sources/Entity/Entity.cpp
index c3f7196a..7bb19bf4 100644
--- a/lib/wal/sources/Entity/Entity.cpp
+++ b/lib/wal/sources/Entity/Entity.cpp
@@ -39,6 +39,11 @@ namespace WAL
return this->_name;
}
+ void Entity::setName(std::string &name)
+ {
+ this->_name = name;
+ }
+
bool Entity::isDisable() const
{
return this->_disabled;
diff --git a/lib/wal/sources/Entity/Entity.hpp b/lib/wal/sources/Entity/Entity.hpp
index 9d8b2d13..5bfc83f8 100644
--- a/lib/wal/sources/Entity/Entity.hpp
+++ b/lib/wal/sources/Entity/Entity.hpp
@@ -51,8 +51,10 @@ namespace WAL
Scene &_scene;
//! @brief Get the ID of the entity.
unsigned getUid() const;
- //! @brief Get the name fo the entity
+ //! @brief Get the name of the entity
std::string getName() const;
+ //!@brief Set the name of the entity
+ void setName(std::string &name);
//! @brief Used if the entity is disabled
bool isDisable() const;
diff --git a/sources/Component/BombHolder/BombHolderComponent.cpp b/sources/Component/BombHolder/BombHolderComponent.cpp
index 13480cda..157f6946 100644
--- a/sources/Component/BombHolder/BombHolderComponent.cpp
+++ b/sources/Component/BombHolder/BombHolderComponent.cpp
@@ -12,9 +12,10 @@ namespace BBM
: WAL::Component(entity)
{}
- BombHolderComponent::BombHolderComponent(WAL::Entity &entity, unsigned int maxCount)
+ BombHolderComponent::BombHolderComponent(WAL::Entity &entity, unsigned int maxCount, unsigned int bombExplosionRadius)
: WAL::Component(entity),
- maxBombCount(maxCount)
+ maxBombCount(maxCount),
+ explosionRadius(bombExplosionRadius)
{}
WAL::Component *BombHolderComponent::clone(WAL::Entity &entity) const
diff --git a/sources/Component/BombHolder/BombHolderComponent.hpp b/sources/Component/BombHolder/BombHolderComponent.hpp
index 43242338..e85e812f 100644
--- a/sources/Component/BombHolder/BombHolderComponent.hpp
+++ b/sources/Component/BombHolder/BombHolderComponent.hpp
@@ -26,7 +26,7 @@ namespace BBM
//! @brief The number of nanosecond before the next bomb refill.
std::chrono::nanoseconds nextBombRefill = refillRate;
//! @brief The radius of the explosion.
- float explosionRadius = 3;
+ unsigned int explosionRadius = 3;
//! @brief The damage made by the explosion on an entity
int damage = 1;
@@ -37,7 +37,7 @@ namespace BBM
explicit BombHolderComponent(WAL::Entity &entity);
//! @brief Constructor
- BombHolderComponent(WAL::Entity &entity, unsigned int maxBombCount);
+ BombHolderComponent(WAL::Entity &entity, unsigned int maxBombCount, unsigned int bombExplosionRadius = 3);
//! @brief A component can't be instantiated, it should be derived.
BombHolderComponent(const BombHolderComponent &) = default;
diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp
index 66904b20..a545751f 100644
--- a/sources/Component/Controllable/ControllableComponent.hpp
+++ b/sources/Component/Controllable/ControllableComponent.hpp
@@ -40,8 +40,6 @@ namespace BBM
bool bomb = false;
//! @brief input value for pause
bool pause = false;
- //! @brief The speed applied to every controllable entities.
- float speed = .15f;
//! @brief The layout used for this controllable.
Layout layout = NONE;
//! @brief True if buttons should be triggered every frame where the key is down, false if the button should only be triggered once the key is released.
diff --git a/sources/Component/Lobby/ResumeLobbyComponent.cpp b/sources/Component/Lobby/ResumeLobbyComponent.cpp
new file mode 100644
index 00000000..6cc0440b
--- /dev/null
+++ b/sources/Component/Lobby/ResumeLobbyComponent.cpp
@@ -0,0 +1,21 @@
+//
+// Created by hbenjamin on 6/18/21.
+//
+
+#include "ResumeLobbyComponent.hpp"
+
+namespace BBM
+{
+ ResumeLobbyComponent::ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int pColor)
+ : WAL::Component(entity),
+ playerID(playerNumber),
+ playerColor(pColor),
+ readyButton(button),
+ coloredTile(tile)
+ {}
+
+ WAL::Component *ResumeLobbyComponent::clone(WAL::Entity &entity) const
+ {
+ return new ResumeLobbyComponent(entity, this->playerID, this->readyButton, this->coloredTile, this->playerColor);
+ }
+}
\ No newline at end of file
diff --git a/sources/Component/Lobby/ResumeLobbyComponent.hpp b/sources/Component/Lobby/ResumeLobbyComponent.hpp
new file mode 100644
index 00000000..8656a472
--- /dev/null
+++ b/sources/Component/Lobby/ResumeLobbyComponent.hpp
@@ -0,0 +1,44 @@
+//
+// Created by hbenjamin on 6/18/21.
+//
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+namespace BBM
+{
+ class ResumeLobbyComponent : public WAL::Component
+ {
+ public:
+ //! @brief The layout used for this player.
+ ControllableComponent::Layout layout = ControllableComponent::NONE;
+ //! @brief The ID of the lobby player (from 0 to 3)
+ int playerID;
+ //! @brief The color of the player (as an index)
+ int playerColor;
+ //! @brief Is this player ready
+ bool ready = false;
+ //! @brief The entity containing the ready display.
+ WAL::Entity &readyButton;
+ //! @brief The colored rectangle behind the player.
+ WAL::Entity &coloredTile;
+ //! @brief The time of last input that this lobby player has made.
+ std::chrono::time_point lastInput;
+
+ Component *clone(WAL::Entity &entity) const override;
+
+ //! @brief Create a new lobby component.
+ explicit ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int pColor);
+ //! @brief A lobby component is copyable.
+ ResumeLobbyComponent(const ResumeLobbyComponent &) = default;
+ //! @brief A default destructor
+ ~ResumeLobbyComponent() override = default;
+ //! @brief A lobby component is not assignable.
+ ResumeLobbyComponent &operator=(const ResumeLobbyComponent &) = delete;
+ };
+}
diff --git a/sources/Component/Speed/SpeedComponent.cpp b/sources/Component/Speed/SpeedComponent.cpp
new file mode 100644
index 00000000..2472d8c4
--- /dev/null
+++ b/sources/Component/Speed/SpeedComponent.cpp
@@ -0,0 +1,24 @@
+//
+// Created by cbihan on 18/06/2021.
+//
+
+#include "SpeedComponent.hpp"
+
+namespace BBM
+{
+ SpeedComponent::SpeedComponent(WAL::Entity &entity) :
+ WAL::Component(entity)
+ {
+ }
+
+ WAL::Component *SpeedComponent::clone(WAL::Entity &entity) const
+ {
+ return new SpeedComponent(this->_entity, this->speed);
+ }
+
+ SpeedComponent::SpeedComponent(WAL::Entity &entity, float entitySpeed) :
+ WAL::Component(entity),
+ speed(entitySpeed)
+ {
+ }
+}
\ No newline at end of file
diff --git a/sources/Component/Speed/SpeedComponent.hpp b/sources/Component/Speed/SpeedComponent.hpp
new file mode 100644
index 00000000..ced8ab3f
--- /dev/null
+++ b/sources/Component/Speed/SpeedComponent.hpp
@@ -0,0 +1,34 @@
+//
+// Created by cbihan on 18/06/2021.
+//
+
+#pragma once
+
+#include
+
+namespace BBM
+{
+ class SpeedComponent : public WAL::Component
+ {
+ public:
+ //! @brief entity speed
+ float speed = .15f;
+
+ //! @inherit
+ WAL::Component *clone(WAL::Entity &entity) const override;
+
+ //! @brief Initialize a new controllable component.
+ explicit SpeedComponent(WAL::Entity &entity);
+
+ //! @brief Initialize a new controllable component.
+ explicit SpeedComponent(WAL::Entity &entity, float entitySpeed);
+ //! @brief A Controllable component is copy constructable.
+ SpeedComponent(const SpeedComponent &) = default;
+ //! @brief default destructor
+ ~SpeedComponent() override = default;
+ //! @brief A Controllable component can't be assigned
+ SpeedComponent &operator=(const SpeedComponent &) = delete;
+ };
+
+
+}
\ No newline at end of file
diff --git a/sources/Component/Tag/TagComponent.hpp b/sources/Component/Tag/TagComponent.hpp
index d84a9708..5bcd837f 100644
--- a/sources/Component/Tag/TagComponent.hpp
+++ b/sources/Component/Tag/TagComponent.hpp
@@ -61,4 +61,5 @@ namespace BBM
constexpr const char Bumper[] = "Bumper";
// interact with bombs (getting damage etc) but doesn't stop explosion
constexpr const char BlowablePass[] = "BlowablePass";
+ constexpr const char Timer[] = "Timer";
}
diff --git a/sources/Exception/Error.cpp b/sources/Exception/Error.cpp
new file mode 100644
index 00000000..ed1d660c
--- /dev/null
+++ b/sources/Exception/Error.cpp
@@ -0,0 +1,16 @@
+//
+// Created by hbenjamin on 11/06/2021.
+//
+
+#include "Error.hpp"
+
+namespace BBM
+{
+ Error::Error(const std::string &what)
+ : std::runtime_error(what)
+ {}
+
+ ParserError::ParserError(const std::string &what)
+ : Error(what)
+ {}
+} // namespace BBM
\ No newline at end of file
diff --git a/sources/Exception/Error.hpp b/sources/Exception/Error.hpp
new file mode 100644
index 00000000..15f8a7d1
--- /dev/null
+++ b/sources/Exception/Error.hpp
@@ -0,0 +1,37 @@
+//
+// Created by hbenjamin on 11/06/2021.
+//
+
+#pragma once
+
+#include
+#include
+#include
+
+namespace BBM {
+ class Error : public std::runtime_error
+ {
+ public:
+ //! @brief Create a new exception
+ explicit Error(const std::string &what);
+ //! @brief An exception is copy constructable
+ Error(const Error &) = default;
+ //! @brief A default destructor
+ ~Error() override = default;
+ //! @brief A default assignment operator
+ Error &operator=(const Error &) = default;
+ };
+
+ class ParserError : public Error
+ {
+ public:
+ //! @brief Create a new parser exception
+ explicit ParserError(const std::string &what);
+ //! @brief A parser exception is copy constructable
+ ParserError(const ParserError &) = default;
+ //! @brief A default destructor
+ ~ParserError() override = default;
+ //! @brief A default assignment operator
+ ParserError &operator=(const ParserError &) = default;
+ };
+}
diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp
index 66675585..60911acb 100644
--- a/sources/Items/Bonus.cpp
+++ b/sources/Items/Bonus.cpp
@@ -5,6 +5,7 @@
#include
#include
#include
+#include "Component/Speed/SpeedComponent.hpp"
#include
#include "Component/Movable/MovableComponent.hpp"
#include "Bonus.hpp"
@@ -40,13 +41,13 @@ namespace BBM {
{
if (bonus.shouldDelete() || axis != CollisionComponent::CollidedAxis::ALL)
return;
- auto *controllable = player.tryGetComponent();
+ auto *speed = player.tryGetComponent();
auto *playerBonus = player.tryGetComponent();
- if (!controllable || !playerBonus)
+ if (!speed || !playerBonus)
return;
- if (controllable->speed >= 0.4)
+ if (speed->speed >= 0.4)
return;
- controllable->speed += 0.025f;
+ speed->speed += 0.025f;
const_cast(bonus).scheduleDeletion();
}
diff --git a/sources/Items/Bonus.hpp b/sources/Items/Bonus.hpp
index 2284b63f..02da9bf2 100644
--- a/sources/Items/Bonus.hpp
+++ b/sources/Items/Bonus.hpp
@@ -6,6 +6,7 @@
#pragma once
#include "Entity/Entity.hpp"
+#include "Component/Collision/CollisionComponent.hpp"
namespace BBM {
class Bonus {
@@ -15,11 +16,6 @@ namespace BBM {
//! @brief Apply bonus effect that allows players to carry one more bomb than before
static void BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis);
- //! @param bonus bonus
- //! @param player the entity on which the effect will be applied
- //! @brief Apply bonus effect who increased the bomb damage
- static void DamageIncreasedBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis);
-
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect that expend the explosion range of the bomb
diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp
index 9c464200..7197771c 100644
--- a/sources/Map/Map.cpp
+++ b/sources/Map/Map.cpp
@@ -19,6 +19,34 @@ using namespace std::chrono_literals;
namespace BBM
{
+ void MapGenerator::createBonus(WAL::Entity &entity, Vector3f position, Bonus::BonusType bonusType) {
+ static std::map> map = {
+ {Bonus::BonusType::BOMBSTOCK, {"Bonus Bomb Up", "assets/items/bombup"}},
+ {Bonus::BonusType::SPEEDUP, {"Bonus Speed Up", "assets/items/speedup"}},
+ {Bonus::BonusType::EXPLOSIONINC, {"Bonus Fire Up", "assets/items/fireup"}},
+ {Bonus::BonusType::NOCLIP, {"Bonus Wallpass", "assets/items/wallpass"}}
+ };
+ static std::vector> func = {
+ &Bonus::BombUpBonus, &Bonus::SpeedUpBonus, &Bonus::ExplosionRangeBonus, &Bonus::NoClipBonus
+ };
+
+ entity.addComponent(position)
+ .addComponent>()
+ .addComponent()
+ .addComponent(1, [](WAL::Entity &myEntity, WAL::Wal &wal) {
+ myEntity.scheduleDeletion();
+ })
+ .addComponent(position.y)
+ .addComponent([](WAL::Entity &bonus, const WAL::Entity &player, CollisionComponent::CollidedAxis axis) {
+ bonus.scheduleDeletion();
+ }, func[bonusType - 1], 0.5, .5)
+ .addComponent(5s, [](WAL::Entity &bonus, WAL::Wal &wal){
+ bonus.scheduleDeletion();
+ })
+ .addComponent(map.at(bonusType)[1] + ".obj", false,
+ std::make_pair(MAP_DIFFUSE, "assets/items/items.png"));
+ }
+
void MapGenerator::bumperCollide(WAL::Entity &entity,
const WAL::Entity &wall,
CollisionComponent::CollidedAxis collidedAxis)
@@ -84,14 +112,11 @@ namespace BBM
{
entity.scheduleDeletion();
auto &position = entity.getComponent().position;
- static std::map map = {
- {Bonus::BonusType::BOMBSTOCK, "assets/items/bombup"},
- {Bonus::BonusType::SPEEDUP, "assets/items/speedup"},
- {Bonus::BonusType::EXPLOSIONINC, "assets/items/fireup"},
- {Bonus::BonusType::NOCLIP, "assets/items/wallpass"}
- };
- static std::vector> func = {
- &Bonus::BombUpBonus, &Bonus::SpeedUpBonus, &Bonus::ExplosionRangeBonus, &Bonus::NoClipBonus
+ static std::map> map = {
+ {Bonus::BonusType::BOMBSTOCK, {"Bonus Bomb Up", "assets/items/bombup"}},
+ {Bonus::BonusType::SPEEDUP, {"Bonus Speed Up", "assets/items/speedup"}},
+ {Bonus::BonusType::EXPLOSIONINC, {"Bonus Fire Up", "assets/items/fireup"}},
+ {Bonus::BonusType::NOCLIP, {"Bonus Wallpass", "assets/items/wallpass"}}
};
auto bonusType = Bonus::getRandomBonusType();
@@ -99,21 +124,7 @@ namespace BBM
return;
if (!map.contains(bonusType))
return;
- wal.getScene()->scheduleNewEntity("Bonus")
- .addComponent(position)
- .addComponent>()
- .addComponent()
- .addComponent(1, [](WAL::Entity &myEntity, WAL::Wal &) {
- myEntity.scheduleDeletion();
- })
- .addComponent(position.y)
- .addComponent(WAL::Callback(),
- func[bonusType - 1], 0.5, .5)
- .addComponent(5s, [](WAL::Entity &bonus, WAL::Wal &){
- bonus.scheduleDeletion();
- })
- .addComponent(map.at(bonusType) + ".obj", false,
- std::make_pair(MAP_DIFFUSE, "assets/items/items.png"));
+ createBonus(wal.getScene()->scheduleNewEntity(map.at(bonusType)[0]), position, bonusType);
}
const std::string MapGenerator::assetsPath = "./assets/";
@@ -227,7 +238,6 @@ namespace BBM
{BREAKABLE, &createBreakable},
{UNBREAKABLE, &createUnbreakable},
{HOLE, &createHole},
- {FLOOR, &createFloor},
{BUMPER, &createBumper},
{UPPERFLOOR, &createUpperFloor},
};
@@ -254,16 +264,6 @@ namespace BBM
.addComponent(breakableObj, false, std::make_pair(MAP_DIFFUSE, breakablePng));
}
- void MapGenerator::createFloor(Vector3f coords, std::shared_ptr scene)
- {
- static const std::string floorObj = floorPath + objExtension;
- static const std::string floorPng = floorPath + imageExtension;
-
- scene->addEntity("Floor")
- .addComponent(Vector3f(coords))
- .addComponent(floorObj, false, std::make_pair(MAP_DIFFUSE, floorPng));
- }
-
void MapGenerator::createUpperFloor(Vector3f coords, std::shared_ptr scene)
{
static const std::string floorObj = secondFloorPath + objExtension;
@@ -508,7 +508,7 @@ namespace BBM
.addComponent(Vector3f(width / 2 - width / 4, 0, height / 2 - height / 4))
.addComponent(
WAL::Callback(),
- &MapGenerator::wallCollided, Vector3f(0.25, 0.25, 0.25),Vector3f(width / 2 + width / 4, 0.75, height / 2 + height / 4));
+ &MapGenerator::wallCollided, Vector3f(0.25, 0.25, 0.25),Vector3f(width / 2 + 0.75, 0.75, height / 2 + 0.75));
}
void MapGenerator::loadMap(int width, int height, MapBlock map, const std::shared_ptr &scene)
diff --git a/sources/Map/Map.hpp b/sources/Map/Map.hpp
index 0606cb54..3e8b60e4 100644
--- a/sources/Map/Map.hpp
+++ b/sources/Map/Map.hpp
@@ -22,7 +22,7 @@
#include "Component/Collision/CollisionComponent.hpp"
#include "Component/Movable/MovableComponent.hpp"
#include
-
+#include
namespace BBM
@@ -38,16 +38,54 @@ namespace BBM
BREAKABLE,
HOLE,
UPPERFLOOR,
- FLOOR,
BUMPER,
SPAWNER,
- UNBREAKABLE
+ UNBREAKABLE,
+ INVISIBLE
};
- private:
- using MapElem = std::function scene)>;
using MapBlock = std::map, BlockType>;
+ static void createBonus(WAL::Entity &entity, Vector3f position, Bonus::BonusType bonusType);
+
+ static void wallCollision(WAL::Entity &entity,
+ const WAL::Entity &wall,
+ CollisionComponent::CollidedAxis collidedAxis);
+ static void wallCollided(WAL::Entity &entity,
+ const WAL::Entity &wall,
+ CollisionComponent::CollidedAxis collidedAxis);
+ static void wallDestroyed(WAL::Entity &entity, WAL::Wal &wal);
+
+ static void holeCollide(WAL::Entity &entity,
+ const WAL::Entity &wall,
+ CollisionComponent::CollidedAxis collidedAxis);
+
+ static void bumperCollide(WAL::Entity &entity,
+ const WAL::Entity &wall,
+ CollisionComponent::CollidedAxis collidedAxis);
+
+
+
+ //! @param width Width of the map
+ //! @param height Height of the map
+ //! @brief Generate map of block to be loaded
+ static MapBlock createMap(int width, int height, bool isHeight = false, bool isNotClassic = false);
+
+ //! @param width Width of the map
+ //! @param height Height of the map
+ //! @param map Map to load with block declared inside
+ //! @param scene Scene where the map is instanced
+ //! @brief Generate the map
+ static void loadMap(int width, int height, MapBlock map, const std::shared_ptr &scene);
+
+ //! @param coords coords of the element
+ //! @param scene Scene where the map is instanced
+ //! @brief Create element of the map
+ static void createElement(Vector3f coords, std::shared_ptr scene, BlockType blockType);
+ private:
+
+ using MapElem = std::function scene)>;
+
//! @brief Generate random block type
static BlockType getRandomBlockType(bool = false);
@@ -77,11 +115,6 @@ namespace BBM
//! @brief Generate the floor of the map
static void generateFloor(MapBlock map, int width, int height, std::shared_ptr scene);
- //! @param coords coords of the element
- //! @param scene Scene where the map is instanced
- //! @brief Create element of the map
- static void createElement(Vector3f coords, std::shared_ptr scene, BlockType blockType);
-
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create breakable of the map
@@ -102,11 +135,6 @@ namespace BBM
//! @brief Create bumper of the map
static void createBumper(Vector3f coords, std::shared_ptr scene);
- //! @param coords coords of the element
- //! @param scene Scene where the map is instanced
- //! @brief Create floor of the map
- static void createFloor(Vector3f coords, std::shared_ptr scene);
-
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create upper floor of the map
@@ -175,37 +203,5 @@ namespace BBM
static const std::string holePath;
static const std::string secondFloorHolePath;
-
- public:
-
- static void wallCollision(WAL::Entity &entity,
- const WAL::Entity &wall,
- CollisionComponent::CollidedAxis collidedAxis);
- static void wallCollided(WAL::Entity &entity,
- const WAL::Entity &wall,
- CollisionComponent::CollidedAxis collidedAxis);
- static void wallDestroyed(WAL::Entity &entity, WAL::Wal &wal);
-
- static void holeCollide(WAL::Entity &entity,
- const WAL::Entity &wall,
- CollisionComponent::CollidedAxis collidedAxis);
-
- static void bumperCollide(WAL::Entity &entity,
- const WAL::Entity &wall,
- CollisionComponent::CollidedAxis collidedAxis);
-
-
-
- //! @param width Width of the map
- //! @param height Height of the map
- //! @brief Generate map of block to be loaded
- static MapBlock createMap(int width, int height, bool isHeight = false, bool isNotClassic = false);
-
- //! @param width Width of the map
- //! @param height Height of the map
- //! @param map Map to load with block declared inside
- //! @param scene Scene where the map is instanced
- //! @brief Generate the map
- static void loadMap(int width, int height, MapBlock map, const std::shared_ptr &scene);
};
} // namespace BBM
\ No newline at end of file
diff --git a/sources/Models/GameState.hpp b/sources/Models/GameState.hpp
index a87f3c95..3132247a 100644
--- a/sources/Models/GameState.hpp
+++ b/sources/Models/GameState.hpp
@@ -24,6 +24,7 @@ namespace BBM
SettingsScene,
PauseMenuScene,
LobbyScene,
+ ResumeLobbyScene,
TitleScreenScene,
CreditScene,
HowToPlayScene,
diff --git a/sources/Parser/Node.cpp b/sources/Parser/Node.cpp
new file mode 100644
index 00000000..f4d23eab
--- /dev/null
+++ b/sources/Parser/Node.cpp
@@ -0,0 +1,61 @@
+//
+// Created by cbihan on 16/06/2021.
+//
+
+#include "Node.hpp"
+
+namespace BBM
+{
+
+ Node::Node(std::string name) :
+ _name(std::move(name))
+ {
+ }
+
+ void Node::setProperty(const std::string &propertyName, const std::string &propertyValue)
+ {
+ this->_properties[propertyName] = propertyValue;
+ }
+
+ std::string Node::getProperty(const std::string &propertyName) const
+ {
+ return this->_properties.at(propertyName);
+ }
+
+ std::string Node::getName() const
+ {
+ return this->_name;
+ }
+
+ void Node::addChildNode(const Node &childNode)
+ {
+ this->_childNodes.emplace_back(childNode);
+ }
+
+ std::vector Node::getChildNodes(const std::string &childNodeName)
+ {
+ std::vector childs;
+
+ for (const auto &child : this->_childNodes) {
+ if (child.getName() == childNodeName) {
+ childs.emplace_back(child);
+ }
+ }
+ return childs;
+ }
+
+ std::vector Node::getChildNodes(void)
+ {
+ return this->_childNodes;
+ }
+
+ void Node::setName(const std::string &name)
+ {
+ this->_name = name;
+ }
+
+ void Node::setProperty(const std::pair &propertyNameValue)
+ {
+ this->setProperty(propertyNameValue.first, propertyNameValue.second);
+ }
+}
\ No newline at end of file
diff --git a/sources/Parser/Node.hpp b/sources/Parser/Node.hpp
new file mode 100644
index 00000000..13056c12
--- /dev/null
+++ b/sources/Parser/Node.hpp
@@ -0,0 +1,51 @@
+//
+// Created by cbihan on 16/06/2021.
+//
+
+#pragma once
+
+#include
+#include