Merge branch 'master' of https://github.com/matteodelabre/projet-cmi
This commit is contained in:
		
						commit
						e859d90cd0
					
				| 
						 | 
					@ -9,6 +9,11 @@ private:
 | 
				
			||||||
    mutable sf::Sprite sprite;
 | 
					    mutable sf::Sprite sprite;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Identifiant unique du type d'objet
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    static const unsigned int TYPE_ID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block(float x, float y);
 | 
					    Block(float x, float y);
 | 
				
			||||||
    virtual ~Block();
 | 
					    virtual ~Block();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +30,6 @@ public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Récupère l'identifiant de type de cet objet
 | 
					     * Récupère l'identifiant de type de cet objet
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    static const unsigned int TYPE_ID;
 | 
					 | 
				
			||||||
    virtual unsigned int getTypeId() const;
 | 
					    virtual unsigned int getTypeId() const;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,11 +48,6 @@ public:
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void save();
 | 
					    void save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Libère les ressources du niveau
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    void clear();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Demande le passage à la frame suivante sur
 | 
					     * Demande le passage à la frame suivante sur
 | 
				
			||||||
     * cette vue
 | 
					     * cette vue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,11 @@ protected:
 | 
				
			||||||
    virtual sf::Vector2f getForces(const Manager& manager, const std::vector<ObjectPtr>& objects) const;
 | 
					    virtual sf::Vector2f getForces(const Manager& manager, const std::vector<ObjectPtr>& objects) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Identifiant unique du type d'objet
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    static const unsigned int TYPE_ID;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    Player(float x, float y);
 | 
					    Player(float x, float y);
 | 
				
			||||||
    virtual ~Player();
 | 
					    virtual ~Player();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +37,6 @@ public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Récupère l'identifiant de type de cet objet
 | 
					     * Récupère l'identifiant de type de cet objet
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    static const unsigned int TYPE_ID;
 | 
					 | 
				
			||||||
    virtual unsigned int getTypeId() const;
 | 
					    virtual unsigned int getTypeId() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,8 @@
 | 
				
			||||||
#include "constants.hpp"
 | 
					#include "constants.hpp"
 | 
				
			||||||
#include "resource_manager.hpp"
 | 
					#include "resource_manager.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const unsigned int Block::TYPE_ID = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Block::Block(float x, float y) : Object(x, y) {
 | 
					Block::Block(float x, float y) : Object(x, y) {
 | 
				
			||||||
    // par défaut, les blocs ne sont pas déplaçables et ont
 | 
					    // par défaut, les blocs ne sont pas déplaçables et ont
 | 
				
			||||||
    // donc une masse infinie, représentée par 0
 | 
					    // donc une masse infinie, représentée par 0
 | 
				
			||||||
| 
						 | 
					@ -43,7 +45,6 @@ std::unique_ptr<sf::FloatRect> Block::getAABB() const {
 | 
				
			||||||
    ));
 | 
					    ));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const unsigned int Block::TYPE_ID = 1;
 | 
					 | 
				
			||||||
unsigned int Block::getTypeId() const {
 | 
					unsigned int Block::getTypeId() const {
 | 
				
			||||||
    return TYPE_ID;
 | 
					    return TYPE_ID;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/game.cpp
								
								
								
								
							
							
						
						
									
										12
									
								
								src/game.cpp
								
								
								
								
							| 
						 | 
					@ -8,20 +8,20 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Game::Game(Manager& manager) : View(manager), accumulator(0.f) {}
 | 
					Game::Game(Manager& manager) : View(manager), accumulator(0.f) {}
 | 
				
			||||||
Game::~Game() {
 | 
					Game::~Game() {
 | 
				
			||||||
    clear();
 | 
					    objects.clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Game::load(std::ifstream& file) {
 | 
					void Game::load(std::ifstream& file) {
 | 
				
			||||||
    // vide le niveau précédent s'il y a lieu
 | 
					    // vide le niveau précédent s'il y a lieu
 | 
				
			||||||
    if (objects.size()) {
 | 
					    if (objects.size() != 0) {
 | 
				
			||||||
        clear();
 | 
					        objects.clear();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // lecture de la signture du fichier ("BAR")
 | 
					    // lecture de la signture du fichier ("BAR")
 | 
				
			||||||
    char signature[3];
 | 
					    char signature[3];
 | 
				
			||||||
    file.read(signature, sizeof(signature));
 | 
					    file.read(signature, sizeof(signature));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (strncmp(signature, "BAR", 3) != 0) {
 | 
					    if (strncmp(signature, "BAR", sizeof(signature)) != 0) {
 | 
				
			||||||
        throw std::runtime_error(
 | 
					        throw std::runtime_error(
 | 
				
			||||||
            "Impossible de lire le fichier : en-tête invalide"
 | 
					            "Impossible de lire le fichier : en-tête invalide"
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
| 
						 | 
					@ -94,10 +94,6 @@ void Game::save() {
 | 
				
			||||||
    // TODO: migrer sur une classe commune Game <-> Editor
 | 
					    // TODO: migrer sur une classe commune Game <-> Editor
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Game::clear() {
 | 
					 | 
				
			||||||
    objects.clear();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Game::frame() {
 | 
					void Game::frame() {
 | 
				
			||||||
    accumulator += manager.getElapsedTime();
 | 
					    accumulator += manager.getElapsedTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,8 @@
 | 
				
			||||||
#include <array>
 | 
					#include <array>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const unsigned int Player::TYPE_ID = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Player::Player(float x, float y) : Object(x, y) {
 | 
					Player::Player(float x, float y) : Object(x, y) {
 | 
				
			||||||
    // déplacement de l'origine au centre de la balle
 | 
					    // déplacement de l'origine au centre de la balle
 | 
				
			||||||
    sprite.setOrigin(sf::Vector2f(getRadius(), getRadius()));
 | 
					    sprite.setOrigin(sf::Vector2f(getRadius(), getRadius()));
 | 
				
			||||||
| 
						 | 
					@ -60,7 +62,6 @@ std::unique_ptr<sf::FloatRect> Player::getAABB() const {
 | 
				
			||||||
    ));
 | 
					    ));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const unsigned int Player::TYPE_ID = 0;
 | 
					 | 
				
			||||||
unsigned int Player::getTypeId() const {
 | 
					unsigned int Player::getTypeId() const {
 | 
				
			||||||
    return TYPE_ID;
 | 
					    return TYPE_ID;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue