Correction commit précédent (deux fichiers manquants)
This commit is contained in:
parent
869875f7e0
commit
4353b056c1
|
@ -8,6 +8,9 @@
|
|||
#include "manager.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
|
||||
// liste des directions de la gravité
|
||||
enum class GravityDirection {NORTH, EAST, SOUTH, WEST};
|
||||
|
||||
/**
|
||||
* La classe Level est une abstraction des
|
||||
* classes affichant une collection d'objets, comme
|
||||
|
@ -21,6 +24,7 @@ private:
|
|||
sf::Sprite background;
|
||||
std::string music_name;
|
||||
|
||||
sf::Vector2f gravity;
|
||||
std::vector<ObjectPtr> objects;
|
||||
std::vector<std::pair<float, float>> zone;
|
||||
|
||||
|
@ -103,6 +107,16 @@ public:
|
|||
*/
|
||||
void setBackground(sf::Sprite set_background);
|
||||
|
||||
/**
|
||||
* Récupère le vecteur gravité
|
||||
*/
|
||||
sf::Vector2f getGravity() const;
|
||||
|
||||
/**
|
||||
* Modifie la direction de la gravité
|
||||
*/
|
||||
void setGravity(GravityDirection direction);
|
||||
|
||||
/**
|
||||
* Récupère la liste des objets
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <utility>
|
||||
#include "level.hpp"
|
||||
|
||||
const float GRAVITY = 235;
|
||||
|
||||
/**
|
||||
* Dictionnaire associant les types d'objets
|
||||
* à des instances qui seront utilisées pour la
|
||||
|
@ -17,7 +19,7 @@ std::map<unsigned int, std::function<ObjectPtr(std::ifstream&)>> object_type_map
|
|||
{Block::TYPE_ID, Block::load}
|
||||
};
|
||||
|
||||
Level::Level(Manager& manager) : View(manager) {}
|
||||
Level::Level(Manager& manager) : View(manager), gravity(0, GRAVITY) {}
|
||||
Level::~Level() {}
|
||||
|
||||
void Level::load(std::ifstream& file) {
|
||||
|
@ -190,6 +192,30 @@ void Level::setBackground(sf::Sprite set_background) {
|
|||
background = set_background;
|
||||
}
|
||||
|
||||
sf::Vector2f Level::getGravity() const {
|
||||
return gravity;
|
||||
}
|
||||
|
||||
void Level::setGravity(GravityDirection direction) {
|
||||
switch (direction) {
|
||||
case GravityDirection::NORTH:
|
||||
gravity = sf::Vector2f(0, -GRAVITY);
|
||||
break;
|
||||
|
||||
case GravityDirection::WEST:
|
||||
gravity = sf::Vector2f(GRAVITY, 0);
|
||||
break;
|
||||
|
||||
case GravityDirection::SOUTH:
|
||||
gravity = sf::Vector2f(0, GRAVITY);
|
||||
break;
|
||||
|
||||
case GravityDirection::EAST:
|
||||
gravity = sf::Vector2f(-GRAVITY, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ObjectPtr>& Level::getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue