Implémentation du bloc tueur comme une icône sur le bloc
This commit is contained in:
		
							parent
							
								
									2281924c62
								
							
						
					
					
						commit
						c3b46574b3
					
				|  | @ -15,14 +15,6 @@ class KillBlock : public Block { | |||
| public: | ||||
|     typedef std::shared_ptr<KillBlock> Ptr; | ||||
| 
 | ||||
| protected: | ||||
|     /**
 | ||||
|      * Initialisation des propriétés du bloc tueur donné | ||||
|      * depuis le fichier donné | ||||
|      */ | ||||
|     static void init(std::ifstream& file, Object::Ptr object); | ||||
| 
 | ||||
| public: | ||||
|     /**
 | ||||
|      * Identifiant unique du type "bloc tueur" | ||||
|      */ | ||||
|  | @ -37,9 +29,9 @@ public: | |||
|     virtual Object::Ptr clone() const; | ||||
| 
 | ||||
|     /**
 | ||||
|      * Prépare les textures avant le dessin du bloc | ||||
|      * Dessine le bloc | ||||
|      */ | ||||
|     virtual void prepareDraw(); | ||||
|     virtual void draw(Level& level); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Appelé lorsque le bloc tueur est activé par un objet | ||||
|  | @ -60,6 +52,16 @@ public: | |||
|      * Sauvegarde le bloc tueur dans le fichier donné | ||||
|      */ | ||||
|     virtual void save(std::ofstream& file) const; | ||||
| 
 | ||||
| private: | ||||
|     sf::Sprite icon_sprite; | ||||
| 
 | ||||
| protected: | ||||
|     /**
 | ||||
|      * Initialisation des propriétés du bloc tueur donné | ||||
|      * depuis le fichier donné | ||||
|      */ | ||||
|     static void init(std::ifstream& file, Object::Ptr object); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
										
											Binary file not shown.
										
									
								
							|  | @ -1,3 +1,4 @@ | |||
| #include "manager.hpp" | ||||
| #include "resource_manager.hpp" | ||||
| #include "kill_block.hpp" | ||||
| #include "game.hpp" | ||||
|  | @ -5,16 +6,26 @@ | |||
| 
 | ||||
| const unsigned int KillBlock::TYPE_ID = 5; | ||||
| 
 | ||||
| KillBlock::KillBlock() : Block() {} | ||||
| KillBlock::KillBlock() : Block() { | ||||
|     icon_sprite.setOrigin(sf::Vector2f(23, 23)); | ||||
|     icon_sprite.setTexture(*ResourceManager::get().getTexture( | ||||
|         "objects/kill_block.tga" | ||||
|     )); | ||||
| } | ||||
| 
 | ||||
| KillBlock::~KillBlock() {} | ||||
| 
 | ||||
| Object::Ptr KillBlock::clone() const { | ||||
|     return Object::Ptr(new KillBlock(*this)); | ||||
| } | ||||
| 
 | ||||
| void KillBlock::prepareDraw() { | ||||
|     Block::prepareDraw(); | ||||
|     sprite.setTexture(*ResourceManager::get().getTexture("objects/kill_block.tga")); | ||||
| void KillBlock::draw(Level& level) { | ||||
|     // on dessine le bloc normal
 | ||||
|     Block::draw(level); | ||||
| 
 | ||||
|     // on dessine l'icône
 | ||||
|     icon_sprite.setPosition(getPosition()); | ||||
|     level.getManager().getWindow().draw(icon_sprite); | ||||
| } | ||||
| 
 | ||||
| void KillBlock::activate(Game& game, Object::Ptr object) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue