Skip to content

Commit

Permalink
Merge pull request #157 from MyEpitech/camera/clement
Browse files Browse the repository at this point in the history
Camera/clement
  • Loading branch information
Clement-Fernandes authored Jun 19, 2022
2 parents c64b1e3 + 063804b commit 36d691f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 65 deletions.
13 changes: 9 additions & 4 deletions project/Conf/Scenes/GameScene/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@
"scale": 1,
"position": [830, 0, 0]
},
"1-score-player-1": {
"1-set-logo": {
"texture": "Ressources/sprites/set.png",
"scale": 1,
"position": [0, 0, 0]
},
"2-score-player-1": {
"texture": "Ressources/sprites/bonus_card_left.png",
"scale": 1,
"position": [0, 100, 0]
},
"2-score-player-2": {
"3-score-player-2": {
"texture": "Ressources/sprites/bonus_card_left.png",
"scale": 1,
"position": [0, 500, 0]
},
"3-score-player-3": {
"4-score-player-3": {
"texture": "Ressources/sprites/bonus_card_right.png",
"scale": 1,
"position": [1500, 110, 0]
},
"4-score-player-4": {
"5-score-player-4": {
"texture": "Ressources/sprites/bonus_card_right.png",
"scale": 1,
"position": [1500, 510, 0]
Expand Down
17 changes: 12 additions & 5 deletions project/Conf/Scenes/GameScene/text.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
{
"0": {
"0-timer": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "",
"color": [255, 255, 255, 255],
"fontSize": 50,
"position": [915, 35, 0]
},
"1-1J": {
"1-number-of-sets": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "",
"color": [255, 255, 255, 255],
"fontSize": 50,
"position": [60, 40, 0]
},
"2-1J": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "1J",
"color": [0, 0, 0, 255],
"fontSize": 30,
"position": [45, 290, 0]
},
"2-2J": {
"3-2J": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "2J",
"color": [0, 0, 0, 255],
"fontSize": 30,
"position": [1822, 300, 0]
},
"3-3J": {
"4-3J": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "3J",
"color": [0, 0, 0, 255],
"fontSize": 30,
"position": [40, 690, 0]
},
"4-4J": {
"5-4J": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "4J",
"color": [0, 0, 0, 255],
Expand Down
18 changes: 16 additions & 2 deletions project/Conf/Scenes/IntroductionScene/text.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
{
"0-winner-player": {
"0-starter-text": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "Press a Key to Start",
"color": [255, 255, 255, 255],
"fontSize": 40,
"position": [750, 700, 0]
},
"1-copyright-text": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "©2022 Studio17 Entertainment",
"color": [128, 128, 128, 255],
"fontSize": 30,
"position": [750, 1035, 0]
},
"2-version-text": {
"font": "Ressources/fonts/primetime/PRIMETIME.ttf",
"text": "ver.1.7",
"color": [128, 128, 128, 255],
"fontSize": 30,
"position": [800, 700, 0]
"position": [1750, 1035, 0]
}
}
4 changes: 2 additions & 2 deletions project/Conf/Settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
1,
0
],
"musicVolume": 0.20000001788139343,
"saveIndex": 7,
"musicVolume": 1.639127766850379e-08,
"saveIndex": 8,
"soundVolume": 1.639127766850379e-08,
"title": "Indie Studio",
"windowSize": [
Expand Down
Binary file added project/Ressources/sprites/set.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 11 additions & 23 deletions project/Save/Maps/random.map
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
XXXXXXXXXXXXXXXXXXXXXXX
X OOOOOOOOO OOOOO X
X xOxOxOxOxOxOxOxOxOx X
XOOOO OOOOOOOOOOOOOOOOX
XOxOxOxOxOxOxOxOxOxOxOX
XOOOOOOOOOO OOOOO OOOX
X xOxOxOxOxOxOx xOxOxOX
XOOOO OOOOOOOOOOOOOOOOX
XOxOxOx xOxOxOxOxOxOxOX
XOOOOOOOO OOOOOOOOOOOOX
XOxOxOxOxOxOxOxOxOxOxOX
XOOOOOOOOO OOOOOOOOOO X
XOxOxOxOxOxOxOx xOxOxOX
XOOOOOOO OOOO OOOO OOOX
XOxOxOx xOxOxOxOxOxOxOX
XOOOOOO OOOOOOO OOOOOOX
XOxOxOx xOxOxOxOxOxOxOX
XOOOOOO OOOOO OOOOOOX
XOxOxOxOxOxOxOxOxOxOx X
XO OOOOOOOOOOOOOOO OOX
X xOx xOx xOxOxOxOxOx X
X OOOOOOOO OOO OOO X
XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXX
X OOOOO X
X xOxOxOx X
XOOOOO O OX
XOxOxOxOxOX
X OOOOOOOOX
XOxOxOxOxOX
XOOOOOOOOOX
X xOx xOx X
X OOOOO X
XXXXXXXXXXX
68 changes: 39 additions & 29 deletions project/Source/Scenes/GameScenes/GameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Scene::GameScene::GameScene(std::shared_ptr<Settings> settings, std::shared_ptr<

for (std::size_t index = 0; index != 4; index++)
_players.emplace(static_cast<Object::PLAYER_ORDER>(index), std::make_unique<Object::Player>(_models.at(index), _textures.at(index + 1), _animations.at(0), 1, (Position){0, 0, 0}, Object::MAP_OBJECTS::PLAYER));
_actualSet = 0;
_actualSet = 1;
}

Scene::GameScene::~GameScene()
Expand Down Expand Up @@ -119,6 +119,7 @@ void Scene::GameScene::restartSet()
_clockGame.reset();
_explosions.clear();
_isPaused = true;
_actualSet += 1;
_bombs.clear();
_gameMap->clearMap();
_gameMap->process(_gameSettings->getMapPath());
Expand Down Expand Up @@ -155,7 +156,7 @@ void Scene::GameScene::applyGameParams()
restartSet();
for (auto &[index, player] : _players)
player->setWon(0);
_actualSet = 0;
_actualSet = 1;
}

void Scene::GameScene::handleCinematicCamera()
Expand Down Expand Up @@ -206,6 +207,7 @@ Scene::Scenes Scene::GameScene::handleEvent()
handlePause();
handleExplosions();
handleTimer();
handleSets();
return _nextScene;
}

Expand All @@ -221,32 +223,8 @@ void Scene::GameScene::draw()
}
drawObjects();
_settings->getCamera()->endMode3D();
if (!_cinematicCamera) {
for (auto &image : _images)
image->draw();
for (std::size_t index = 0; index < _players.size(); index++) {
if (_players.at(static_cast<Object::PLAYER_ORDER>(index))->isAlive())
_playersIcons.at(index).second.at(_playerSkin.at(index))->draw();
else
_playersIcons.at(index).second.at(_playerSkin.at(index) + 8)->draw();
for (std::size_t nbSets = 0; nbSets < _gameSettings->getNbSets(); nbSets++) {
if (nbSets < _players.at(static_cast<Object::PLAYER_ORDER>(index))->getSetsWon())
_setsIcons.at(index).second.at(nbSets + 5)->draw();
else
_setsIcons.at(index).second.at(nbSets)->draw();
}
}
for (auto &text : _texts)
text->draw();
for (auto &parameter : _playerParameters)
parameter->draw();
if (_3dcameraVue)
_buttons.at(1)->draw();
else
_buttons.at(0)->draw();
if (_isPaused && !_cinematicCamera)
_pauseScene->draw();
}
if (!_cinematicCamera)
drawUserInterface();
}

void Scene::GameScene::handleWin()
Expand All @@ -269,7 +247,6 @@ void Scene::GameScene::handleWin()
_settings->stopMusic(MusicsEnum::Game);
_settings->playMusic(MusicsEnum::EndGame);
_gameSettings->setPlayersRank(_mapStatistics);
_actualSet += 1;
restartSet();
}
for (auto &[index, player] : _players) {
Expand Down Expand Up @@ -494,6 +471,11 @@ void Scene::GameScene::handleExplosions()
}
}

void Scene::GameScene::handleSets()
{
_texts.at(1)->setText("Set n°" + std::to_string(_actualSet));
}

void Scene::GameScene::handleTimer()
{
int time = _clockGame.getElapsedTime() / 1000;
Expand Down Expand Up @@ -523,6 +505,34 @@ bool Scene::GameScene::isCollidingBomb(Position const &direction, Position const
return false;
}

void Scene::GameScene::drawUserInterface()
{
for (auto &image : _images)
image->draw();
for (std::size_t index = 0; index < _players.size(); index++) {
if (_players.at(static_cast<Object::PLAYER_ORDER>(index))->isAlive())
_playersIcons.at(index).second.at(_playerSkin.at(index))->draw();
else
_playersIcons.at(index).second.at(_playerSkin.at(index) + 8)->draw();
for (std::size_t nbSets = 0; nbSets < _gameSettings->getNbSets(); nbSets++) {
if (nbSets < _players.at(static_cast<Object::PLAYER_ORDER>(index))->getSetsWon())
_setsIcons.at(index).second.at(nbSets + 5)->draw();
else
_setsIcons.at(index).second.at(nbSets)->draw();
}
}
for (auto &text : _texts)
text->draw();
for (auto &parameter : _playerParameters)
parameter->draw();
if (_3dcameraVue)
_buttons.at(1)->draw();
else
_buttons.at(0)->draw();
if (_isPaused && !_cinematicCamera)
_pauseScene->draw();
}

void Scene::GameScene::drawObjects()
{
for (auto &[line, bonus] : _bonus)
Expand Down
2 changes: 2 additions & 0 deletions project/Source/Scenes/GameScenes/GameScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace Scene {

void handleExplosions();
void handleTimer();
void handleSets();

void handleCinematicCamera();
protected:
Expand All @@ -84,6 +85,7 @@ namespace Scene {

/* Draw part */
void drawObjects();
void drawUserInterface();

/* */
void resumeGame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ void Scene::IntroductionScene::draw()
image->draw();
if (_shouldPrintText)
_texts.at(0)->draw();
for (std::size_t index = 1; index < _texts.size(); index++)
_texts.at(index)->draw();
}

0 comments on commit 36d691f

Please sign in to comment.