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;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * Identifiant unique du type d'objet
 | 
			
		||||
     */
 | 
			
		||||
    static const unsigned int TYPE_ID;
 | 
			
		||||
 | 
			
		||||
    Block(float x, float y);
 | 
			
		||||
    virtual ~Block();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +30,6 @@ public:
 | 
			
		|||
    /**
 | 
			
		||||
     * Récupère l'identifiant de type de cet objet
 | 
			
		||||
     */
 | 
			
		||||
    static const unsigned int TYPE_ID;
 | 
			
		||||
    virtual unsigned int getTypeId() const;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,11 +48,6 @@ public:
 | 
			
		|||
     */
 | 
			
		||||
    void save();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Libère les ressources du niveau
 | 
			
		||||
     */
 | 
			
		||||
    void clear();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Demande le passage à la frame suivante sur
 | 
			
		||||
     * cette vue
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,11 @@ protected:
 | 
			
		|||
    virtual sf::Vector2f getForces(const Manager& manager, const std::vector<ObjectPtr>& objects) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * Identifiant unique du type d'objet
 | 
			
		||||
     */
 | 
			
		||||
    static const unsigned int TYPE_ID;
 | 
			
		||||
    
 | 
			
		||||
    Player(float x, float y);
 | 
			
		||||
    virtual ~Player();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +37,6 @@ public:
 | 
			
		|||
    /**
 | 
			
		||||
     * Récupère l'identifiant de type de cet objet
 | 
			
		||||
     */
 | 
			
		||||
    static const unsigned int TYPE_ID;
 | 
			
		||||
    virtual unsigned int getTypeId() const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,8 @@
 | 
			
		|||
#include "constants.hpp"
 | 
			
		||||
#include "resource_manager.hpp"
 | 
			
		||||
 | 
			
		||||
const unsigned int Block::TYPE_ID = 1;
 | 
			
		||||
 | 
			
		||||
Block::Block(float x, float y) : Object(x, y) {
 | 
			
		||||
    // par défaut, les blocs ne sont pas déplaçables et ont
 | 
			
		||||
    // 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 {
 | 
			
		||||
    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() {
 | 
			
		||||
    clear();
 | 
			
		||||
    objects.clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Game::load(std::ifstream& file) {
 | 
			
		||||
    // vide le niveau précédent s'il y a lieu
 | 
			
		||||
    if (objects.size()) {
 | 
			
		||||
        clear();
 | 
			
		||||
    if (objects.size() != 0) {
 | 
			
		||||
        objects.clear();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lecture de la signture du fichier ("BAR")
 | 
			
		||||
    char signature[3];
 | 
			
		||||
    file.read(signature, sizeof(signature));
 | 
			
		||||
 | 
			
		||||
    if (strncmp(signature, "BAR", 3) != 0) {
 | 
			
		||||
    if (strncmp(signature, "BAR", sizeof(signature)) != 0) {
 | 
			
		||||
        throw std::runtime_error(
 | 
			
		||||
            "Impossible de lire le fichier : en-tête invalide"
 | 
			
		||||
        );
 | 
			
		||||
| 
						 | 
				
			
			@ -94,10 +94,6 @@ void Game::save() {
 | 
			
		|||
    // TODO: migrer sur une classe commune Game <-> Editor
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Game::clear() {
 | 
			
		||||
    objects.clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Game::frame() {
 | 
			
		||||
    accumulator += manager.getElapsedTime();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,8 @@
 | 
			
		|||
#include <array>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
const unsigned int Player::TYPE_ID = 0;
 | 
			
		||||
 | 
			
		||||
Player::Player(float x, float y) : Object(x, y) {
 | 
			
		||||
    // déplacement de l'origine au centre de la balle
 | 
			
		||||
    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 {
 | 
			
		||||
    return TYPE_ID;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue