Skip to content

Commit

Permalink
Merge branch 'master' into victor/loadingScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpalle authored Jun 16, 2022
2 parents a9db79f + 407eed1 commit 7d0cf90
Show file tree
Hide file tree
Showing 36 changed files with 719 additions and 589 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
CPackConfig.cmake
CPackSourceConfig.cmake
Testing
Makefile
cmake_install.cmake
Expand Down
2 changes: 2 additions & 0 deletions project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ file(GLOB SOURCES
Source/Scenes/NonGameScenes/SelectMapScene/*.cpp
Source/Scenes/NonGameScenes/CreditsScene/*.cpp
Source/Scenes/NonGameScenes/SelectSaveScene/*.cpp
Source/Scenes/NonGameScenes/IntroductionScene/*.cpp

Source/Settings/*.cpp
Source/Settings/GameSetting/*.cpp
Expand Down Expand Up @@ -135,6 +136,7 @@ include_directories(
Source/Scenes/NonGameScenes/SelectMapScene/
Source/Scenes/NonGameScenes/CreditsScene/
Source/Scenes/NonGameScenes/SelectSaveScene/
Source/Scenes/NonGameScenes/IntroductionScene/

Source/Settings/
Source/Settings/GameSetting/
Expand Down
9 changes: 9 additions & 0 deletions project/Conf/Scenes/GameScene/button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"0-cameraVue": {
"type": "button",
"nbFrame": 3,
"position": [100, 880, 0],
"texture": "Ressources/buttons/back_button.png",
"audio": "Ressources/buttons/click_sound.ogg"
}
}
7 changes: 7 additions & 0 deletions project/Conf/Scenes/IntroductionScene/image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"0-rose-banner": {
"texture": "Ressources/sprites/logo_bomberman.png",
"scale": 1,
"position": [660, 200, 0]
}
}
9 changes: 9 additions & 0 deletions project/Conf/Scenes/IntroductionScene/text.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"0-winner-player": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "Press a Key to Start",
"color": [255, 255, 255, 255],
"fontSize": 30,
"position": [800, 700, 0]
}
}
10 changes: 8 additions & 2 deletions project/Conf/Scenes/SelectSaveScene/button.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
"position": [300, 551, 0],
"texture": "Ressources/buttons/medium_left_arrow.png",
"audio": "Ressources/buttons/click_sound.ogg"
}
,
},
"4-NextSave": {
"type": "button",
"nbFrame": 2,
"position": [670, 551, 0],
"texture": "Ressources/buttons/medium_right_arrow.png",
"audio": "Ressources/buttons/click_sound.ogg"
},
"5-NewGameScene": {
"type": "button",
"nbFrame": 3,
"position": [300, 700, 0],
"texture": "Ressources/buttons/little_button.png",
"audio": "Ressources/buttons/click_sound.ogg"
}
}
7 changes: 7 additions & 0 deletions project/Conf/Scenes/SelectSaveScene/text.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@
"color": [255, 255, 255, 255],
"fontSize": 30,
"position": [440, 560, 0]
},
"4-New-Game": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "Create new game",
"color": [255, 255, 255, 255],
"fontSize": 30,
"position": [380, 735, 0]
}
}
5 changes: 0 additions & 5 deletions project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ cmake -DUNIT_TEST=ON ..
```

> Usage
```
This repository is intended for epitech students for want to access github actions and other features
If you are heving an issue please submit it on this github : )
```
#

Made by :
Expand Down
36 changes: 11 additions & 25 deletions project/Save/Maps/random.map
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
XXXXXXXXXXXXXXXXXXXXXXXXX
X OOOOOO OO OOOO OOOO X
X xOxOxOxOxOxOxOxOx xOx X
X O OOOOOOOOOOOO O OOOO X
XOxOxOxOxOx x xOxOxOxOxOX
XOOOOOOOOOOOOOOOOOO OO OX
XOxOxOx x xOxOxOxOxOxOxOX
XO OO OOOOOOOOOOOOOOOOOOX
XOxOxOxOxOxOxOxOxOxOxOxOX
XOOO OOOOOOOOOOOOOOOOOOOX
XOxOxOxOxOxOxOxOxOxOxOx X
XOOOOOOOOOOOOOO OOOOOOOOX
XOx xOxOx xOxOx xOxOxOxOX
XO OOOOO OOOOOO OOOOOOOOX
XOxOxOxOxOxOxOxOxOxOxOxOX
XO OOOOOOO OOOOOOOOOOOOOX
XOxOxOxOx xOxOxOxOxOxOxOX
XO OO OO OOO OOOOOOOX
XOxOxOxOxOx xOxOxOxOxOxOX
XOOOOO OOOOOOOO OOOOOOO X
X xOxOxOxOxOx xOxOxOxOxOX
XOOOOOOOOOOOOOOOOOOOOOO X
X xOx xOxOxOxOxOxOxOx x X
X OOOO OOOOOOOOOOOOO X
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXX
XEEOOOO EEX
XEx xOxOxEX
X OOOOOOOX
XOxOxOxOx X
XOOOOOOOOOX
X x xOx xOX
X OOOOOOOOX
XEx x xOx X
XEEOOOOO X
XXXXXXXXXXX
11 changes: 8 additions & 3 deletions project/Source/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
#include "SelectMapScene.hpp"
#include "CreditsScene.hpp"
#include "SelectSaveScene.hpp"
#include "IntroductionScene.hpp"

#include "tools.hpp"
#include "Map.hpp"
#include "Core.hpp"

Core::Core() : _isRunning(true),
_activeScene(Scene::Scenes::MAIN_MENU),
_activeScene(Scene::Scenes::INTRODUCTION),
_settings(std::make_shared<Settings>(getJsonData("Conf/Settings/settings.json"))),
_gameSettings(std::make_shared<GameSettings>())
{
Expand Down Expand Up @@ -56,19 +57,23 @@ void Core::loadMenuScenes()
_texts = loadObjects<Object::Text>("Conf/WaitingScreen/text.json");
updateLoadingScreen();

std::shared_ptr<Scene::GameScene> gameScene = std::make_shared<Scene::GameScene>(_settings, _gameSettings);
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::INTRODUCTION, std::make_shared<Scene::IntroductionScene>(_settings, _keyboard));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::MAIN_MENU, std::make_shared<Scene::MainMenuScene>(_settings));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::START_GAME, std::make_shared<Scene::StartGameScene>(_settings));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::SETTINGS, std::make_shared<Scene::SettingsScene>(_settings));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::GAME, std::make_shared<Scene::GameScene>(_settings, _gameSettings));
_menuScenes.emplace(Scene::Scenes::GAME, gameScene);
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::OPTION_GAME, std::make_shared<Scene::OptionGameMenuScene>(_settings, _gameSettings));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::BINDING_MENU, std::make_shared<Scene::BindingScene>(_settings, _keyboard, _playerActions, std::bind(&Core::bindKey, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::SELECT_PLAYER, std::make_shared<Scene::SelectPlayerScene>(_settings, _gameSettings));
_menuScenes.emplace(Scene::Scenes::SELECT_PLAYER, std::make_shared<Scene::SelectPlayerScene>(_settings, _gameSettings, std::bind(&Scene::GameScene::applyGameParams, gameScene)));
updateLoadingScreen();
_menuScenes.emplace(Scene::Scenes::END_GAME, std::make_shared<Scene::EndGameScene>(_settings, _gameSettings));
updateLoadingScreen();
Expand Down
4 changes: 2 additions & 2 deletions project/Source/Objects/3DObject/BombObject/Bomb/Bomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "Bomb.hpp"

Object::Bomb::Bomb(std::pair<std::string, std::string> const &pathToRessources, Position const &position, Object::PLAYER_ORDER player, float lifeTime, std::size_t range, Object::MAP_OBJECTS type) :
AThreeDimensionObject(pathToRessources, position, type)
Object::Bomb::Bomb(std::pair<std::string, std::string> const &pathToRessources, Position const &position, Object::PLAYER_ORDER player, float lifeTime, std::size_t range) :
AThreeDimensionObject(pathToRessources, position, Object::MAP_OBJECTS::BOMB)
{
_bombClock.start();
_player = player;
Expand Down
3 changes: 1 addition & 2 deletions project/Source/Objects/3DObject/BombObject/Bomb/Bomb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ namespace Object
* @param player enum of player order
* @param lifeTime float life time value
* @param range std::size_t range value
* @param type map object type
*/
Bomb(std::pair<std::string, std::string> const &pathToRessources, Position const &position, Object::PLAYER_ORDER player, float lifeTime, std::size_t range, Object::MAP_OBJECTS type);
Bomb(std::pair<std::string, std::string> const &pathToRessources, Position const &position, Object::PLAYER_ORDER player, float lifeTime, std::size_t range);
/**
* @brief Destroy the Bomb object
*/
Expand Down
105 changes: 18 additions & 87 deletions project/Source/Objects/3DObject/MapObject/Map/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ Object::Map::~Map()
{
}

void Object::Map::createFile(const std::string &filename)
{
_file.open(filename, std::ofstream::out);
if (!_file) {
_file.close();
throw Error::FileError("file failed to open " + filename);
}
}

void Object::Map::printLine(std::size_t height)
{
for (size_t one = 0; one < height + 2; one++) {
_file << static_cast<char>(MAP_OBJECTS::WALL_SIDE);
}
_file << std::endl;
}

std::vector<Position> Object::Map::getMapCorners(std::size_t width, std::size_t height)
{
std::vector<Position> corners;
Expand All @@ -52,51 +35,14 @@ std::vector<Position> Object::Map::getMapCorners(std::size_t width, std::size_t
return corners;
}

void Object::Map::generate(const std::string &filename, std::size_t width, std::size_t height, std::size_t percentageDrop)
{
srand(time(NULL));
std::size_t randomNumber = 1 + (rand() % 100);
width -= 2;
height -= 2;

if ((width % 2) == 0 || (height % 2) == 0)
throw Error::Errors("Height and Width are not compatible !");
createFile(filename);
printLine(height);
for (size_t x = 0; x < height; x++) {
_file << static_cast<char>(MAP_OBJECTS::WALL_SIDE);
for (size_t y = 0; y < width; y++) {
if (x % 2 && y % 2)
_file << static_cast<char>(MAP_OBJECTS::WALL_MIDDLE);
else {
randomNumber = 1 + (rand() % 100);
if (randomNumber > percentageDrop || (x <= 1 || x >= height - 2) && (y <= 1 || y >= width - 2))
_file << static_cast<char>(MAP_OBJECTS::EMPTY);
else
_file << static_cast<char>(MAP_OBJECTS::BOX);
}
}
_file << static_cast<char>(MAP_OBJECTS::WALL_SIDE);
_file << std::endl;
}
printLine(height);
_file.close();
}

void Object::Map::draw()
{
for (int index = 0; index < _mapPositionsObjects.size(); index++) {
for (int idx = 0; idx < _mapPositionsObjects[index].size(); idx++) {
_mapPositionsObjects[index][idx]->draw();

}
}
for (int index = 0; index < _groundMap.size(); index++) {
for (int idx = 0; idx < _groundMap[index].size(); idx++) {
_groundMap[index][idx]->draw();

}
}
for (auto &line : _mapPositionsObjects)
for (auto &object : line)
object->draw();
for (auto &line : _groundMap)
for (auto &object : line)
object->draw();
}

std::vector<std::string> Object::Map::load(std::string const &pathToFile)
Expand All @@ -105,28 +51,17 @@ std::vector<std::string> Object::Map::load(std::string const &pathToFile)
std::string tmp;
std::vector<std::string> map;

if (map.empty()) {
if (!file.is_open())
throw Error::FileError("File " + pathToFile + " doesn't exist");
while (std::getline(file, tmp))
map.push_back(tmp);
file.close();
}
if (!file.is_open())
throw Error::FileError("File " + pathToFile + " doesn't exist");
while (std::getline(file, tmp))
map.push_back(tmp);
file.close();
return (map);
}

void Object::Map::removeBlock(std::size_t index)
{
if (_mapObjects.at(index)->getType() == MAP_OBJECTS::BOX)
_mapObjects.erase(_mapObjects.begin() + index);
}

void Object::Map::process(std::string const &pathToFile)
{
_pathToMap = pathToFile;

std::vector<std::string> mapLayout = load(_pathToMap);

std::vector<std::string> mapLayout = load(pathToFile);
static const std::map<Object::MAP_OBJECTS, std::pair<Object::Render::MyModel, Object::Render::MyTexture>> keyMap = {
{MAP_OBJECTS::WALL_MIDDLE, {_mapModels.at(4), _mapTextures.at(6)}},
{MAP_OBJECTS::GROUND, {_mapModels.at(5), _mapTextures.at(7)}},
Expand All @@ -146,10 +81,6 @@ void Object::Map::process(std::string const &pathToFile)

srand(time(NULL));

_mapDimensions.setX((mapLayout.size() * _blockSize) / 2);
_mapDimensions.setY(0);
_mapDimensions.setZ((mapLayout[0].size() * _blockSize) / 2);

Vector3 tilePosition = {0, 0, 0};

for (std::size_t line = 0; line < mapLayout.size(); line += 1) {
Expand Down Expand Up @@ -202,20 +133,20 @@ std::pair<int, int> Object::Map::transposeFrom3Dto2D(Position const &position)
int x = roundUp(static_cast<int>(position.getX()), (_blockSize / 2));
int z = roundUp(static_cast<int>(position.getZ()), (_blockSize / 2));

if (x % 10 == (_blockSize / 2))
if (x % static_cast<int>(_blockSize) == (_blockSize / 2))
x -= static_cast<int>(_blockSize / 2);
if (z % 10 == (_blockSize / 2))
if (z % static_cast<int>(_blockSize) == (_blockSize / 2))
z -= static_cast<int>(_blockSize / 2);
return {x / static_cast<int>(_blockSize), z / static_cast<int>(_blockSize)};
}

void Object::Map::save()
void Object::Map::save(std::string const &mapPath)
{
std::ofstream o(_pathToMap);
std::ofstream mapFile(mapPath);
for (auto &line : _mapPositionsObjects) {
for (auto &elem : line)
o << static_cast<char>(elem->getType());
o << std::endl;
mapFile << static_cast<char>(elem->getType());
mapFile << std::endl;
}

}
Loading

0 comments on commit 7d0cf90

Please sign in to comment.