2016-04-17 21:12:19 +00:00
|
|
|
#ifndef __SKIZZLE_GAME_HPP__
|
|
|
|
#define __SKIZZLE_GAME_HPP__
|
2016-03-04 15:29:31 +00:00
|
|
|
|
2016-04-28 23:16:03 +00:00
|
|
|
#include "../gui/modal.hpp"
|
2016-04-03 19:05:27 +00:00
|
|
|
#include "level.hpp"
|
2016-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-28 13:05:18 +00:00
|
|
|
* La classe Game gère l'affichage et les objets
|
|
|
|
* d'une partie de jeu
|
2016-03-04 15:29:31 +00:00
|
|
|
*/
|
2016-04-03 19:05:27 +00:00
|
|
|
class Game : public Level {
|
2016-04-10 00:11:37 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Les différents modes de jeu
|
|
|
|
*/
|
|
|
|
enum class Mode {NORMAL, PAUSED, WON, LOST};
|
|
|
|
|
2016-04-11 12:16:20 +00:00
|
|
|
/**
|
|
|
|
* Les différentes raisons de mort
|
|
|
|
*/
|
|
|
|
enum class DeathCause {NONE, OUT_OF_BOUNDS, KILLED, TIME_OUT};
|
|
|
|
|
2016-03-04 15:29:31 +00:00
|
|
|
private:
|
2016-04-12 19:04:31 +00:00
|
|
|
Mode mode;
|
2016-04-28 06:48:54 +00:00
|
|
|
bool test;
|
2016-04-12 19:04:31 +00:00
|
|
|
|
2016-04-03 18:19:48 +00:00
|
|
|
sf::Time next_frame_time;
|
2016-04-12 19:04:31 +00:00
|
|
|
unsigned int skipped_frames;
|
2016-04-10 22:56:22 +00:00
|
|
|
|
2016-04-12 19:04:31 +00:00
|
|
|
std::vector<Object::Ptr> pending_kill;
|
2016-04-11 12:16:20 +00:00
|
|
|
DeathCause death_cause;
|
2016-03-30 12:03:52 +00:00
|
|
|
|
2016-04-11 21:07:05 +00:00
|
|
|
float time_left;
|
|
|
|
|
2016-04-28 23:16:03 +00:00
|
|
|
sfg::Label::Ptr death_message;
|
|
|
|
Modal pause_modal;
|
|
|
|
Modal won_modal;
|
|
|
|
Modal lost_modal;
|
|
|
|
|
2016-03-09 18:35:40 +00:00
|
|
|
/**
|
|
|
|
* Met à jour les objets du jeu pour
|
2016-03-28 13:05:18 +00:00
|
|
|
* qu'ils s'adaptent au nouvel état
|
2016-03-09 18:35:40 +00:00
|
|
|
*/
|
2016-03-30 12:03:52 +00:00
|
|
|
void update();
|
2016-03-08 18:51:42 +00:00
|
|
|
|
2016-04-10 22:56:22 +00:00
|
|
|
/**
|
|
|
|
* Vérifie si l'objet donné se trouve dans
|
|
|
|
* la zone de jeu ou non
|
|
|
|
*/
|
|
|
|
bool isInZone(Object::Ptr object);
|
|
|
|
|
2016-04-28 08:14:21 +00:00
|
|
|
/**
|
|
|
|
* Recommence le niveau depuis le début
|
|
|
|
*/
|
|
|
|
void restart();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Échange entre le mode pause et le mode normal
|
|
|
|
* (si on est dans un autre mode, ne fait rien)
|
|
|
|
*/
|
|
|
|
void switchPause();
|
|
|
|
|
2016-04-06 13:21:46 +00:00
|
|
|
protected:
|
2016-04-27 20:23:44 +00:00
|
|
|
/**
|
|
|
|
* Demande le dessin d'une frame
|
|
|
|
*/
|
|
|
|
void frame() override;
|
|
|
|
|
2016-04-06 13:21:46 +00:00
|
|
|
/**
|
|
|
|
* Dessine tous les objets, le fond et
|
|
|
|
* l'interface de jeu
|
|
|
|
*/
|
2016-04-27 20:23:44 +00:00
|
|
|
void draw() override;
|
2016-04-06 13:21:46 +00:00
|
|
|
|
2016-03-09 18:35:40 +00:00
|
|
|
public:
|
2016-04-28 06:48:54 +00:00
|
|
|
Game(Manager& manager, bool test = false);
|
2016-03-28 17:57:55 +00:00
|
|
|
virtual ~Game();
|
|
|
|
|
2016-04-17 13:25:21 +00:00
|
|
|
/**
|
|
|
|
* Active l'état
|
|
|
|
*/
|
2016-04-27 20:23:44 +00:00
|
|
|
void enable() override;
|
2016-04-17 13:25:21 +00:00
|
|
|
|
2016-03-08 18:51:42 +00:00
|
|
|
/**
|
2016-04-09 21:57:23 +00:00
|
|
|
* Traite l'événement donné
|
|
|
|
*/
|
2016-04-27 20:23:44 +00:00
|
|
|
void processEvent(const sf::Event& event) override;
|
2016-04-05 23:13:00 +00:00
|
|
|
|
2016-04-11 14:32:19 +00:00
|
|
|
/**
|
|
|
|
* Tue l'objet donné
|
|
|
|
*/
|
|
|
|
void kill(Object::Ptr object);
|
|
|
|
|
2016-04-10 00:11:37 +00:00
|
|
|
/**
|
|
|
|
* Récupère le mode actuel de jeu
|
|
|
|
*/
|
|
|
|
Mode getMode();
|
2016-04-11 12:16:20 +00:00
|
|
|
DeathCause getDeathCause();
|
2016-04-10 00:11:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le mode actuel de jeu
|
|
|
|
*/
|
|
|
|
void setMode(Mode set_mode);
|
2016-04-11 12:16:20 +00:00
|
|
|
void setDeathCause(DeathCause set_death_cause);
|
2016-04-11 21:07:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le temps total du niveau
|
|
|
|
*/
|
|
|
|
virtual void setTotalTime(int set_total_time);
|
2016-04-28 06:48:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Récupère si on est en mode test
|
|
|
|
*/
|
|
|
|
bool isTest();
|
2016-03-04 15:29:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|