initial commit
This commit is contained in:
commit
d40f802f7a
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build
|
||||
.idea
|
||||
19
CMakeLists.txt
Normal file
19
CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(Space)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
file(GLOB_RECURSE SRC src/*)
|
||||
file(GLOB_RECURSE LIB_HEADERS lib_headers/*)
|
||||
file(GLOB_RECURSE HEADERS headers/*)
|
||||
|
||||
add_executable(Space ${LIB_HEADERS} ${HEADERS} ${SRC})
|
||||
|
||||
# target_link_directories(Space PUBLIC libs)
|
||||
target_include_directories(Space PUBLIC headers)
|
||||
target_include_directories(Space PUBLIC lib_headers)
|
||||
|
||||
target_link_libraries(Space mingl)
|
||||
target_link_libraries(Space GL)
|
||||
target_link_libraries(Space GLU)
|
||||
target_link_libraries(Space glut)
|
||||
40
config.yaml
Normal file
40
config.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
# Screen Config
|
||||
screen:
|
||||
# specifies the screen resolution, must in 16:9,
|
||||
# default : "1280x720"
|
||||
#! hardcoder une res de base si c'est pas un 16:9
|
||||
resolution:
|
||||
screen:
|
||||
- "1920"
|
||||
- "1080"
|
||||
terminal:
|
||||
- 10
|
||||
- 10
|
||||
terminal:
|
||||
charEmptySpace: ' '
|
||||
charPlayer: ''
|
||||
charPlayerProjectile: ''
|
||||
charEnemy: ''
|
||||
charEnemyProjectile: ''
|
||||
|
||||
# Game Mode
|
||||
# values : "terminal" "graphic"
|
||||
# default : "terminal"
|
||||
mode: "graphic"
|
||||
|
||||
# User config
|
||||
user:
|
||||
startPositionX: 0
|
||||
startPositionY: 0
|
||||
speed: 5
|
||||
keys:
|
||||
moveLeft: '4'
|
||||
moveLeft: '6'
|
||||
shoot: '5'
|
||||
|
||||
# Enemies config
|
||||
enemy:
|
||||
startPositionX: 0
|
||||
startPositionY: 0
|
||||
speed: 2
|
||||
size: 4
|
||||
16
headers/entites.h
Normal file
16
headers/entites.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef entites
|
||||
#define entites
|
||||
|
||||
void summonEntity(entites & pos_entites, pos & coordonees);
|
||||
|
||||
void deleteEntity(entites & pos_entites, pos & coordonees);
|
||||
|
||||
void invaderMovement(entites & pos_entites);
|
||||
|
||||
void torpilleMovement(entites & pos_entites);
|
||||
|
||||
void Collision(entites & pos_entites);
|
||||
|
||||
void userInteraction(entites & pos_entites);
|
||||
|
||||
#endif
|
||||
8
headers/space.h
Normal file
8
headers/space.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef space
|
||||
#define space
|
||||
|
||||
void display(CVString & space, entites & pos_entites);
|
||||
|
||||
void initTerminalSpace (CVString & space, entites & liste_pos);
|
||||
|
||||
#endif
|
||||
12
headers/sprites.h
Normal file
12
headers/sprites.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef sprites
|
||||
#define sprites
|
||||
#include "mingl/mingl.h"
|
||||
|
||||
#include "mingl/shape/line.h"
|
||||
#include "mingl/shape/triangle.h"
|
||||
#include "mingl/shape/rectangle.g"
|
||||
#include "mingl/shape/circle.h"
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
128
lib_headers/mingl/audio/audioengine.h
Normal file
128
lib_headers/mingl/audio/audioengine.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
*
|
||||
* @file audioengine.h
|
||||
* @author Clément Mathieu--Drif
|
||||
* @date Septembre 2020
|
||||
* @version 1.0
|
||||
* @brief Gestionnaire audio de minGL
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef AUDIOENGINE_H
|
||||
#define AUDIOENGINE_H
|
||||
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#include <SFML/Audio.hpp> // based on SFML
|
||||
|
||||
/**
|
||||
* @namespace nsAudio
|
||||
* @brief Espace de nom pour les utilitaires audio. Il est conseillé d'utiliser des fichiers .wav
|
||||
*/
|
||||
namespace nsAudio
|
||||
{
|
||||
/**
|
||||
* @class AudioEngine
|
||||
* @brief Une classe de gestion des effets audio et de la musique
|
||||
*/
|
||||
class AudioEngine
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Définit le fichier audio de la musique
|
||||
* @param[in] fileName : nom du fichier
|
||||
* @param[in] loop : indique si la musique est lue en boucle ou non (oui par défaut)
|
||||
* @fn void setMusic(const std::string& fileName, bool loop = true);
|
||||
*/
|
||||
void setMusic(const std::string& fileName, bool loop = true);
|
||||
|
||||
/**
|
||||
* @brief Met en pause ou relance la musique
|
||||
* @fn void toggleMusicPlaying();
|
||||
*/
|
||||
void toggleMusicPlaying();
|
||||
|
||||
/**
|
||||
* @brief Règle l'état de lecture de la musique
|
||||
* @param[in] playing : Nouvel état de lecture
|
||||
* @fn void setMusicPlaying(bool playing);
|
||||
*/
|
||||
void setMusicPlaying(bool playing);
|
||||
|
||||
/**
|
||||
* @brief Récupère l'état de lecture de la musique
|
||||
* @fn bool isMusicPlaying() const;
|
||||
*/
|
||||
bool isMusicPlaying() const;
|
||||
|
||||
/**
|
||||
* @brief Charge un fichier audio dans un buffer
|
||||
* @fn void loadSound(const std::string & fileName);
|
||||
*/
|
||||
void loadSound(const std::string& fileName);
|
||||
|
||||
/**
|
||||
* @brief Retire un buffer de la liste
|
||||
* @fn void removeBuffer(const std::string & fileName);
|
||||
*/
|
||||
void removeBuffer(const std::string & fileName);
|
||||
|
||||
/**
|
||||
* @brief Vide la liste des buffers
|
||||
* @fn void emptyBufferList();
|
||||
*/
|
||||
void emptyBufferList();
|
||||
|
||||
/**
|
||||
* @brief Relance la musique depuis le début
|
||||
* @fn void startMusicFromBeginning();
|
||||
*/
|
||||
void startMusicFromBeginning();
|
||||
|
||||
/**
|
||||
* @brief Joue un son depuis un buffer
|
||||
* @param[in] fileName : nom du fichier
|
||||
* @fn void playSoundFromBuffer(const std::string& fileName);
|
||||
*/
|
||||
void playSoundFromBuffer(const std::string& fileName);
|
||||
|
||||
/**
|
||||
* @brief Joue un son depuis un fichier
|
||||
* @param[in] fileName : nom du fichier
|
||||
* @fn void playSoundFromFile(const std::string& fileName);
|
||||
*/
|
||||
void playSoundFromFile(const std::string& fileName);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_buffers : Liste des buffers utilisés par les éléments de m_sounds
|
||||
*/
|
||||
std::list<std::pair<std::string, sf::SoundBuffer>> m_buffers;
|
||||
|
||||
/**
|
||||
* @brief m_sounds : Liste des effets audio en cours de lecture depuis des buffers
|
||||
*/
|
||||
std::list<sf::Sound> m_sounds;
|
||||
|
||||
/**
|
||||
* @brief m_soundsFromFiles : Liste des effets audio en cours de lecture depuis des fichiers
|
||||
*/
|
||||
std::list<sf::Music> m_soundsFromFiles;
|
||||
|
||||
/**
|
||||
* @brief m_music : Musique principale
|
||||
*/
|
||||
sf::Music m_music;
|
||||
|
||||
/**
|
||||
* @brief Retire les sons terminés des listes m_sounds et m_soundsFromFiles
|
||||
* @fn void removeOldSounds();
|
||||
*/
|
||||
void removeOldSounds();
|
||||
|
||||
}; // class AudioEngine
|
||||
|
||||
} // namespace nsAudio
|
||||
|
||||
#endif // AUDIOENGINE_H
|
||||
69
lib_headers/mingl/event/event.hpp
Normal file
69
lib_headers/mingl/event/event.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
*
|
||||
* @file event.hpp
|
||||
* @author Alexandre Sollier
|
||||
* @date Décembre 2019
|
||||
* @version 1.0
|
||||
* @brief Différents types utile pour le gestionnaire d'événements
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef EVENT_HPP
|
||||
#define EVENT_HPP
|
||||
|
||||
/**
|
||||
* @namespace nsEvent
|
||||
* @brief Espace de nom pour la gestion d'événements
|
||||
*/
|
||||
namespace nsEvent {
|
||||
|
||||
/**
|
||||
* @brief EventType_t : Liste de tout les types d'événements
|
||||
*/
|
||||
enum EventType_t {
|
||||
MouseClick, /**< L'utilisateur a cliqué sur un des boutons de la souris */
|
||||
MouseMove /**< Le curseur s'est déplacé */,
|
||||
MouseDrag, /**< Le curseur s'est déplacé pendant qu'un des boutons de la souris était pressé */
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct MouseClickData_t
|
||||
* @brief Possède des données pour un événement MouseClick
|
||||
*/
|
||||
struct MouseClickData_t {
|
||||
int button; /**< ID numérique du bouton */
|
||||
int state; /**< Nouvel état du bouton */
|
||||
int x; /**< Coordonnée X du curseur, relative au coin supérieur-gauche de la fenêtre */
|
||||
int y; /**< Coordonnée Y du curseur, relative au coin supérieur-gauche de la fenêtre */
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct MouseMoveData_t
|
||||
* @brief Possède des données pour un événement MouseMove/MouseDrag
|
||||
*/
|
||||
struct MouseMoveData_t {
|
||||
int x; /**< Coordonnée X du curseur, relative au coin supérieur-gauche de la fenêtre */
|
||||
int y; /**< Coordonnée Y du curseur, relative au coin supérieur-gauche de la fenêtre */
|
||||
};
|
||||
|
||||
/**
|
||||
* @union EventData_t
|
||||
* @brief Union contenant les données d'un événement
|
||||
*/
|
||||
union EventData_t {
|
||||
MouseClickData_t clickData; /**< Données pour un événement MouseClick */
|
||||
MouseMoveData_t moveData; /**< Données pour un événment MouseMove/MouseDrag */
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct Event_t
|
||||
* @brief Possède des données pour un événement
|
||||
*/
|
||||
struct Event_t {
|
||||
EventType_t eventType; /**< Type de l'événement */
|
||||
EventData_t eventData; /**< Données de l'événement */
|
||||
};
|
||||
|
||||
} // namespace nsEvent
|
||||
|
||||
#endif // EVENT_HPP
|
||||
65
lib_headers/mingl/event/event_manager.h
Normal file
65
lib_headers/mingl/event/event_manager.h
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
* @file event_manager.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Décembre 2019
|
||||
* @version 1.0
|
||||
* @brief Gestionnaire d'événements de minGL
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef EVENTMANAGER_H
|
||||
#define EVENTMANAGER_H
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "event.hpp"
|
||||
|
||||
namespace nsEvent {
|
||||
|
||||
/**
|
||||
* @class EventManager
|
||||
* @brief Gère une queue d'événement entrants
|
||||
*/
|
||||
class EventManager
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Vérifie si un événement doit être traité
|
||||
* @return Si la queue possède au moins un élément
|
||||
* @fn bool hasEvent();
|
||||
*/
|
||||
bool hasEvent();
|
||||
|
||||
/**
|
||||
* @brief Pousse un nouvel événement dans la queue
|
||||
* @param[in] event : Evénement a pousser
|
||||
* @fn void pushEvent(const Event_t& event);
|
||||
*/
|
||||
void pushEvent(const Event_t& event);
|
||||
|
||||
/**
|
||||
* @brief Tire l'événement le plus ancien, et l'enlève de la queue
|
||||
* @return Une copie du plus ancien événement
|
||||
* @fn const Event_t pullEvent();
|
||||
*/
|
||||
const Event_t pullEvent();
|
||||
|
||||
/**
|
||||
* @brief Vide la queue
|
||||
* @fn void clearEvents();
|
||||
*/
|
||||
void clearEvents();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_eventQueue : Queue possèdant des événement entrants
|
||||
*/
|
||||
std::queue<Event_t> m_eventQueue;
|
||||
|
||||
}; // class EventManager
|
||||
|
||||
} // namespace nsEvent
|
||||
|
||||
#endif // EVENTMANAGER_H
|
||||
98
lib_headers/mingl/exception/cexception.h
Executable file
98
lib_headers/mingl/exception/cexception.h
Executable file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
*
|
||||
* @file cexception.h
|
||||
*
|
||||
* @authors M. Laporte, D. Mathieu
|
||||
*
|
||||
* @date 23/03/2010
|
||||
*
|
||||
* @version V1.0
|
||||
*
|
||||
* @brief Declaration de la classe CException
|
||||
*
|
||||
* @version V1.1
|
||||
*
|
||||
* @author Alexandre Sollier
|
||||
*
|
||||
* @brief Ajout de la documentation
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef CEXCEPTION_H
|
||||
#define CEXCEPTION_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include "../tools/ieditable.h"
|
||||
#include "errcode.h"
|
||||
|
||||
/**
|
||||
* @namespace nsException
|
||||
* @brief Espace de nom pour la gestion d'exceptions
|
||||
*/
|
||||
namespace nsException
|
||||
{
|
||||
|
||||
/**
|
||||
* @class CException
|
||||
* @brief Classe pour créer des exceptions facilement
|
||||
*/
|
||||
class CException : public std::exception, public nsUtil::IEditable
|
||||
{
|
||||
|
||||
public :
|
||||
/**
|
||||
* @brief Constructeur pour la classe CException
|
||||
* @param[in] Libelle : Libellé de l'exception
|
||||
* @param[in] CodErr : Code erreur de l'exception
|
||||
* @fn CException(const std::string& Libelle = std::string(), const unsigned CodErr = KNoExc);
|
||||
*/
|
||||
CException(const std::string& Libelle = std::string(), const unsigned CodErr = KNoExc);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe CException
|
||||
* @fn virtual ~CException() override = default;
|
||||
*/
|
||||
virtual ~CException() override = default;
|
||||
|
||||
/**
|
||||
* @brief Récupère le libellé de l'exception
|
||||
* @fn const std::string& GetLibelle() const;
|
||||
*/
|
||||
const std::string& GetLibelle() const;
|
||||
|
||||
/**
|
||||
* @brief Récupère le code erreur de l'exception
|
||||
* @fn unsigned GetCodErr() const;
|
||||
*/
|
||||
unsigned GetCodErr() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne une chaine de caractère C décrivant l'exception
|
||||
* @fn virtual const char* what() const noexcept override;
|
||||
*/
|
||||
virtual const char* what() const noexcept override;
|
||||
|
||||
protected :
|
||||
virtual std::ostream& _Edit(std::ostream& os = std::cerr) const override;
|
||||
|
||||
/**
|
||||
* @brief m_Libelle : Libellé de l'exception
|
||||
*/
|
||||
std::string m_Libelle;
|
||||
|
||||
/**
|
||||
* @brief m_CodErr : Code erreur de l'exception
|
||||
*/
|
||||
unsigned m_CodErr;
|
||||
|
||||
}; // class CException
|
||||
|
||||
} // namespace nsException
|
||||
|
||||
#include "cexception.hpp"
|
||||
|
||||
#endif // CEXCEPTION_H
|
||||
|
||||
49
lib_headers/mingl/exception/cexception.hpp
Executable file
49
lib_headers/mingl/exception/cexception.hpp
Executable file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
*
|
||||
* @file cexception.hpp
|
||||
*
|
||||
* @authors M. Laporte, D. Mathieu
|
||||
*
|
||||
* @date 23/03/2010
|
||||
*
|
||||
* @version V1.0
|
||||
*
|
||||
* @brief classe CException
|
||||
*
|
||||
* @version V1.1
|
||||
*
|
||||
* @author Alexandre Sollier
|
||||
*
|
||||
* @brief Documentation complétée
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef CEXCEPTION_HPP
|
||||
#define CEXCEPTION_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cexception.h"
|
||||
|
||||
inline nsException::CException::CException(const std::string& Libelle /* = std::string () */, const unsigned CodErr /* = KNoExc */)
|
||||
: m_Libelle (Libelle)
|
||||
, m_CodErr (CodErr)
|
||||
{} // CException()
|
||||
|
||||
inline const std::string& nsException::CException::GetLibelle() const
|
||||
{
|
||||
return m_Libelle;
|
||||
} // GetLibelle()
|
||||
|
||||
inline unsigned nsException::CException::GetCodErr() const
|
||||
{
|
||||
return m_CodErr;
|
||||
} // GetCoderr()
|
||||
|
||||
inline const char* nsException::CException::what() const noexcept
|
||||
{
|
||||
return m_Libelle.c_str();
|
||||
} // what()
|
||||
|
||||
#endif // CEXCEPTION_HPP
|
||||
|
||||
65
lib_headers/mingl/exception/errcode.h
Executable file
65
lib_headers/mingl/exception/errcode.h
Executable file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
* @file errcode.h
|
||||
*
|
||||
* @authors D. Mathieu
|
||||
*
|
||||
* @date 28/08/2010
|
||||
*
|
||||
* @version V2.0
|
||||
*
|
||||
* @brief Codes d'erreurs
|
||||
*
|
||||
* @version V2.1
|
||||
*
|
||||
* @author Alexandre Sollier
|
||||
*
|
||||
* @brief Ajout de la documentation, renommage du fichier
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef CSTCODERR_H
|
||||
#define CSTCODERR_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace nsException
|
||||
{
|
||||
|
||||
enum {
|
||||
KNoExc = 0, /**< Pas d'exception */
|
||||
KNoError = 0, /**< Pas d'exception */
|
||||
|
||||
kColorOutOfBounds = 100, /**< Couleur hors des bornes */
|
||||
|
||||
KFileError = 252, /**< Erreur lors de l'ouverture du fichier */
|
||||
KErrArg = 253, /**< Erreur d'argument (Nombre ou types) */
|
||||
KExcStd = 254, /**< Erreur standard */
|
||||
kExcInconnue = -1, /**< Erreur inconnue */
|
||||
|
||||
kErrTooHight = 300, /**< Position trop haute */
|
||||
kErrTooRight = 301, /**< Position trop a droite */
|
||||
kErrFontSize = 302, /**< Erreur sur la taille de la police */
|
||||
kNoTriangle = 303, /**< Pas de triangle */
|
||||
kNoLine = 304, /**< Pas de ligne */
|
||||
kNoRectangle = 305, /**< Pas de rectangle */
|
||||
kNoCircle = 306, /**< Pas de cercle */
|
||||
kTypeNotFound = 307, /**< Type non trouvé */
|
||||
};
|
||||
|
||||
const std::map <unsigned, std::string> kError
|
||||
{
|
||||
{kErrTooHight, "Trop haut"},
|
||||
{kErrTooRight, "Trop à droite"},
|
||||
{kErrFontSize, "Taille de police incorrecte"},
|
||||
{kNoTriangle, "Nombre incorrect de points pour la construction du triangle"},
|
||||
{kNoLine, "Nombre incorrect de points pour la construction d'une ligne"},
|
||||
{kNoRectangle, "Nombre incorrect de points pour la construction d'un rectangle"},
|
||||
{kNoCircle, "Nombre incorrect de points pour la construction d'un cercle"},
|
||||
{kTypeNotFound, "Instanciation impossible: Pas le bon type"},
|
||||
};
|
||||
|
||||
} // namespace nsException
|
||||
|
||||
#endif // CSTCODERR_H
|
||||
62
lib_headers/mingl/graphics/idrawable.h
Normal file
62
lib_headers/mingl/graphics/idrawable.h
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
*
|
||||
* @file idrawable.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Interface pour un objet affichable
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef DRAWABLE_H
|
||||
#define DRAWABLE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
class MinGL;
|
||||
|
||||
/**
|
||||
* @namespace nsGraphics
|
||||
* @brief Espace de nom pour les utilitaires graphiques
|
||||
*/
|
||||
namespace nsGraphics
|
||||
{
|
||||
|
||||
/**
|
||||
* @class IDrawable
|
||||
* @brief Interface pour un objet affichable
|
||||
*/
|
||||
class IDrawable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Destructeur pour la classe IDrawable
|
||||
* @fn virtual ~IDrawable() = default;
|
||||
*/
|
||||
virtual ~IDrawable() = default;
|
||||
|
||||
/**
|
||||
* @brief Fonction pour afficher l'objet.
|
||||
* @fn virtual void draw(MinGL& window) const = 0;
|
||||
*/
|
||||
virtual void draw(MinGL& window) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Surcharge de l'opérateur d'injection
|
||||
* @param[in] window : Fenêtre dans laquelle injecter l'élément
|
||||
* @param[in] drawable : Elément a injecter
|
||||
* @fn friend MinGL& operator<<(MinGL& window, const IminGLInjectable& drawable)
|
||||
*/
|
||||
friend MinGL& operator<<(MinGL& window, const IDrawable& drawable)
|
||||
{
|
||||
drawable.draw(window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
}; // class IDrawable
|
||||
|
||||
} // namespace nsGraphics
|
||||
|
||||
#endif // DRAWABLE_H
|
||||
177
lib_headers/mingl/graphics/rgbacolor.h
Executable file
177
lib_headers/mingl/graphics/rgbacolor.h
Executable file
@ -0,0 +1,177 @@
|
||||
/**
|
||||
*
|
||||
* @file rgbacolor.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.1
|
||||
* @brief Représente une couleur RGBA
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef RGBACOLOR_H
|
||||
#define RGBACOLOR_H
|
||||
|
||||
#include <GL/freeglut.h> // GLubyte
|
||||
|
||||
#include "../tools/ieditable.h"
|
||||
|
||||
namespace nsGraphics
|
||||
{
|
||||
|
||||
/**
|
||||
* @class RGBAcolor
|
||||
* @brief Classe représentant un couleur RGBA8888
|
||||
*/
|
||||
class RGBAcolor : public nsUtil::IEditable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructeur pour la classe RGBAcolor
|
||||
* @param[in] red : Taux de rouge (0-255)
|
||||
* @param[in] green : Taux de vert (0-255)
|
||||
* @param[in] blue : Taux de bleu (0-255)
|
||||
* @param[in] alpha : Taux de transparence (0-255)
|
||||
* @fn RGBAcolor(const GLubyte& red = 0, const GLubyte& green = 0, const GLubyte& blue = 0, const GLubyte& alpha = 255);
|
||||
*/
|
||||
RGBAcolor(const GLubyte& red = 0, const GLubyte& green = 0, const GLubyte& blue = 0, const GLubyte& alpha = 255);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe RGBAcolor
|
||||
* @fn virtual ~RGBAcolor() override = default;
|
||||
*/
|
||||
virtual ~RGBAcolor() override = default;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'égalité
|
||||
* @param[in] col : Couleur a vérifier
|
||||
* @fn bool operator==(const RGBAcolor& col) const;
|
||||
*/
|
||||
bool operator==(const RGBAcolor& col) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'inégalité
|
||||
* @param[in] col : Couleur a vérifier
|
||||
* @fn bool operator!=(const RGBAcolor& col) const;
|
||||
*/
|
||||
bool operator!=(const RGBAcolor& col) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de décalage
|
||||
* @param[in] rhs : Couleur a additionner
|
||||
* @fn RGBAcolor operator+(const RGBAcolor& rhs) const;
|
||||
*/
|
||||
RGBAcolor operator+(const RGBAcolor& rhs) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de réduction
|
||||
* @param[in] rhs : Couleur avec laquelle multiplier la couleur actuelle
|
||||
* @fn RGBAcolor operator*(const float& rhs) const;
|
||||
*/
|
||||
RGBAcolor operator*(const float& rhs) const;
|
||||
|
||||
/**
|
||||
* @brief Récupère le taux de rouge
|
||||
* @return Une référence constante vers m_red
|
||||
* @fn GLubyte getRed() const;
|
||||
*/
|
||||
GLubyte getRed() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau taux de rouge
|
||||
* @param[in] red : Nouveau taux de rouge
|
||||
* @fn void setRed(const GLubyte& red);
|
||||
*/
|
||||
void setRed(const GLubyte& red);
|
||||
|
||||
/**
|
||||
* @brief Récupère le taux de vert
|
||||
* @return Une référence constante vers m_green
|
||||
* @fn GLubyte getGreen() const;
|
||||
*/
|
||||
GLubyte getGreen() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau taux de vert
|
||||
* @param[in] red : Nouveau taux de vert
|
||||
* @fn void setGreen(const GLubyte& green);
|
||||
*/
|
||||
void setGreen(const GLubyte& green);
|
||||
|
||||
/**
|
||||
* @brief Récupère le taux de bleu
|
||||
* @return Une référence constante vers m_blue
|
||||
* @fn GLubyte getBlue() const;
|
||||
*/
|
||||
GLubyte getBlue() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau taux de bleu
|
||||
* @param[in] red : Nouveau taux de bleu
|
||||
* @fn void setBlue(const GLubyte& blue);
|
||||
*/
|
||||
void setBlue(const GLubyte& blue);
|
||||
|
||||
/**
|
||||
* @brief Récupère le taux de transparence
|
||||
* @return Une référence constante vers m_alpha
|
||||
* @fn GLubyte getAlpha() const;
|
||||
*/
|
||||
GLubyte getAlpha() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau taux de transparence
|
||||
* @param[in] red : Nouveau taux de transparence
|
||||
* @fn void setAlpha(const GLubyte& alpha);
|
||||
*/
|
||||
void setAlpha(const GLubyte& alpha);
|
||||
|
||||
protected:
|
||||
virtual std::ostream& _Edit(std::ostream& os = std::cout) const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_red : Taux de rouge
|
||||
*/
|
||||
GLubyte m_red;
|
||||
|
||||
/**
|
||||
* @brief m_green : Taux de vert
|
||||
*/
|
||||
GLubyte m_green;
|
||||
|
||||
/**
|
||||
* @brief m_blue : Taux de bleu
|
||||
*/
|
||||
GLubyte m_blue;
|
||||
|
||||
/**
|
||||
* @brief m_alpha : Taux de transparence
|
||||
*/
|
||||
GLubyte m_alpha;
|
||||
|
||||
}; // class RGBAcolor
|
||||
|
||||
// Quelques couleurs trouvées sur:
|
||||
// https://www.rapidtables.com/web/color/RGB_Color.html
|
||||
const RGBAcolor KBlack { 0, 0, 0};
|
||||
const RGBAcolor KWhite {255, 255, 255};
|
||||
const RGBAcolor KRed {255, 0, 0};
|
||||
const RGBAcolor KLime { 0, 255, 0};
|
||||
const RGBAcolor KBlue { 0, 0, 255};
|
||||
const RGBAcolor KYellow {255, 255, 0};
|
||||
const RGBAcolor KCyan { 0, 255, 255};
|
||||
const RGBAcolor KMagenta {255, 0, 255};
|
||||
const RGBAcolor KSilver {192, 192, 192};
|
||||
const RGBAcolor KGray {128, 128, 128};
|
||||
const RGBAcolor KMaroon {128, 0, 0};
|
||||
const RGBAcolor KOlive {128, 128, 0};
|
||||
const RGBAcolor KGreen { 0, 128, 0};
|
||||
const RGBAcolor KPurple {128, 0, 128};
|
||||
const RGBAcolor KTeal { 0, 128, 128};
|
||||
const RGBAcolor KNavy { 0, 0, 128};
|
||||
const RGBAcolor KTransparent { 0, 0, 0, 0};
|
||||
|
||||
} // namespace nsGraphics
|
||||
|
||||
#endif // RGBACOLOR_H
|
||||
270
lib_headers/mingl/graphics/vec2d.h
Executable file
270
lib_headers/mingl/graphics/vec2d.h
Executable file
@ -0,0 +1,270 @@
|
||||
/**
|
||||
*
|
||||
* @file vec2d.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.3
|
||||
* @brief Représente un vecteur sur deux dimensions
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef VEC2D_H
|
||||
#define VEC2D_H
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "../tools/ieditable.h"
|
||||
|
||||
namespace nsGraphics
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Vec2D
|
||||
* @brief Classe représentant un vecteur deux-dimensionnel
|
||||
*/
|
||||
class Vec2D : public nsUtil::IEditable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructeur pour la classe Vec2D
|
||||
* @param[in] x : Position X (abscisse) du vecteur
|
||||
* @param[in] y : Position Y (ordonnée) du vecteur
|
||||
* @fn Vec2D(const int& x = 0, const int& y = 0);
|
||||
*/
|
||||
Vec2D(const int& x = 0, const int& y = 0);
|
||||
|
||||
/**
|
||||
* @brief Constructeur de recopie pour la classe Vec2D
|
||||
* @param[in] pos : Vec2D a copier
|
||||
* @fn Vec2D(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur unaire plus
|
||||
* @fn Vec2D operator+() const;
|
||||
*/
|
||||
Vec2D operator+() const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur unaire moins
|
||||
* @fn Vec2D operator-() const;
|
||||
*/
|
||||
Vec2D operator-() const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'addition
|
||||
* @param[in] pos : Vecteur a additionner
|
||||
* @fn Vec2D operator+(const Vec2D& pos) const;
|
||||
*/
|
||||
Vec2D operator+(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de soustraction
|
||||
* @param[in] pos : Vecteur a soustraire
|
||||
* @fn Vec2D operator-(const Vec2D& pos) const;
|
||||
*/
|
||||
Vec2D operator-(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de multiplication
|
||||
* @param[in] pos : Vecteur a multiplier
|
||||
* @fn Vec2D operator*(const Vec2D& pos) const;
|
||||
*/
|
||||
Vec2D operator*(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de multiplication
|
||||
* @param[in] n : Nombre avec lequel multiplier le vecteur actuel
|
||||
* @fn Vec2D operator*(const float& n) const;
|
||||
*/
|
||||
Vec2D operator*(const float& n) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de division
|
||||
* @param[in] pos : Vecteur a diviser
|
||||
* @fn Vec2D operator/(const Vec2D& pos) const;
|
||||
*/
|
||||
Vec2D operator/(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de division
|
||||
* @param[in] n : Nombre avec lequel diviser le vecteur actuel
|
||||
* @fn Vec2D operator/(const float& n) const;
|
||||
*/
|
||||
Vec2D operator/(const float& n) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur modulo
|
||||
* @param[in] pos : Vecteur avec lequel faire un modulo
|
||||
* @fn Vec2D operator%(const Vec2D& pos) const;
|
||||
*/
|
||||
Vec2D operator%(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'égalité
|
||||
* @param[in] pos : Vecteur avec lequel vérifier l'égalité
|
||||
* @fn bool operator==(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator==(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'inégalité
|
||||
* @param[in] pos : Vecteur avec lequel vérifier l'inégalité
|
||||
* @fn bool operator!=(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator!=(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de stricte infériorité
|
||||
* (Vérifie la stricte infériorité de la magnitude des deux vecteurs)
|
||||
* @param[in] pos : Vecteur avec lequel vérifier la stricte infériorité
|
||||
* @fn bool operator<(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator<(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de stricte supériorité
|
||||
* (Vérifie la stricte supériorité de la magnitude des deux vecteurs)
|
||||
* @param[in] pos : Vecteur avec lequel vérifier la stricte supériorité
|
||||
* @fn bool operator>(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator>(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'infériorité
|
||||
* (Vérifie l'infériorité de la magnitude des deux vecteurs)
|
||||
* @param[in] pos : Vecteur avec lequel vérifier l'infériorité
|
||||
* @fn bool operator<=(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator<=(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de supériorité
|
||||
* (Vérifie la supériorité de la magnitude des deux vecteurs)
|
||||
* @param[in] pos : Vecteur avec lequel vérifier la supériorité
|
||||
* @fn bool operator>=(const Vec2D& pos) const;
|
||||
*/
|
||||
bool operator>=(const Vec2D& pos) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'assignement
|
||||
* @param[in] pos : Vecteur source
|
||||
* @fn Vec2D& operator=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur d'addition avec assignement
|
||||
* @param[in] pos : Vecteur avec lequel additionner le vecteur actuel
|
||||
* @fn Vec2D& operator+=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator+=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur de soustraction avec assignement
|
||||
* @param[in] pos : Vecteur avec lequel soustraire le vecteur actuel
|
||||
* @fn Vec2D& operator-=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator-=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur de multiplication avec assignement
|
||||
* @param[in] pos : Vecteur avec lequel multiplier le vecteur actuel
|
||||
* @fn Vec2D& operator*=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator*=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur de division avec assignement
|
||||
* @param[in] pos : Vecteur avec lequel diviser le vecteur actuel
|
||||
* @fn Vec2D& operator/=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator/=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Opérateur modulo avec assignement
|
||||
* @param[in] pos : Vecteur avec lequel faire un modulo sur le vecteur actuel
|
||||
* @fn Vec2D& operator%=(const Vec2D& pos);
|
||||
*/
|
||||
Vec2D& operator%=(const Vec2D& pos);
|
||||
|
||||
/**
|
||||
* @brief Retourne le vecteur le plus petit entre les deux passés en argument
|
||||
* @param[in] p1 : Premier vecteur
|
||||
* @param[in] p2 : Second vecteur
|
||||
* @fn static Vec2D min(const Vec2D& p1, const Vec2D& p2);
|
||||
*/
|
||||
static Vec2D min(const Vec2D& p1, const Vec2D& p2);
|
||||
|
||||
/**
|
||||
* @brief Retourne vrai si le premier vecteur est le plus petit des deux
|
||||
* @param[in] p1 : Premier vecteur
|
||||
* @param[in] p2 : Second vecteur
|
||||
* @fn static bool minf(const Vec2D& p1, const Vec2D& p2);
|
||||
*/
|
||||
static bool minf(const Vec2D& p1, const Vec2D& p2);
|
||||
|
||||
/**
|
||||
* @brief Retourne vrai si le vecteur actuel est compris entre deux vecteurs formant un rectangle
|
||||
* @param[in] firstCorner : Premier vecteur
|
||||
* @param[in] secondCorner : Second vecteur
|
||||
* @fn bool isColliding(Vec2D firstCorner, Vec2D secondCorner) const;
|
||||
*/
|
||||
bool isColliding(Vec2D firstCorner, Vec2D secondCorner) const;
|
||||
|
||||
/**
|
||||
* @brief Calcule la magnitude de ce vecteur
|
||||
* @return Magnitude du vecteur
|
||||
* @fn double computeMagnitude() const;
|
||||
*/
|
||||
double computeMagnitude() const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position X (abscisse)
|
||||
* @return Une référence constante vers m_x
|
||||
* @fn int getX() const;
|
||||
*/
|
||||
int getX() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position X (abscisse)
|
||||
* @param[in] x : Nouvelle position X
|
||||
* @fn void setX(int x);
|
||||
*/
|
||||
void setX(int x);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position Y (ordonnée)
|
||||
* @return Une référence constante vers m_y
|
||||
* @fn int getY() const;
|
||||
*/
|
||||
int getY() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position Y (ordonnée)
|
||||
* @param[in] y : Nouvelle position Y
|
||||
* @fn void setY(int y);
|
||||
*/
|
||||
void setY(int y);
|
||||
|
||||
protected:
|
||||
virtual std::ostream& _Edit(std::ostream& os = std::cout) const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_x : Position X (abscisse)
|
||||
*/
|
||||
int m_x;
|
||||
|
||||
/**
|
||||
* @brief m_y : Position Y (ordonnée)
|
||||
*/
|
||||
int m_y;
|
||||
|
||||
}; // class Vec2D
|
||||
|
||||
} // namespace nsGraphics
|
||||
|
||||
#endif // VEC2D_H
|
||||
61
lib_headers/mingl/gui/glut_font.h
Normal file
61
lib_headers/mingl/gui/glut_font.h
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file glut_font.h
|
||||
* @brief Classe utilitaire pour utiliser facilement les polices de Glut
|
||||
* @author Alexandre Sollier
|
||||
* @version 1.1
|
||||
* @date 28 décembre 2019
|
||||
*/
|
||||
|
||||
#ifndef GLUT_FONTS_H
|
||||
#define GLUT_FONTS_H
|
||||
|
||||
namespace nsGui
|
||||
{
|
||||
|
||||
/**
|
||||
* @class GlutFont
|
||||
* @brief Classe listant toute les polices rendues disponibles par Glut, a utiliser avec Text
|
||||
*/
|
||||
class GlutFont
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief GlutFonts : Liste de toutes les polices Glut
|
||||
*/
|
||||
enum GlutFonts
|
||||
{
|
||||
BITMAP_8_BY_13, /**< Police 8x13 Bitmap */
|
||||
BITMAP_9_BY_15, /**< Police 9x15 Bitmap */
|
||||
BITMAP_TIMES_ROMAN_10, /**< Police 10px Times New Roman */
|
||||
BITMAP_TIMES_ROMAN_24, /**< Police 24px Times New Roman */
|
||||
BITMAP_HELVETICA_10, /**< Police 10px Helvetica */
|
||||
BITMAP_HELVETICA_12, /**< Police 12px Helvetica */
|
||||
BITMAP_HELVETICA_18, /**< Police 18px Helvetica */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe GlutFont
|
||||
* @param[in] font_ : Police représentée par cette instance
|
||||
* @fn GlutFont(const GlutFonts& font);
|
||||
*/
|
||||
GlutFont(const GlutFonts& font);
|
||||
|
||||
/**
|
||||
* @brief Récupère l'identificateur de police utilisable par Glut
|
||||
* @return Un identificateur de police Glut
|
||||
* @fn void* convertForGlut() const;
|
||||
*/
|
||||
void* convertForGlut() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_font : Police représentée par cette instance
|
||||
*/
|
||||
GlutFonts m_font;
|
||||
|
||||
}; // class GlutFont
|
||||
|
||||
} // namespace nsGui
|
||||
|
||||
#endif // GLUT_FONTS_H
|
||||
127
lib_headers/mingl/gui/sprite.h
Normal file
127
lib_headers/mingl/gui/sprite.h
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
*
|
||||
* @file sprite.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Image pouvant être chargé depuis un fichier
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef DISPLAY_SPRITE_H
|
||||
#define DISPLAY_SPRITE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "../graphics/idrawable.h"
|
||||
#include "../graphics/rgbacolor.h"
|
||||
#include "../graphics/vec2d.h"
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
namespace nsGui {
|
||||
|
||||
/**
|
||||
* @class Sprite
|
||||
* @brief Permet de charger une image depuis un format créé pour l'occasion, le .si2
|
||||
*/
|
||||
class Sprite : public nsGraphics::IDrawable, public nsTransition::ITransitionable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_POSITION, /**< Transition pour la position */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Sprite, charge les données depuis un fichier
|
||||
* @param[in] filename : Chemin d'accès vers le fichier image
|
||||
* @param[in] position : Position du sprite
|
||||
* @fn Sprite(const std::string& filename, const nsGraphics::Vec2D& position = nsGraphics::Vec2D());
|
||||
*/
|
||||
Sprite(const std::string& filename, const nsGraphics::Vec2D& position = nsGraphics::Vec2D());
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Sprite, copie les données depuis un vecteur de pixels
|
||||
* @param[in] pixelData : Vecteur contenant des données sur les pixels
|
||||
* @param[in] rowSize : Nombre de pixels par ligne
|
||||
* @param[in] position : Position du sprite
|
||||
* @fn Sprite(const std::vector<nsGraphics::RGBAcolor>& pixelData, const uint32_t& rowSize, const nsGraphics::Vec2D& position = nsGraphics::Vec2D());
|
||||
*/
|
||||
Sprite(const std::vector<nsGraphics::RGBAcolor>& pixelData, const uint32_t& rowSize, const nsGraphics::Vec2D& position = nsGraphics::Vec2D());
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Récupère le nombre de pixels par ligne
|
||||
* @return Une référence constante vers m_rowSize
|
||||
* @fn const uint32_t& getRowSize() const;
|
||||
*/
|
||||
const uint32_t& getRowSize() const;
|
||||
|
||||
/**
|
||||
* @brief Récupère le vecteur contenant les pixels de l'image
|
||||
* @return Une référence constante vers m_pixelData
|
||||
* @fn const std::vector<nsGraphics::RGBAcolor>& getPixelData() const;
|
||||
*/
|
||||
const std::vector<nsGraphics::RGBAcolor>& getPixelData() const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du sprite
|
||||
* @return Une référence const vers m_position
|
||||
* @fn const nsGraphics::Vec2D& getPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du sprite
|
||||
* @param[in] position : Nouvelle position
|
||||
* @fn void setPosition(const nsGraphics::Vec2D &position);
|
||||
*/
|
||||
void setPosition(const nsGraphics::Vec2D& position);
|
||||
|
||||
/**
|
||||
* @brief Calcule la taille du sprite
|
||||
* @return La taille calculée
|
||||
* @fn Vec2D computeSize() const;
|
||||
*/
|
||||
nsGraphics::Vec2D computeSize() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @struct FileBegin
|
||||
* @brief Décrit le début d'un fichier .si2
|
||||
*/
|
||||
struct FileBegin {
|
||||
uint16_t magic; /**< Le magic number du fichier, doit toujours être "SI" */
|
||||
uint32_t headmagic; /**< Le magic number de la section en-tête, doit toujours être "HEAD" */
|
||||
uint16_t fileVersion; /**< La version du format stockée par le fichier */
|
||||
uint32_t pixelCount; /**< Le nombre de pixels contenus dans la section données */
|
||||
uint32_t rowSize; /**< Le nombre de pixels par ligne */
|
||||
uint32_t datamagic; /**< Le magic number de la section données, doit toujours être "DATA" */
|
||||
} __attribute__((packed));
|
||||
|
||||
/**
|
||||
* @brief m_position : Position de ce Sprite
|
||||
*/
|
||||
nsGraphics::Vec2D m_position;
|
||||
|
||||
/**
|
||||
* @brief m_rowSize : Nombre de pixel par ligne
|
||||
*/
|
||||
uint32_t m_rowSize;
|
||||
|
||||
/**
|
||||
* @brief m_pixelData : Vecteur contenant tout les pixels composant l'image
|
||||
*/
|
||||
std::vector<nsGraphics::RGBAcolor> m_pixelData;
|
||||
}; // class Sprite
|
||||
|
||||
} // namespace nsGui
|
||||
|
||||
#endif // DISPLAY_SPRITE_H
|
||||
224
lib_headers/mingl/gui/text.h
Normal file
224
lib_headers/mingl/gui/text.h
Normal file
@ -0,0 +1,224 @@
|
||||
/**
|
||||
*
|
||||
* @file text.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Du texte
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
|
||||
#include "glut_font.h"
|
||||
#include "../graphics/idrawable.h"
|
||||
#include "../graphics/rgbacolor.h"
|
||||
#include "../graphics/vec2d.h"
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
/**
|
||||
* @namespace nsGui
|
||||
* @brief Espace de nom pour des éléments d'interface complexes
|
||||
*/
|
||||
namespace nsGui {
|
||||
|
||||
/**
|
||||
* @class Text
|
||||
* @brief Gère l'affichage d'un texte
|
||||
*/
|
||||
class Text : public nsGraphics::IDrawable, public nsTransition::ITransitionable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_COLOR_RGB, /**< Transition pour la couleur RGB */
|
||||
TRANSITION_COLOR_ALPHA, /**< Transition pour la transparence */
|
||||
TRANSITION_POSITION, /**< Transition pour la position */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief VerticalAlignment : Liste de tout les alignements verticaux supportés
|
||||
*/
|
||||
enum VerticalAlignment {
|
||||
ALIGNV_TOP, /**< Le texte sera aligné verticallement en haut */
|
||||
ALIGNV_CENTER, /**< Le texte sera aligné verticallement au centre */
|
||||
ALIGNV_BOTTOM, /**< Le texte sera aligné verticallement en bas */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief HorizontalAlignment : Liste de tout les alignements horizontaux supportés
|
||||
*/
|
||||
enum HorizontalAlignment {
|
||||
ALIGNH_LEFT, /**< Le texte sera aligné horizontalement a gauche */
|
||||
ALIGNH_CENTER, /**< Le texte sera aligné horizontalement au centre */
|
||||
ALIGNH_RIGHT, /**< Le texte sera aligné horizontalement a droite */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Text
|
||||
* @param[in] position : Position du texte
|
||||
* @param[in] content : Contenu du texte
|
||||
* @param[in] textColor : Couleur du texte
|
||||
* @param[in] textFont : Police du texte (8x13 Bitmap par défaut)
|
||||
* @param[in] horizontalAlignment : Alignement horizontal du texte (Alignement a gauche par défaut)
|
||||
* @param[in] verticalAlignment : Alignement vertical du texte (Alignement en bas par défaut)
|
||||
* @fn Text(const nsGraphics::Vec2D &position, const std::string &content,
|
||||
const nsGraphics::RGBAcolor &textColor, const GlutFont::GlutFonts &textFont = GlutFont::GlutFonts::BITMAP_8_BY_13,
|
||||
const HorizontalAlignment &horizontalAlignment = ALIGNH_LEFT,
|
||||
const VerticalAlignment &verticalAlignment = ALIGNV_BOTTOM);
|
||||
*/
|
||||
Text(const nsGraphics::Vec2D &position, const std::string &content,
|
||||
const nsGraphics::RGBAcolor &textColor, const GlutFont::GlutFonts &textFont = GlutFont::GlutFonts::BITMAP_8_BY_13,
|
||||
const HorizontalAlignment &horizontalAlignment = ALIGNH_LEFT,
|
||||
const VerticalAlignment &verticalAlignment = ALIGNV_BOTTOM);
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Calcule la largeur de ce texte
|
||||
* @return La largeur du texte
|
||||
* @fn int computeWidth() const;
|
||||
*/
|
||||
int computeWidth() const;
|
||||
|
||||
/**
|
||||
* @brief Calcule la hauteur de ce texte
|
||||
* @return La hauteur du texte
|
||||
* @fn int computeHeight() const;
|
||||
*/
|
||||
int computeHeight() const;
|
||||
|
||||
/**
|
||||
* @brief Calcule la position visible du texte, calculée avec l'alignement vertical et horizontal
|
||||
* @return La position visible, en haut a gauche
|
||||
* @fn nsGraphics::Vec2D computeVisiblePosition() const;
|
||||
*/
|
||||
nsGraphics::Vec2D computeVisiblePosition() const;
|
||||
|
||||
/**
|
||||
* @brief Calcule la position de fin visible du texte, calculée avec l'alignement vertical et horizontal
|
||||
* @return La position visible, en bas a droite
|
||||
* @fn nsGraphics::Vec2D computeVisibleEndPosition() const;
|
||||
*/
|
||||
nsGraphics::Vec2D computeVisibleEndPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Récupère le contenu du texte
|
||||
* @return Une référence constante vers m_content
|
||||
* @fn const std::string& getContent() const;
|
||||
*/
|
||||
const std::string& getContent() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau contenu du texte
|
||||
* @param[in] content : Nouveau contenu
|
||||
* @fn void setContent(const std::string &content);
|
||||
*/
|
||||
void setContent(const std::string &content);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du texte
|
||||
* @fn const nsGraphics::Vec2D& getPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du texte
|
||||
* @param[in] position : Nouvelle position
|
||||
* @fn void setPosition(const nsGraphics::Vec2D &position);
|
||||
*/
|
||||
void setPosition(const nsGraphics::Vec2D &position);
|
||||
|
||||
/**
|
||||
* @brief Récupère la couleur du texte
|
||||
* @fn const nsGraphics::RGBAcolor& getTextColor() const;
|
||||
*/
|
||||
const nsGraphics::RGBAcolor& getTextColor() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle couleur du texte
|
||||
* @param[in] textColor : Nouvelle couleur
|
||||
* @fn void setTextColor(const nsGraphics::RGBAcolor &textColor);
|
||||
*/
|
||||
void setTextColor(const nsGraphics::RGBAcolor &textColor);
|
||||
|
||||
/**
|
||||
* @brief Récupère la police du texte
|
||||
* @fn const GlutFont& getTextFont() const;
|
||||
*/
|
||||
const GlutFont& getTextFont() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle police du texte
|
||||
* @param[in] textFont : Nouvelle police
|
||||
* @fn void setTextFont(const GlutFont &textFont);
|
||||
*/
|
||||
void setTextFont(const GlutFont &textFont);
|
||||
|
||||
/**
|
||||
* @brief Récupère l'alignement horizontal du texte
|
||||
* @fn HorizontalAlignment getHorizontalAlignment() const;
|
||||
*/
|
||||
HorizontalAlignment getHorizontalAlignment() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouvel alignement horizontal du texte
|
||||
* @param[in] horizontalAlignment : Nouvel alignement horizontal
|
||||
* @fn void setHorizontalAlignment(const HorizontalAlignment &horizontalAlignment);
|
||||
*/
|
||||
void setHorizontalAlignment(const HorizontalAlignment &horizontalAlignment);
|
||||
|
||||
/**
|
||||
* @brief Récupère l'alignement vertical du texte
|
||||
* @fn VerticalAlignment getVerticalAlignment() const;
|
||||
*/
|
||||
VerticalAlignment getVerticalAlignment() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouvel alignement vertical du texte
|
||||
* @param[in] verticalAlignment : Nouvel alignement vertical
|
||||
* @fn void setVerticalAlignment(const VerticalAlignment &verticalAlignment);
|
||||
*/
|
||||
void setVerticalAlignment(const VerticalAlignment &verticalAlignment);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_position : Position du texte
|
||||
*/
|
||||
nsGraphics::Vec2D m_position;
|
||||
|
||||
/**
|
||||
* @brief m_content : Contenu du texte
|
||||
*/
|
||||
std::string m_content;
|
||||
|
||||
/**
|
||||
* @brief m_textColor : Couleur du texte
|
||||
*/
|
||||
nsGraphics::RGBAcolor m_textColor;
|
||||
|
||||
/**
|
||||
* @brief m_textFont : Police du texte
|
||||
*/
|
||||
GlutFont m_textFont;
|
||||
|
||||
/**
|
||||
* @brief m_horizontalAlignment : Alignement horizontal du texte
|
||||
*/
|
||||
HorizontalAlignment m_horizontalAlignment;
|
||||
|
||||
/**
|
||||
* @brief m_verticalAlignment : Alignement vertical du texte
|
||||
*/
|
||||
VerticalAlignment m_verticalAlignment;
|
||||
}; // class Text
|
||||
|
||||
} // namespace nsGui
|
||||
|
||||
#endif // TEXT_H
|
||||
19
lib_headers/mingl/macros.h
Normal file
19
lib_headers/mingl/macros.h
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
*
|
||||
* @file macros.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Macros utiles
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef MACROS_H
|
||||
#define MACROS_H
|
||||
|
||||
/**
|
||||
* @brief Une macro permettant de marquer explicitement un paramètre de fonction comme étant inutilisé
|
||||
*/
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#endif // MACROS_H
|
||||
307
lib_headers/mingl/mingl.h
Executable file
307
lib_headers/mingl/mingl.h
Executable file
@ -0,0 +1,307 @@
|
||||
/**
|
||||
*
|
||||
* @file mingl.h
|
||||
* @author Alexandre Sollier, Clément Mathieu--Drif, Alain Casali
|
||||
* @date Janvier 2020
|
||||
* @version 2.0
|
||||
* @brief La bête
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef MINGL_H
|
||||
#define MINGL_H
|
||||
|
||||
#include <map>
|
||||
#include <memory> // shared_ptr
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
|
||||
#include "graphics/idrawable.h"
|
||||
#include "graphics/rgbacolor.h"
|
||||
#include "graphics/vec2d.h"
|
||||
|
||||
#include "event/event_manager.h"
|
||||
|
||||
/**
|
||||
* @brief Classe de base de minGL 2
|
||||
*/
|
||||
|
||||
// Pour les polices et l'affichage des chaines de caractères, voir: https://www.opengl.org/resources/libraries/glut/spec3/node76.html
|
||||
|
||||
class MinGL
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief KeyType_t : Représente une touche du clavier
|
||||
* @details C'est une paire de nombre entier naturel et booléen <br>
|
||||
* <ul><li> L'entier naturel représente le caractère pour une touche non spéciale,
|
||||
* ou l'identifiant de touche pour une touche spéciale
|
||||
* (<a href="https://www.opengl.org/resources/libraries/glut/spec3/node54.html">Voir ici</a> pour les identifiants). </li>
|
||||
* <li> Le booléen indique si la touche est spéciale ou non.</li></ul>
|
||||
*
|
||||
*/
|
||||
typedef std::pair<unsigned, bool> KeyType_t; // cle, spécial
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief KeyMap_t : Map représentant des touches et leurs état (pressée ou non).
|
||||
* @details La clé de cette map est un @ref KeyType_t représentant une touche, et la valeur est son état.
|
||||
*
|
||||
*/
|
||||
typedef std::map<KeyType_t, bool> KeyMap_t;
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe MinGL
|
||||
* @param[in] name : Nom de la fenêtre
|
||||
* @param[in] windowSize : Taille de la fenêtre
|
||||
* @param[in] windowPosition : Position de la fenêtre
|
||||
* @param[in] backgroundColor : Couleur de fond de la fenêtre
|
||||
* @fn MinGL(const std::string& name, const nsGraphics::Vec2D& windowSize = nsGraphics::Vec2D(640, 480),
|
||||
* const nsGraphics::Vec2D& windowPosition = nsGraphics::Vec2D(128, 128),
|
||||
* const nsGraphics::RGBAcolor& backgroundColor = nsGraphics::KWhite);
|
||||
*/
|
||||
MinGL(const std::string& name, const nsGraphics::Vec2D& windowSize = nsGraphics::Vec2D(640, 480),
|
||||
const nsGraphics::Vec2D& windowPosition = nsGraphics::Vec2D(128, 128),
|
||||
const nsGraphics::RGBAcolor& backgroundColor = nsGraphics::KWhite);
|
||||
|
||||
/**
|
||||
* @brief Destructeur de la classe MinGL
|
||||
* @fn ~MinGL();
|
||||
*/
|
||||
~MinGL();
|
||||
|
||||
/**
|
||||
* @brief Initialise la bibliothèque freeglut
|
||||
* @fn static void initGlut()
|
||||
*/
|
||||
static void initGlut()
|
||||
{
|
||||
int tmp = 0;
|
||||
glutInit(&tmp, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialise minGL et ouvre la fenêtre
|
||||
* @fn void initGraphic();
|
||||
*/
|
||||
void initGraphic();
|
||||
|
||||
/**
|
||||
* @brief Ferme la fenêtre et minGL proprement
|
||||
* @fn void stopGraphic();
|
||||
*/
|
||||
void stopGraphic();
|
||||
|
||||
/**
|
||||
* @brief Renvoie l'état d'une touche du clavier (pressée ou non)
|
||||
* @param[in] key : Touche du clavier a vérifier
|
||||
* @fn bool isPressed(const KeyType_t& key);
|
||||
*/
|
||||
bool isPressed(const KeyType_t& key);
|
||||
|
||||
/**
|
||||
* @brief Force une touche a être relâchée
|
||||
* @param[in] key : Touche du clavier a relâcher
|
||||
* @fn void resetKey(const KeyType_t& key);
|
||||
*/
|
||||
void resetKey(const KeyType_t& key);
|
||||
|
||||
/**
|
||||
* @brief Préviens minGL que la frame est terminée
|
||||
* @fn void finishFrame();
|
||||
*/
|
||||
void finishFrame();
|
||||
|
||||
/**
|
||||
* @brief Efface l'écran avec la couleur de fond spécifiée
|
||||
* @fn void clearScreen();
|
||||
*/
|
||||
void clearScreen();
|
||||
|
||||
/**
|
||||
* @brief Récupère le gestionnaire d'évènements minGL
|
||||
* @fn nsEvent::EventManager& getEventManager();
|
||||
*/
|
||||
nsEvent::EventManager& getEventManager();
|
||||
|
||||
/**
|
||||
* @brief Récupère la couleur de fond de la fenêtre
|
||||
* @fn const nsGraphics::RGBAcolor& getBackgroundColor() const;
|
||||
*/
|
||||
const nsGraphics::RGBAcolor& getBackgroundColor() const;
|
||||
|
||||
/**
|
||||
* @brief Règle la couleur de fond de la fenêtre
|
||||
* @fn void setBackgroundColor(const nsGraphics::RGBAcolor& backgroundColor);
|
||||
*/
|
||||
void setBackgroundColor(const nsGraphics::RGBAcolor& backgroundColor);
|
||||
|
||||
/**
|
||||
* @brief Récupère la taille de la fenêtre
|
||||
* @fn nsGraphics::Vec2D getWindowSize() const;
|
||||
*/
|
||||
nsGraphics::Vec2D getWindowSize() const;
|
||||
|
||||
/**
|
||||
* @brief Règle la taille de la fenêtre
|
||||
* @param[in] windowSize : Nouvelle taille
|
||||
* @fn void setWindowSize(const nsGraphics::Vec2D& windowSize);
|
||||
*/
|
||||
void setWindowSize(const nsGraphics::Vec2D& windowSize);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position de la fenêtre
|
||||
* @fn nsGraphics::Vec2D getWindowPosition() const;
|
||||
*/
|
||||
nsGraphics::Vec2D getWindowPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Règle la position de la fenêtre
|
||||
* @param[in] windowPosition : Nouvelle position
|
||||
* @fn void setWindowPosition(const nsGraphics::Vec2D &windowPosition);
|
||||
*/
|
||||
void setWindowPosition(const nsGraphics::Vec2D &windowPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère le nom de la fenêtre
|
||||
* @fn const std::string& getWindowName() const;
|
||||
*/
|
||||
const std::string& getWindowName() const;
|
||||
|
||||
/**
|
||||
* @brief Règle le nom de la fenêtre
|
||||
* @param[in] windowName : Nouveau nom
|
||||
* @fn void setWindowName(const std::string &windowName);
|
||||
*/
|
||||
void setWindowName(const std::string &windowName);
|
||||
|
||||
/**
|
||||
* @brief Retourne si la fenêtre est ouverte
|
||||
* @fn bool isOpen() const;
|
||||
*/
|
||||
bool isOpen() const;
|
||||
|
||||
private:
|
||||
// Les données membres en tant que tel
|
||||
|
||||
/**
|
||||
* @brief m_windowName : Nom de la fenêtre
|
||||
*/
|
||||
std::string m_windowName;
|
||||
|
||||
/**
|
||||
* @brief m_bgColor : Couleur de fond de la fenêtre
|
||||
*/
|
||||
nsGraphics::RGBAcolor m_bgColor;
|
||||
|
||||
/**
|
||||
* @brief m_keyboardMap : Map de l'état des touches du clavier
|
||||
*/
|
||||
KeyMap_t m_keyboardMap;
|
||||
|
||||
/**
|
||||
* @brief m_glutWindowId : Identifiant de la fenêtre freeglut
|
||||
*/
|
||||
short m_glutWindowId = 0;
|
||||
|
||||
/**
|
||||
* @brief m_eventManager : Gestionnaire d'évènements
|
||||
*/
|
||||
nsEvent::EventManager m_eventManager;
|
||||
|
||||
/**
|
||||
* @brief m_windowIsOpen : Etat de la fenêtre
|
||||
*/
|
||||
bool m_windowIsOpen;
|
||||
|
||||
// Les handlers
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node48.html">glutReshapeFunc</a>
|
||||
* @param[in] h : Nouvelle hauteur de la fenêtre
|
||||
* @param[in] w : Nouvelle largeur de la fenêtre
|
||||
* @fn void callReshape(int h, int w);
|
||||
*/
|
||||
void callReshape(int h, int w);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node46.html">glutDisplayFunc</a>
|
||||
* @fn void callDisplay();
|
||||
*/
|
||||
void callDisplay();
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node50.html">glutMouseFunc</a>
|
||||
* @param[in] button : Bouton de la souris qui a généré l'évènement
|
||||
* @param[in] state : Nouvel état du bouton
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callMouse(int button, int state, int x = 0, int y = 0);
|
||||
*/
|
||||
void callMouse(int button, int state, int x = 0, int y = 0);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node51.html">glutMotionFunc</a>
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callMotion(int x, int y);
|
||||
*/
|
||||
void callMotion(int x, int y);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node51.html">glutPassiveMotionFunc</a>
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callPassiveMotion(int x, int y);
|
||||
*/
|
||||
void callPassiveMotion(int x, int y);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="https://www.opengl.org/resources/libraries/glut/spec3/node49.html">glutKeyboardFunc</a>
|
||||
* @param[in] key : Touche qui a été pressée
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callKeyboard(unsigned char key, int x = 0, int y = 0);
|
||||
*/
|
||||
void callKeyboard(unsigned char key, int x = 0, int y = 0);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="http://freeglut.sourceforge.net/docs/api.php#WindowCallback">glutKeyboardUpFunc</a>
|
||||
* @param[in] key : Touche qui a été relâchée
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callKeyboardUp(unsigned char key, int x = 0, int y = 0);
|
||||
*/
|
||||
void callKeyboardUp(unsigned char key, int x = 0, int y = 0);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="http://freeglut.sourceforge.net/docs/api.php#WindowCallback">glutSpecialFunc</a>
|
||||
* @param[in] key : Touche spéciale qui a été pressée
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callKeyboardSpecial(int key, int x = 0, int y = 0);
|
||||
*/
|
||||
void callKeyboardSpecial(int key, int x = 0, int y = 0);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="http://freeglut.sourceforge.net/docs/api.php#WindowCallback">glutSpecialUpFunc</a>
|
||||
* @param[in] key : Touche spéciale qui a été relâchée
|
||||
* @param[in] x : Coordonnée X du curseur
|
||||
* @param[in] y : Coordonnée Y du curseur
|
||||
* @fn void callKeyboardUpSpecial(int key, int x = 0, int y = 0);
|
||||
*/
|
||||
void callKeyboardUpSpecial(int key, int x = 0, int y = 0);
|
||||
|
||||
/**
|
||||
* @brief Handler lié a <a href="http://freeglut.sourceforge.net/docs/api.php#WindowCallback">glutCloseFunc</a>
|
||||
* @fn void callClose();
|
||||
*/
|
||||
void callClose();
|
||||
|
||||
}; // class MinGL
|
||||
|
||||
#endif // MINGL_H
|
||||
117
lib_headers/mingl/shape/circle.h
Executable file
117
lib_headers/mingl/shape/circle.h
Executable file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
*
|
||||
* @file circle.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Représente un cercle
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef CIRCLE_H
|
||||
#define CIRCLE_H
|
||||
|
||||
#include "shape.h"
|
||||
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
namespace nsShape
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Circle
|
||||
* @brief Classe représentant un cercle
|
||||
*/
|
||||
class Circle : public Shape, public nsTransition::ITransitionable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_FILL_COLOR_RGB, /**< Transition pour la couleur de remplissage */
|
||||
TRANSITION_FILL_COLOR_ALPHA, /**< Transition pour la transparence de remplissage */
|
||||
TRANSITION_BORDER_COLOR_RGB, /**< Transition pour la couleur de bord */
|
||||
TRANSITION_BORDER_COLOR_ALPHA, /**< Transition pour la transparence de bord */
|
||||
TRANSITION_POSITION, /**< Transition pour la position */
|
||||
TRANSITION_RADIUS, /**< Transition pour le rayon */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Circle
|
||||
* @param[in] firstPosition : Position du centre
|
||||
* @param[in] radius : Rayon du cercle
|
||||
* @param[in] fillColor : Couleur de remplissage
|
||||
* @param[in] borderColor : Couleur de bord
|
||||
* @fn Circle(const nsGraphics::Vec2D& position, const unsigned& radius, const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
*/
|
||||
Circle(const nsGraphics::Vec2D& position, const unsigned& radius, const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe Circle
|
||||
* @fn virtual ~Circle() override = default;
|
||||
*/
|
||||
virtual ~Circle() override = default;
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de décalage
|
||||
* @param[in] position : Position a additionner
|
||||
* @fn Circle operator+(const nsGraphics::Vec2D& position) const
|
||||
*/
|
||||
Circle operator+(const nsGraphics::Vec2D& getPosition) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de réduction
|
||||
* @param[in] f : Nombre avec lequel multiplier la position actuelle
|
||||
* @fn Circle operator*(const float& f) const
|
||||
*/
|
||||
Circle operator*(const float& f) const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du cercle
|
||||
* @fn const nsGraphics::Vec2D& getPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du cercle
|
||||
* @param[in] position : Nouvelle position
|
||||
* @fn void setPosition(const nsGraphics::Vec2D &position);
|
||||
*/
|
||||
void setPosition(const nsGraphics::Vec2D &position);
|
||||
|
||||
/**
|
||||
* @brief Récupère le rayon du cercle
|
||||
* @fn unsigned getRadius() const;
|
||||
*/
|
||||
unsigned getRadius() const;
|
||||
|
||||
/**
|
||||
* @brief Définit le nouveau rayon du cercle
|
||||
* @param[in] radius : Nouveau rayon
|
||||
* @fn void setRadius(const unsigned &radius);
|
||||
*/
|
||||
void setRadius(const unsigned &radius);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_position : Position du centre
|
||||
*/
|
||||
nsGraphics::Vec2D m_position;
|
||||
|
||||
/**
|
||||
* @brief m_radius : Rayon du cercle
|
||||
*/
|
||||
unsigned m_radius;
|
||||
|
||||
}; // class Circle
|
||||
|
||||
} // namespace nsShape
|
||||
|
||||
#endif // CIRCLE_H
|
||||
136
lib_headers/mingl/shape/line.h
Executable file
136
lib_headers/mingl/shape/line.h
Executable file
@ -0,0 +1,136 @@
|
||||
/**
|
||||
*
|
||||
* @file line.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Représente une ligne
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef LINE_H
|
||||
#define LINE_H
|
||||
|
||||
#include "shape.h"
|
||||
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
namespace nsShape
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Line
|
||||
* @brief Classe représentant une ligne
|
||||
*/
|
||||
class Line : public Shape, public nsTransition::ITransitionable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_FILL_COLOR_RGB, /**< Transition pour la couleur de remplissage */
|
||||
TRANSITION_FILL_COLOR_ALPHA, /**< Transition pour la transparence de remplissage */
|
||||
TRANSITION_BORDER_COLOR_RGB, /**< Transition pour la couleur de bord */
|
||||
TRANSITION_BORDER_COLOR_ALPHA, /**< Transition pour la transparence de bord */
|
||||
TRANSITION_FIRST_POSITION, /**< Transition pour la position du premier sommet */
|
||||
TRANSITION_SECOND_POSITION, /**< Transition pour la position du second sommet */
|
||||
TRANSITION_LINE_WIDTH, /**< Transition pour l'épaisseur de la ligne */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Line
|
||||
* @param[in] firstPosition : Position du premier sommet
|
||||
* @param[in] secondPosition : Position du second sommet
|
||||
* @param[in] fillColor : Couleur de remplissage
|
||||
* @param[in] lineWidth : Epaisseur de la ligne
|
||||
* @fn Line(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::RGBAcolor& fillColor, const float& lineWidth = 1.f);
|
||||
*/
|
||||
Line(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::RGBAcolor& fillColor, const float& lineWidth = 1.f);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe Line
|
||||
* @fn virtual ~Line() override = default;
|
||||
*/
|
||||
virtual ~Line() override = default;
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de décalage
|
||||
* @param[in] position : Position a additionner
|
||||
* @fn Line operator+(const nsGraphics::Vec2D& position) const
|
||||
*/
|
||||
Line operator+(const nsGraphics::Vec2D& position) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de réduction
|
||||
* @param[in] f : Nombre avec lequel multiplier la position actuelle
|
||||
* @fn Line operator*(const float& f) const
|
||||
*/
|
||||
Line operator*(const float& f) const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du premier sommet de la ligne
|
||||
* @fn const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du premier sommet de la ligne
|
||||
* @param[in] firstPosition : Nouvelle position du premier sommet
|
||||
* @fn void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
*/
|
||||
void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du second sommet de la ligne
|
||||
* @fn const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du second sommet de la ligne
|
||||
* @param[in] secondPosition : Nouvelle position du second sommet
|
||||
* @fn void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
*/
|
||||
void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère l'épaisseur de la ligne
|
||||
* @fn float getLineWidth() const;
|
||||
*/
|
||||
float getLineWidth() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle épaisseur de la ligne
|
||||
* @param[in] lineWidth : Nouvelle épaisseur
|
||||
* @fn void setLineWidth(float lineWidth);
|
||||
*/
|
||||
void setLineWidth(float lineWidth);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_firstPosition : Position du premier sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_firstPosition;
|
||||
|
||||
/**
|
||||
* @brief m_position : Position du second sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_secondPosition;
|
||||
|
||||
/**
|
||||
* @brief m_position : Epaisseur de la ligne
|
||||
*/
|
||||
float m_lineWidth;
|
||||
|
||||
}; // class Line
|
||||
|
||||
} // namespace nsShape
|
||||
|
||||
#endif // LINE_H
|
||||
132
lib_headers/mingl/shape/rectangle.h
Executable file
132
lib_headers/mingl/shape/rectangle.h
Executable file
@ -0,0 +1,132 @@
|
||||
/**
|
||||
*
|
||||
* @file rectangle.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Représente un rectangle
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef RECTANGLE_H
|
||||
#define RECTANGLE_H
|
||||
|
||||
#include "shape.h"
|
||||
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
namespace nsShape
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Rectangle
|
||||
* @brief Classe représentant un rectangle
|
||||
*/
|
||||
class Rectangle : public Shape, public nsTransition::ITransitionable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_FILL_COLOR_RGB, /**< Transition pour la couleur de remplissage */
|
||||
TRANSITION_FILL_COLOR_ALPHA, /**< Transition pour la transparence de remplissage */
|
||||
TRANSITION_BORDER_COLOR_RGB, /**< Transition pour la couleur de bord */
|
||||
TRANSITION_BORDER_COLOR_ALPHA, /**< Transition pour la transparence de bord */
|
||||
TRANSITION_FIRST_POSITION, /**< Transition pour la position du coin haut-gauche */
|
||||
TRANSITION_SECOND_POSITION, /**< Transition pour la position du coin bas-droit */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Rectangle
|
||||
* @param[in] firstPosition : Position du coin haut-gauche
|
||||
* @param[in] secondPosition : Position du coin bas-droit
|
||||
* @param[in] fillColor : Couleur de remplissage
|
||||
* @param[in] borderColor : Couleur de bord
|
||||
* @fn Rectangle(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::RGBAcolor& fillColor,
|
||||
const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
*/
|
||||
Rectangle(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::RGBAcolor& fillColor,
|
||||
const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Rectangle
|
||||
* @param[in] position : Position du coin haut-gauche
|
||||
* @param[in] width : Largeur du rectangle
|
||||
* @param[in] height : Hauteur du rectangle
|
||||
* @param[in] fillColor : Couleur de remplissage
|
||||
* @param[in] borderColor : Couleur de bord
|
||||
* @fn Rectangle(const nsGraphics::Vec2D& position, const unsigned& width, const unsigned& height, const nsGraphics::RGBAcolor& fillColor,
|
||||
const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
*/
|
||||
Rectangle(const nsGraphics::Vec2D& position, const unsigned& width, const unsigned& height, const nsGraphics::RGBAcolor& fillColor,
|
||||
const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe Line
|
||||
* @fn virtual ~Line() override = default;
|
||||
*/
|
||||
virtual ~Rectangle() override = default;
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de décalage
|
||||
* @param[in] position : Position a additionner
|
||||
* @fn Rectangle operator+(const nsGraphics::Vec2D& position) const
|
||||
*/
|
||||
Rectangle operator+(const nsGraphics::Vec2D& position) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de réduction
|
||||
* @param[in] f : Nombre avec lequel multiplier la position actuelle
|
||||
* @fn Rectangle operator*(const float& f) const
|
||||
*/
|
||||
Rectangle operator*(const float& f) const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du coin haut-gauche du rectangle
|
||||
* @fn const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du coin haut-gauche du rectangle
|
||||
* @param[in] firstPosition : Nouvelle position du coin haut-gauche
|
||||
* @fn void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
*/
|
||||
void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du coin bas-droit du rectangle
|
||||
* @fn const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du coin bas-droit du rectangle
|
||||
* @param[in] secondPosition : Nouvelle position du coin bas-droit
|
||||
* @fn void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
*/
|
||||
void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_firstPosition : Position du premier sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_firstPosition;
|
||||
|
||||
/**
|
||||
* @brief m_secondPosition : Position du second sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_secondPosition;
|
||||
|
||||
}; // class Rectangle
|
||||
|
||||
} // namespace nsShape
|
||||
|
||||
#endif // RECTANGLE_H
|
||||
86
lib_headers/mingl/shape/shape.h
Normal file
86
lib_headers/mingl/shape/shape.h
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
*
|
||||
* @file shape.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Représente une forme
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef FIG2_H
|
||||
#define FIG2_H
|
||||
|
||||
#include "../graphics/idrawable.h"
|
||||
#include "../graphics/rgbacolor.h"
|
||||
#include "../graphics/vec2d.h"
|
||||
|
||||
/**
|
||||
* @namespace nsShape
|
||||
* @brief Espace de nom pour différentes formes
|
||||
*/
|
||||
namespace nsShape
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Shape
|
||||
* @brief Classe de base pour une forme
|
||||
*/
|
||||
class Shape: public nsGraphics::IDrawable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructeur pour la classe Shape
|
||||
* @param[in] fillColor : Couleur de remplissage de la forme
|
||||
* @param[in] borderColor : Couleur de bord de la forme
|
||||
* @fn Shape(const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor);
|
||||
*/
|
||||
Shape(const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe Shape
|
||||
* @fn virtual ~Shape() = default;
|
||||
*/
|
||||
virtual ~Shape() = default;
|
||||
|
||||
/**
|
||||
* @brief Retourne la couleur de remplissage
|
||||
* @fn const nsGraphics::RGBAcolor& getFillColor() const;
|
||||
*/
|
||||
const nsGraphics::RGBAcolor& getFillColor() const;
|
||||
|
||||
/**
|
||||
* @brief Règle la couleur de remplissage
|
||||
* @fn cvoid setFillColor(const nsGraphics::RGBAcolor& fillColor);
|
||||
*/
|
||||
void setFillColor(const nsGraphics::RGBAcolor& fillColor);
|
||||
|
||||
/**
|
||||
* @brief Retourne la couleur de bord
|
||||
* @fn const nsGraphics::RGBAcolor& getBorderColor() const;
|
||||
*/
|
||||
const nsGraphics::RGBAcolor& getBorderColor() const;
|
||||
|
||||
/**
|
||||
* @brief Règle la couleur de bord
|
||||
* @fn void setBorderColor(const RGBAcolor& borderColor);
|
||||
*/
|
||||
void setBorderColor(const nsGraphics::RGBAcolor& borderColor);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief m_fillColor : Couleur de remplissage
|
||||
*/
|
||||
nsGraphics::RGBAcolor m_fillColor;
|
||||
|
||||
/**
|
||||
* @brief m_borderColor : Couleur de bord
|
||||
*/
|
||||
nsGraphics::RGBAcolor m_borderColor;
|
||||
|
||||
}; // class Shape
|
||||
|
||||
} // namespace nsShape
|
||||
|
||||
#endif // FIG2_H
|
||||
139
lib_headers/mingl/shape/triangle.h
Executable file
139
lib_headers/mingl/shape/triangle.h
Executable file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
*
|
||||
* @file triangle.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Représente un triangle
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TRIANGLE_H
|
||||
#define TRIANGLE_H
|
||||
|
||||
#include "shape.h"
|
||||
|
||||
#include "../transition/itransitionable.h"
|
||||
|
||||
namespace nsShape
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Triangle
|
||||
* @brief Classe représentant un triangle
|
||||
*/
|
||||
class Triangle : public Shape, public nsTransition::ITransitionable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionIds : Liste de toutes les transitions que cet élément peut exécuter
|
||||
*/
|
||||
enum TransitionIds {
|
||||
TRANSITION_FILL_COLOR_RGB, /**< Transition pour la couleur de remplissage */
|
||||
TRANSITION_FILL_COLOR_ALPHA, /**< Transition pour la transparence de remplissage */
|
||||
TRANSITION_BORDER_COLOR_RGB, /**< Transition pour la couleur de bord */
|
||||
TRANSITION_BORDER_COLOR_ALPHA, /**< Transition pour la transparence de bord */
|
||||
TRANSITION_FIRST_POSITION, /**< Transition pour la position du premier sommet */
|
||||
TRANSITION_SECOND_POSITION, /**< Transition pour la position du second sommet */
|
||||
TRANSITION_THIRD_POSITION, /**< Transition pour la position du troisième sommet */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Triangle
|
||||
* @param[in] firstPosition : Position du premier sommet
|
||||
* @param[in] secondPosition : Position du second sommet
|
||||
* @param[in] thirdPosition : Position du troisième sommet
|
||||
* @param[in] fillColor : Couleur de remplissage
|
||||
* @param[in] borderColor : Couleur de bord
|
||||
* @fn Triangle(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::Vec2D& thirdPosition,
|
||||
const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
*/
|
||||
Triangle(const nsGraphics::Vec2D& firstPosition, const nsGraphics::Vec2D& secondPosition, const nsGraphics::Vec2D& thirdPosition,
|
||||
const nsGraphics::RGBAcolor& fillColor, const nsGraphics::RGBAcolor& borderColor = nsGraphics::KTransparent);
|
||||
|
||||
/**
|
||||
* @brief Destructeur virtuel pour la classe Triangle
|
||||
* @fn virtual ~Triangle() override = default;
|
||||
*/
|
||||
virtual ~Triangle() override = default;
|
||||
|
||||
virtual void draw(MinGL& window) const override;
|
||||
|
||||
virtual void getValues(const int &id, std::vector<float> &values) override;
|
||||
virtual void setValues(const int &id, const std::vector<float> &values) override;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de décalage
|
||||
* @param[in] position : Position a additionner
|
||||
* @fn Triangle operator+(const nsGraphics::Vec2D& position) const
|
||||
*/
|
||||
Triangle operator+(const nsGraphics::Vec2D& position) const;
|
||||
|
||||
/**
|
||||
* @brief Opérateur de réduction
|
||||
* @param[in] f : Nombre avec lequel multiplier la position actuelle
|
||||
* @fn Triangle operator*(const float& f) const
|
||||
*/
|
||||
Triangle operator*(const float& f) const;
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du premier sommet du triangle
|
||||
* @fn const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getFirstPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du premier sommet du triangle
|
||||
* @param[in] firstPosition : Nouvelle position du premier sommet
|
||||
* @fn void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
*/
|
||||
void setFirstPosition(const nsGraphics::Vec2D &firstPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du second sommet du triangle
|
||||
* @fn const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getSecondPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du second sommet du triangle
|
||||
* @param[in] secondPosition : Nouvelle position du second sommet
|
||||
* @fn void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
*/
|
||||
void setSecondPosition(const nsGraphics::Vec2D &secondPosition);
|
||||
|
||||
/**
|
||||
* @brief Récupère la position du troisième sommet du triangle
|
||||
* @fn const nsGraphics::Vec2D& getThirdPosition() const;
|
||||
*/
|
||||
const nsGraphics::Vec2D& getThirdPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la nouvelle position du troisième sommet du triangle
|
||||
* @param[in] thirdPosition : Nouvelle position du troisième sommet
|
||||
* @fn void setThirdPosition(const nsGraphics::Vec2D &thirdPosition);
|
||||
*/
|
||||
void setThirdPosition(const nsGraphics::Vec2D &thirdPosition);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_firstPosition : Position du premier sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_firstPosition;
|
||||
|
||||
/**
|
||||
* @brief m_secondPosition : Position du second sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_secondPosition;
|
||||
|
||||
/**
|
||||
* @brief m_thirdPosition : Position du troisième sommet
|
||||
*/
|
||||
nsGraphics::Vec2D m_thirdPosition;
|
||||
|
||||
}; // class Triangle
|
||||
|
||||
} // namespace nsShape
|
||||
|
||||
#endif // TRIANGLE_H
|
||||
72
lib_headers/mingl/tools/ieditable.h
Executable file
72
lib_headers/mingl/tools/ieditable.h
Executable file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
*
|
||||
* @file ieditable.h
|
||||
*
|
||||
* @authors D. Mathieu, M. Laporte
|
||||
*
|
||||
* @date 16/03/2009
|
||||
*
|
||||
* @version V2.0
|
||||
*
|
||||
* @brief declaration de la classe CEditable dans nsUtil
|
||||
*
|
||||
* @version V2.1
|
||||
*
|
||||
* @author Alexandre Sollier
|
||||
*
|
||||
* @brief Ajout de la documentation
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef IEDITABLE_H
|
||||
#define IEDITABLE_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* @namespace nsUtil
|
||||
* @brief Espace de nom pour les utilitaires lambda
|
||||
*/
|
||||
namespace nsUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* @class IEditable
|
||||
* @brief Interface pour un objet injectable
|
||||
*/
|
||||
class IEditable
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Destructeur pour la classe IEditable
|
||||
* @fn virtual ~IEditable() = default;
|
||||
*/
|
||||
virtual ~IEditable() = default;
|
||||
|
||||
/**
|
||||
* @brief Surcharge de l'opérateur d'injection
|
||||
* @param[in] os : Flux dans lequel injecter
|
||||
* @param[in] Obj : Objet a injecter
|
||||
* @fn friend std::ostream& operator<<(std::ostream& os, const IEditable& Obj);
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& os, const IEditable& Obj);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Fonction appelée pour injecter l'objet courant dans un flux
|
||||
* @param[in] os : Flux dans lequel injecter
|
||||
* @fn virtual std::ostream& _Edit(std::ostream& os) const = 0;
|
||||
*/
|
||||
virtual std::ostream& _Edit(std::ostream& os) const = 0;
|
||||
|
||||
}; // class IEditable
|
||||
|
||||
std::ostream& operator<<(std::ostream & os, const IEditable & Obj);
|
||||
|
||||
} // namespace nsUtil
|
||||
|
||||
#include "ieditable.hpp"
|
||||
|
||||
#endif // IEDITABLE_H
|
||||
|
||||
26
lib_headers/mingl/tools/ieditable.hpp
Executable file
26
lib_headers/mingl/tools/ieditable.hpp
Executable file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
*
|
||||
* @file ieditable.hpp
|
||||
*
|
||||
* @authors D. Mathieu, M. Laporte
|
||||
*
|
||||
* @date 17/03/2010
|
||||
*
|
||||
* @version V2.0
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef IEDITABLE_HXX
|
||||
#define IEDITABLE_HXX
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ieditable.h"
|
||||
|
||||
inline std::ostream& nsUtil::operator<<(std::ostream& os, const IEditable& Obj)
|
||||
{
|
||||
return Obj._Edit(os);
|
||||
} // operator<<
|
||||
|
||||
#endif // IEDITABLE_HXX
|
||||
|
||||
33
lib_headers/mingl/tools/ifonctorunaire.hpp
Normal file
33
lib_headers/mingl/tools/ifonctorunaire.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef IFONCTORBINAIRE_HPP
|
||||
#define IFONCTORBINAIRE_HPP
|
||||
|
||||
namespace nsUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* @class IFonctorUnaire
|
||||
* @brief Interface pour un fonctor unaire
|
||||
*/
|
||||
template<typename T1, typename TRes>
|
||||
class IFonctorUnaire
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Destructeur pour la classe IFonctorUnaire
|
||||
* @fn virtual ~IFonctorUnaire() = default;
|
||||
*/
|
||||
virtual ~IFonctorUnaire() = default;
|
||||
|
||||
/**
|
||||
* @brief Surcharge de l'opérateur d'appel
|
||||
* @param[in] in : Premier paramètre
|
||||
* @fn virtual TRes operator()(const T1& in) const = 0;
|
||||
*/
|
||||
virtual TRes operator()(const T1& in) const = 0;
|
||||
|
||||
}; // class IFonctorUnaire
|
||||
|
||||
} // namespace nsUtil
|
||||
|
||||
#endif // IFONCTORBINAIRE_HPP
|
||||
51
lib_headers/mingl/transition/itransitionable.h
Normal file
51
lib_headers/mingl/transition/itransitionable.h
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
*
|
||||
* @file itransitionable.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Interface pour objet "transitionable"
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef ITRANSITIONABLE_H
|
||||
#define ITRANSITIONABLE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace nsTransition
|
||||
{
|
||||
|
||||
/**
|
||||
* @class ITransitionable
|
||||
* @brief Une classe abstraite pour n'importe quelle élément pouvant effectuer une transition entre deux états
|
||||
*/
|
||||
class ITransitionable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Destructeur pour la classe ITransitionable
|
||||
* @fn virtual ~ITransitionable() {}
|
||||
*/
|
||||
virtual ~ITransitionable() {}
|
||||
|
||||
/**
|
||||
* @brief Récupère des valeurs dans un vecteur de float pour l'ID spécifié
|
||||
* @param[in] id: ID des valeurs a récupérer
|
||||
* @param[in, out] values: Vecteur de valeurs a peupler
|
||||
* @fn virtual void getValues(const int& id, std::vector<float>& values);
|
||||
*/
|
||||
virtual void getValues(const int& id, std::vector<float>& values) = 0;
|
||||
|
||||
/**
|
||||
* @brief Définit les nouvelles valeurs pour l'ID spécifié
|
||||
* @param[in] id: ID des valeurs a définir
|
||||
* @param[in] values: Vecteur des nouvelles valeurs a appliquer
|
||||
* @fn virtual void setValues(const int& id, const std::vector<float>& values);
|
||||
*/
|
||||
virtual void setValues(const int& id, const std::vector<float>& values) = 0;
|
||||
}; // class ITransitionable
|
||||
|
||||
} // namespace nsTransition
|
||||
|
||||
#endif // ITRANSITIONABLE_H
|
||||
128
lib_headers/mingl/transition/transition.h
Normal file
128
lib_headers/mingl/transition/transition.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
*
|
||||
* @file transition.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Definition d'une transition
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TRANSITION_H
|
||||
#define TRANSITION_H
|
||||
|
||||
#include "transition_contract.h"
|
||||
|
||||
/**
|
||||
* @namespace nsTransition
|
||||
* @brief Espace de nom pour le moteur de transition et ses composants
|
||||
*/
|
||||
namespace nsTransition
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Transition
|
||||
* @brief Une classe représentant un TransitionContract en cours de lecture
|
||||
*/
|
||||
class Transition : public TransitionContract
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionMode : Liste de tout les modes de fin de la Transition
|
||||
*/
|
||||
enum TransitionFinishModes {
|
||||
FINISH_START, /**< Ce mode de fin met les valeurs de la cible a celles de départ */
|
||||
FINISH_CURRENT, /**< Ce mode de fin ne touche pas aux valeurs actuelles de la cible */
|
||||
FINISH_DESTINATION, /**< Ce mode de fin met les valeurs de la cible a celles d'arrivé */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe Transition
|
||||
* @param[in] contract : Contrat utilisé pour initialiser cette Transition
|
||||
* @fn Transition(const TransitionContract& contract);
|
||||
*/
|
||||
Transition(const TransitionContract& contract);
|
||||
|
||||
/**
|
||||
* @brief Retourne le temps écoulé pour cette Transition
|
||||
* @return Une référence const vers m_elapsed
|
||||
* @fn const SystemDuration_t& getElapsed() const;
|
||||
*/
|
||||
const SystemDuration_t& getElapsed() const;
|
||||
|
||||
/**
|
||||
* @brief Définit un nouveau temps écoulé pour cette Transition,
|
||||
* puis met a jour les valeurs de la cible
|
||||
* @param[in] elapsed : Nouveau temps écoulé
|
||||
* @fn void setElapsed(const SystemDuration_t& elapsed);
|
||||
*/
|
||||
void setElapsed(const SystemDuration_t& elapsed);
|
||||
|
||||
/**
|
||||
* @brief Rajoute une durée au temps écoulé actuel
|
||||
* @param[in] addedTime : Durée a rajouter
|
||||
* @fn void addToElapsed(const SystemDuration_t& addedTime);
|
||||
*/
|
||||
void addToElapsed(const SystemDuration_t& addedTime);
|
||||
|
||||
/**
|
||||
* @brief Indique si cette Transition est en train de se jouer a l'envers
|
||||
* @return Une référence const vers m_reverse
|
||||
* @fn const bool& isReversed() const;
|
||||
*/
|
||||
const bool& isReversed() const;
|
||||
|
||||
/**
|
||||
* @brief Marque cette Transition comme terminée, en utilisant le mode spécifié
|
||||
* @param[in] finishMode : Mode utilisé pour finir cette Transition (Valeurs d'arrivé par défaut)
|
||||
* @fn void finish();
|
||||
*/
|
||||
void finish(const TransitionFinishModes& finishMode = TransitionFinishModes::FINISH_DESTINATION);
|
||||
|
||||
/**
|
||||
* @brief Indique si cette Transition est marquée comme terminée
|
||||
* @return Une référence const vers m_finished
|
||||
* @fn const bool& isFinished() const;
|
||||
*/
|
||||
const bool& isFinished() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_startTime : Stocke le temps du début de cette Transition
|
||||
*/
|
||||
SystemTimePoint_t m_startTime;
|
||||
|
||||
/**
|
||||
* @brief m_elapsed : Stocke le temps écoulé
|
||||
*/
|
||||
SystemDuration_t m_elapsed;
|
||||
|
||||
/**
|
||||
* @brief m_reverse : Flag set si cette Transition se joue a l'envers
|
||||
* i.e. se jouant des valeurs d'arrivé vers celles de départ
|
||||
*/
|
||||
bool m_reverse;
|
||||
|
||||
/**
|
||||
* @brief m_finished : Flag set si cette Transition doit être considérée terminée
|
||||
* Le moteur de transition utilisé doit enlever une telle Transition de sa liste
|
||||
*/
|
||||
bool m_finished;
|
||||
|
||||
/**
|
||||
* @brief Calcule et définit les nouvelles valeurs a la cible,
|
||||
* basé sur le temps écoulé, la durée de la transition et le temps de départ
|
||||
* @fn void updateValues();
|
||||
*/
|
||||
void updateValues();
|
||||
|
||||
/**
|
||||
* @brief Appelé quand cette Transition s'est terminée
|
||||
* @fn void handleEndlife();
|
||||
*/
|
||||
void handleEndlife();
|
||||
}; // class Transition
|
||||
|
||||
} // namespace nsTransition
|
||||
|
||||
#endif // TRANSITION_H
|
||||
158
lib_headers/mingl/transition/transition_contract.h
Normal file
158
lib_headers/mingl/transition/transition_contract.h
Normal file
@ -0,0 +1,158 @@
|
||||
/**
|
||||
*
|
||||
* @file transition_contract.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Création de la transition
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TRANSITION_CONTRACT_H
|
||||
#define TRANSITION_CONTRACT_H
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "itransitionable.h"
|
||||
#include "transition_types.h"
|
||||
|
||||
namespace nsTransition
|
||||
{
|
||||
|
||||
/**
|
||||
* @class TransitionContract
|
||||
* @brief Une classe contenant des paramètres pour créer une transition
|
||||
*/
|
||||
class TransitionContract
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief TransitionMode : Liste de tout les modes de transition
|
||||
*/
|
||||
enum TransitionMode {
|
||||
MODE_FINITE, /**< Ce mode marque la Transition comme terminée une fois achevée */
|
||||
MODE_FINITE_REVERSE, /**< Ce mode va jouer la Transition a l'envers une fois achevée, puis marquer la Transition comme étant terminée */
|
||||
MODE_LOOP, /**< Ce mode va définir les valeurs de départ a la cible une fois la Transition achevée, puis se rejouer en boucle */
|
||||
MODE_LOOP_SMOOTH, /**< Ce mode va jouer la Transition a l'envers une fois achevée, puis se rejouer en boucle */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructeur pour la classe TransitionContract
|
||||
* @param[in, out] target : Une référence vers une classe dérivée d'ITransitionable qui sera la cible
|
||||
* @param[in] id : L'ID de la transition a appliquer
|
||||
* @param[in] duration : La durée de la transition
|
||||
* @param[in] destination : Les valeurs d'arrivée
|
||||
* @param[in] delay : Délai avant que la transition commence (Zéro par défaut)
|
||||
* @param[in] transitionMode : Mode de transition (Transition finie par défaut)
|
||||
* @fn TransitionContract(ITransitionable& target, const int& id,
|
||||
const SystemDuration_t& duration, const std::vector<float>& destination,
|
||||
const SystemDuration_t& delay = std::chrono::seconds::zero(),
|
||||
const TransitionMode& transitionMode = TransitionMode::MODE_FINITE);
|
||||
*/
|
||||
TransitionContract(ITransitionable& target, const int& id,
|
||||
const SystemDuration_t& duration, const std::vector<float>& destination,
|
||||
const SystemDuration_t& delay = std::chrono::seconds::zero(),
|
||||
const TransitionMode& transitionMode = TransitionMode::MODE_FINITE);
|
||||
|
||||
/**
|
||||
* @brief Retourne l'ID de transition, utilisé par la cible pour connaitre les valeurs a utiliser
|
||||
* @return Une référence const vers m_id
|
||||
* @fn const int& getId() const;
|
||||
*/
|
||||
const int& getId() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne la cible de transition
|
||||
* @return Une référence const vers m_target
|
||||
* @fn const ITransitionable& getTarget() const;
|
||||
*/
|
||||
const ITransitionable& getTarget() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne le mode de transition
|
||||
* @return Une référence const vers m_transitionMode
|
||||
* @fn const TransitionMode& getTransitionMode() const;
|
||||
*/
|
||||
const TransitionMode& getTransitionMode() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne les valeurs de départ
|
||||
* @return Une référence const vers m_beginning
|
||||
* @fn const std::vector<float>& getBeginning() const;
|
||||
*/
|
||||
const std::vector<float>& getBeginning() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne les valeurs d'arrivée
|
||||
* @return Une référence const vers m_destination
|
||||
* @fn const std::vector<float>& getDestination() const;
|
||||
*/
|
||||
const std::vector<float>& getDestination() const;
|
||||
|
||||
/**
|
||||
* @brief Retourne la durée de la transition
|
||||
* @return Une référence const vers m_duration
|
||||
* @fn const SystemDuration_t& getDuration() const;
|
||||
*/
|
||||
const SystemDuration_t& getDuration() const;
|
||||
|
||||
/**
|
||||
* @brief Définit la fonction de callback a appeler quand la transition est achevée
|
||||
* @param[in] callback : La fonction a appeler
|
||||
* @fn void setDestinationCallback(const std::function<void()>& callback);
|
||||
*/
|
||||
void setDestinationCallback(const std::function<void()>& callback);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief m_id : L'ID de la transition
|
||||
*
|
||||
* Ceci est seulement utile pour la cible, car lui seul sait a quel ID correspond quelles valeurs.
|
||||
* Ainsi, l'ID n'est jamais utilisée directement par la transition et est seulement passée a la cible.
|
||||
*/
|
||||
const int m_id;
|
||||
|
||||
/**
|
||||
* @brief m_target : Une référence vers une instance d'une classe dérivée d'ITransitionable
|
||||
*
|
||||
* C'est la cible de la transition, sur laquelle vont s'appliquer les modifications de valeurs.
|
||||
*/
|
||||
ITransitionable& m_target;
|
||||
|
||||
/**
|
||||
* @brief m_transitionMode : Le mode de transition
|
||||
*
|
||||
* Pour plus d'informations, voyez les valeurs de l'énumération TransitionMode.
|
||||
*/
|
||||
const TransitionMode m_transitionMode;
|
||||
|
||||
/**
|
||||
* @brief m_beginning : Contient les valeurs de départ
|
||||
*/
|
||||
std::vector<float> m_beginning;
|
||||
|
||||
/**
|
||||
* @brief m_destination : Contient les valeurs d'arrivées
|
||||
*/
|
||||
const std::vector<float> m_destination;
|
||||
|
||||
/**
|
||||
* @brief m_duration : La durée de la transition
|
||||
*/
|
||||
SystemDuration_t m_duration;
|
||||
|
||||
/**
|
||||
* @brief m_delay : Délai a attendre avant que la transition ne démarre
|
||||
*/
|
||||
SystemDuration_t m_delay;
|
||||
|
||||
/**
|
||||
* @brief m_duration : Un pointeur vers la fonction a appeler une fois la transition achevée
|
||||
*/
|
||||
std::function<void()> m_destinationCallback;
|
||||
}; // class TransitionContract
|
||||
|
||||
} // namespace nsTransition
|
||||
|
||||
#endif // TRANSITION_CONTRACT_H
|
||||
76
lib_headers/mingl/transition/transition_engine.h
Normal file
76
lib_headers/mingl/transition/transition_engine.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
*
|
||||
* @file transition_engine.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Gestionnaire de transition de minGL
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TRANSITION_ENGINE_H
|
||||
#define TRANSITION_ENGINE_H
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
#include "transition.h"
|
||||
|
||||
namespace nsTransition
|
||||
{
|
||||
|
||||
/**
|
||||
* @class TransitionEngine
|
||||
* @brief Une classe implémentant un moteur de transition supportant plusieurs transitions a la fois
|
||||
*/
|
||||
class TransitionEngine
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Met a jour toutes les transitions dans la liste
|
||||
* @param[in] delta : Temps que la dernière image a mis pour faire son rendu
|
||||
* @fn void update(const std::chrono::microseconds &delta);
|
||||
*
|
||||
* Cette fonction rajoute la valeur de delta aux temps écoulés des différentes transitions,
|
||||
* et supprime les transitions terminées de la liste.
|
||||
*/
|
||||
void update(const std::chrono::microseconds& delta);
|
||||
|
||||
/**
|
||||
* @brief Démarre un contrat
|
||||
* @param[in] contract : Contrat de transition a démarrer
|
||||
* @fn void startContract(const TransitionContract &contract);
|
||||
*/
|
||||
void startContract(const TransitionContract& contract);
|
||||
|
||||
/**
|
||||
* @brief Termine toutes les transitions de la liste
|
||||
* @param[in] finishMode : finishMode : Mode utilisé pour finir cette Transition (Valeurs d'arrivé par défaut)
|
||||
* @fn void finishEveryTransition();
|
||||
*/
|
||||
void finishEveryTransition(const Transition::TransitionFinishModes& finishMode = Transition::FINISH_DESTINATION);
|
||||
|
||||
/**
|
||||
* @brief Termine toutes les transitions d'une certaine cible de la liste
|
||||
* @param[in] transitionable : La cible où arrêter les transitions
|
||||
* @param[in] finishMode : finishMode : Mode utilisé pour finir cette Transition (Valeurs d'arrivé par défaut)
|
||||
* @fn void finishEveryTransitionOfTarget(const ITransitionable &transitionable);
|
||||
*/
|
||||
void finishEveryTransitionOfTarget(const ITransitionable& transitionable, const Transition::TransitionFinishModes& finishMode = Transition::FINISH_DESTINATION);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief TransitionVector_t : Définition de type représentant une liste de transition
|
||||
*/
|
||||
typedef std::list<Transition> TransitionVector_t;
|
||||
|
||||
/**
|
||||
* @brief m_transitionList : Liste des transitions que ce moteur gère
|
||||
*/
|
||||
TransitionVector_t m_transitionList;
|
||||
}; // class TransitionEngine
|
||||
|
||||
} // namespace nsTransition
|
||||
|
||||
#endif // TRANSITION_ENGINE_H
|
||||
31
lib_headers/mingl/transition/transition_types.h
Normal file
31
lib_headers/mingl/transition/transition_types.h
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
* @file transition_types.h
|
||||
* @author Alexandre Sollier
|
||||
* @date Janvier 2020
|
||||
* @version 1.0
|
||||
* @brief Définit quelques types pour les transitions
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef TRANSITION_TYPES_H
|
||||
#define TRANSITION_TYPES_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace nsTransition
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief SystemDuration_t : Définition de type stockant une durée exprimée en nanosecondes, sous forme de float
|
||||
*/
|
||||
typedef std::chrono::duration<float, std::nano> SystemDuration_t;
|
||||
|
||||
/**
|
||||
* @brief SystemTimePoint_t : Définition de type représentant un point dans le temps basée sur l'horloge système
|
||||
*/
|
||||
typedef std::chrono::time_point<std::chrono::steady_clock, SystemDuration_t> SystemTimePoint_t;
|
||||
|
||||
} // namespace nsTransition
|
||||
|
||||
#endif // TRANSITION_TYPES_H
|
||||
BIN
libmingl.a
Normal file
BIN
libmingl.a
Normal file
Binary file not shown.
6
main.cpp
Normal file
6
main.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
return 0;
|
||||
}
|
||||
16
src/entites.cpp
Normal file
16
src/entites.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include<string>
|
||||
#include "entites.h"
|
||||
#include <mingl/mingl.h>
|
||||
|
||||
struct pos {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct entites {
|
||||
vector<pos> torpille = vector<pos>(0);
|
||||
vector<pos> missile = vector<pos>(0);
|
||||
pos joueur;
|
||||
vector<pos> envahisseur= vector<pos>(0);
|
||||
string direction;
|
||||
};
|
||||
1
src/space.cpp
Normal file
1
src/space.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "space.h"
|
||||
Loading…
Reference in New Issue
Block a user