2016-04-11 21:38:03 +00:00
|
|
|
#ifndef __SKIZZLE_BLOCK_HPP__
|
|
|
|
#define __SKIZZLE_BLOCK_HPP__
|
2016-03-08 16:46:33 +00:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
2016-04-10 05:37:09 +00:00
|
|
|
#include <memory>
|
2016-03-08 18:50:37 +00:00
|
|
|
#include "object.hpp"
|
2016-03-08 16:46:33 +00:00
|
|
|
|
2016-04-11 12:16:20 +00:00
|
|
|
class Game;
|
2016-04-12 16:11:36 +00:00
|
|
|
class ResourceManager;
|
2016-04-11 12:16:20 +00:00
|
|
|
class Level;
|
|
|
|
|
2016-03-08 17:07:34 +00:00
|
|
|
class Block : public Object {
|
2016-04-10 05:37:09 +00:00
|
|
|
public:
|
|
|
|
typedef std::shared_ptr<Block> Ptr;
|
|
|
|
|
2016-03-15 16:08:21 +00:00
|
|
|
private:
|
2016-04-10 05:37:09 +00:00
|
|
|
sf::Sprite select_sprite;
|
2016-03-10 20:47:19 +00:00
|
|
|
|
2016-04-09 03:51:55 +00:00
|
|
|
protected:
|
|
|
|
mutable sf::Sprite sprite;
|
2016-04-11 10:34:43 +00:00
|
|
|
sf::FloatRect aabb;
|
2016-04-09 03:51:55 +00:00
|
|
|
|
2016-04-10 05:37:09 +00:00
|
|
|
/**
|
|
|
|
* Initialisation des propriétés du bloc donné
|
|
|
|
* depuis le fichier donné
|
|
|
|
*/
|
|
|
|
static void init(std::ifstream& file, Object::Ptr object);
|
|
|
|
|
2016-03-08 16:46:33 +00:00
|
|
|
public:
|
2016-03-31 17:45:57 +00:00
|
|
|
/**
|
2016-04-09 01:53:17 +00:00
|
|
|
* Identifiant unique du type "bloc"
|
2016-03-31 17:45:57 +00:00
|
|
|
*/
|
|
|
|
static const unsigned int TYPE_ID;
|
|
|
|
|
2016-04-02 13:18:29 +00:00
|
|
|
Block();
|
2016-03-28 18:02:23 +00:00
|
|
|
virtual ~Block();
|
2016-03-10 20:47:19 +00:00
|
|
|
|
2016-04-06 11:54:03 +00:00
|
|
|
/**
|
2016-04-09 01:53:17 +00:00
|
|
|
* Clone ce bloc en un bloc avec les mêmes propriétés
|
2016-04-06 11:54:03 +00:00
|
|
|
*/
|
2016-04-10 05:37:09 +00:00
|
|
|
virtual Object::Ptr clone() const;
|
2016-04-06 11:54:03 +00:00
|
|
|
|
2016-04-01 20:44:10 +00:00
|
|
|
/**
|
2016-04-09 01:53:17 +00:00
|
|
|
* Récupère la boîte englobante du bloc
|
2016-04-01 20:44:10 +00:00
|
|
|
*/
|
2016-04-10 03:10:27 +00:00
|
|
|
virtual sf::FloatRect getAABB() const;
|
2016-04-01 20:44:10 +00:00
|
|
|
|
2016-04-09 13:32:42 +00:00
|
|
|
/**
|
|
|
|
* Récupère le rayon du bloc
|
|
|
|
*/
|
|
|
|
virtual float getRadius() const;
|
|
|
|
|
2016-04-09 03:51:55 +00:00
|
|
|
/**
|
2016-04-11 00:49:40 +00:00
|
|
|
* Prépare les textures avant le dessin du bloc
|
2016-04-09 03:51:55 +00:00
|
|
|
*/
|
2016-04-11 00:49:40 +00:00
|
|
|
virtual void prepareDraw(ResourceManager& resources);
|
2016-04-09 03:51:55 +00:00
|
|
|
|
2016-03-08 17:07:34 +00:00
|
|
|
/**
|
|
|
|
* Dessin du bloc dans la fenêtre donnée
|
|
|
|
*/
|
2016-04-09 02:36:30 +00:00
|
|
|
virtual void draw(Level& level);
|
2016-03-08 20:15:33 +00:00
|
|
|
|
2016-03-13 18:07:35 +00:00
|
|
|
/**
|
2016-04-09 01:53:17 +00:00
|
|
|
* Appelé lorsque le bloc est activé par un objet
|
2016-03-13 18:07:35 +00:00
|
|
|
*/
|
2016-04-11 14:32:19 +00:00
|
|
|
virtual void activate(Game& game, Object::Ptr object);
|
2016-04-10 22:56:22 +00:00
|
|
|
|
2016-03-15 21:00:03 +00:00
|
|
|
/**
|
2016-04-09 01:53:17 +00:00
|
|
|
* Récupère l'identifiant de type des blocs
|
2016-03-15 21:00:03 +00:00
|
|
|
*/
|
2016-03-28 15:23:47 +00:00
|
|
|
virtual unsigned int getTypeId() const;
|
2016-04-09 01:53:17 +00:00
|
|
|
|
2016-04-09 13:32:42 +00:00
|
|
|
/**
|
|
|
|
* Récupère le type de collision des blocs
|
|
|
|
*/
|
|
|
|
virtual CollisionType getCollisionType() const;
|
|
|
|
|
2016-04-09 01:53:17 +00:00
|
|
|
/**
|
2016-04-10 05:37:09 +00:00
|
|
|
* Chargement d'un bloc depuis le fichier donné
|
2016-04-09 01:53:17 +00:00
|
|
|
*/
|
2016-04-10 05:37:09 +00:00
|
|
|
static Object::Ptr load(std::ifstream& file);
|
2016-04-10 04:53:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sauvegarde le bloc dans le fichier donné
|
|
|
|
*/
|
|
|
|
virtual void save(std::ofstream& file) const;
|
2016-03-08 16:46:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|