-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'phoenix' with GUI and full features.
- Loading branch information
Showing
36 changed files
with
1,213 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,22 @@ | ||
#include <SFML/Window.hpp> | ||
#include <SFML/Graphics.hpp> | ||
#include <SFML/System.hpp> | ||
#include <iostream> | ||
#include <fstream> | ||
#include "Game.h" | ||
|
||
#include "Vecteur.h" | ||
#include "Objet.h" | ||
|
||
sf::RenderWindow window; | ||
sf::CircleShape Prometheus(15); | ||
sf::RenderWindow game; | ||
sf::RenderWindow param; | ||
|
||
int main() { | ||
//creation du système | ||
Objet Vaisseau; | ||
|
||
//création d'un fichier de sortie des données et d'un compteur d'itérations | ||
std::ofstream outfile; | ||
outfile.open("../vaisseau.dat"); | ||
|
||
int iterations = 0; | ||
//temps d'une boucle (fps) | ||
sf::Time time = sf::milliseconds(10); | ||
double dTime = 0.010; | ||
|
||
// création de la fenêtre | ||
window.create(sf::VideoMode(800, 600), "My window"); | ||
Prometheus.setFillColor(sf::Color(100, 250, 50)); | ||
|
||
// on fait tourner le programme tant que la fenêtre n'a pas été fermée | ||
while (window.isOpen()) { | ||
//Chronometrage | ||
sf::Clock clock; | ||
|
||
// on traite tous les évènements de la fenêtre qui ont été générés depuis la dernière itération de la boucle | ||
sf::Event event; | ||
while (window.pollEvent(event)) { | ||
// fermeture de la fenêtre lorsque l'utilisateur le souhaite | ||
if (event.type == sf::Event::Closed) | ||
window.close(); | ||
} | ||
// effacement de la fenêtre en noir | ||
window.clear(); | ||
Vaisseau.Acceleration(); | ||
Data Parametres(3,120,30,80,20,10,10,2,0); | ||
|
||
//Vaisseau.affiche_acceleration_x(Vaisseau.acceleration_x()); | ||
//Vaisseau.affiche_acceleration_y(Vaisseau.acceleration_y()); | ||
outfile << iterations << " " << Vaisseau.acceleration_x() << " " << Vaisseau.acceleration_y() << " " << Vaisseau.vitesse_x() << " " << Vaisseau.vitesse_y() << " " << Vaisseau.x_() << " " << Vaisseau.y_() << std::endl; | ||
sf::Time time = sf::milliseconds(20); | ||
Vecteur Diff_de_ref; | ||
|
||
Vaisseau.Euler(dTime); | ||
Prometheus.setPosition(Vaisseau.x_(), Vaisseau.y_()); | ||
bool end = true; | ||
bool close = true; | ||
|
||
// c'est ici qu'on dessine tout | ||
window.draw(Prometheus); | ||
|
||
// fin de la frame courante, affichage de tout ce qu'on a dessiné | ||
iterations += 1; | ||
window.display(); | ||
|
||
// Wait for the next frame, in order to get a constant framerate, independent from the execution time | ||
sf::sleep(time - clock.getElapsedTime()); | ||
} | ||
outfile.close(); | ||
do { | ||
game.create(sf::VideoMode(Parametres.Lx(), Parametres.Ly()), "The Game"); | ||
param.create(sf::VideoMode(Parametres.Lx(), Parametres.Ly()), "Paramètres"); | ||
Front_Page (param, game, Diff_de_ref, Parametres, close); | ||
} while (Game(game, param, Diff_de_ref, time, Parametres, end, close)); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ ninja | |
./sfml-app | ||
``` | ||
|
||
Make sure that `libsfml` is installed. | ||
Make sure that `libsfml` is installed. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef CorpsStellaire_h | ||
#define CorpsStellaire_h | ||
#include <SFML/Graphics.hpp> | ||
#include "Vecteur.h" | ||
#include "Objet.h" | ||
|
||
class CorpsStellaire : public Objet { | ||
public: | ||
CorpsStellaire (); | ||
CorpsStellaire (const double rayon_, const Vecteur vitesse_, const Vecteur position_, const double masse_, const sf::Texture texture_, const sf::CircleShape planete_); | ||
void set_CorpsStellaire (double & rayon_, sf::CircleShape & planete_); | ||
|
||
double rayon_ () const; | ||
|
||
private: | ||
double rayon; | ||
sf::CircleShape planete; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#ifndef Data_h | ||
#define Data_h | ||
#include <SFML/Window.hpp> | ||
#include <SFML/Graphics.hpp> | ||
#include <SFML/System.hpp> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
#include <random> | ||
#include "Vecteur.h" | ||
#include "Objet.h" | ||
#include "Vaisseau.h" | ||
#include "CorpsStellaire.h" | ||
#include "PageSetting.h" | ||
|
||
|
||
using namespace std; | ||
|
||
class Data { | ||
|
||
public: | ||
|
||
Data (); | ||
Data (const double N, | ||
const double RMAX, | ||
const double RMIN, | ||
const double PROPULSION_AR, | ||
const double PROPULSION_AV, | ||
const double PROPULSION_LAT, | ||
const double PROPULSION_ROT, | ||
const double MASSE, | ||
const int MODE | ||
); | ||
|
||
void default_setting_1 (vector<Input> & Input); | ||
Data cstr_setting_1 (vector<Input> Input); | ||
void corpsstellaire_generation (CorpsStellaire & CorpsStellaire_, sf::CircleShape & corps_); | ||
void mapping (); | ||
bool uncovering_test (); | ||
void Texturage (); | ||
void reset (); | ||
void sides (); | ||
void Game_Over (); | ||
void set_mode (); | ||
void ship_deplacement (bool & test); | ||
void planete_deplacement (bool & test, Vecteur & Diff_de_ref); | ||
|
||
|
||
double n (); | ||
//int t () const; | ||
//double R () const; | ||
//double M () const; | ||
//int Rmax () const; | ||
//int Rmin () const; | ||
int Lx (); | ||
int Ly (); | ||
//double h () const; | ||
//double Propulsion_Ar () const; | ||
//double Propulsion_Av () const; | ||
//double Propulsion_Lat () const; | ||
//double Propulsion_Rot () const; | ||
//double Masse () const; | ||
//int Largeur () const; | ||
//int Longueur () const; | ||
//Vecteur position_initial () const; | ||
//sf::Texture texture_vaisseau () const; | ||
sf::RectangleShape Ship (); | ||
Vaisseau Prometheus(); | ||
vector<CorpsStellaire> list_objet (); | ||
vector<sf::CircleShape> corps (); | ||
Text game_over (); | ||
int Mode (); | ||
|
||
private: | ||
//Nombre d'objets | ||
double n_; | ||
//Nombre de texture de planètes differentes | ||
double t_; | ||
//Rayon d'un CorpsStellaire | ||
double R_; | ||
//Masse d'un CorpsStellaire | ||
double M_; | ||
//Rayon maximum d'un CorpsStellaire | ||
double Rmax_; | ||
//Rayon minimum d'un CorpsStellaire | ||
double Rmin_; | ||
//Taille de la fenêtre selon x | ||
int Lx_; | ||
//Taille de la fenêtre seon y | ||
int Ly_; | ||
//Paramètrage RK4 | ||
double h_; | ||
//Propulsion arrière d'un Vaisseau | ||
double Propulsion_Ar_; | ||
//Propulsion avant d'un Vaisseau | ||
double Propulsion_Av_; | ||
//Propulsion laterale d'un Vaisseau | ||
double Propulsion_Lat_; | ||
//Propulsion de rotation d'un Vaisseau | ||
double Propulsion_Rot_; | ||
//Masse d'un Vaisseau | ||
double Masse_; | ||
//Largeur d'un Vaisseau | ||
int Largeur_; | ||
//Longueur d'un Vaisseau | ||
int Longueur_; | ||
//Position initial du Vaisseau | ||
Vecteur position_initial_; | ||
//Texture du vaisseau | ||
sf::Texture texture_vaisseau_; | ||
//Forme du vaisseau | ||
sf::RectangleShape Ship_; | ||
//vaisseau | ||
Vaisseau Prometheus_; | ||
//Liste de CorpsStellaire (physique) | ||
vector<CorpsStellaire> list_objet_; | ||
//Liste de CorpsStellaire (affichage) | ||
vector<sf::CircleShape> corps_; | ||
//Police game over | ||
Text game_over_; | ||
//Mode de jeu | ||
int mode_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "Parametres.h" | ||
|
||
bool Game (sf::RenderWindow & game_, sf::RenderWindow & param_, Vecteur Diff_de_ref, sf::Time time, Data & game_setting, bool & end, bool & close) { | ||
|
||
bool Continue = true; | ||
|
||
if (close) { | ||
while (game_.isOpen()) { | ||
|
||
sf::Event event; | ||
|
||
while (game_.pollEvent(event)) { | ||
if (event.type == sf::Event::Closed) { | ||
game_.close(); | ||
end = false; | ||
} | ||
}; | ||
|
||
if(Continue) { | ||
sf::Clock clock; | ||
vector<sf::CircleShape> Corps; | ||
Corps = game_setting.corps(); | ||
vector<CorpsStellaire> Objets; | ||
Objets = game_setting.list_objet(); | ||
sf::RectangleShape Ship; | ||
Ship = game_setting.Prometheus().ship_(); | ||
game_.display(); | ||
game_.clear(); | ||
game_.draw(Ship); | ||
if (game_setting.Mode() == 0) { | ||
game_setting.ship_deplacement(Continue); | ||
}; | ||
if (game_setting.Mode() == 1) { | ||
game_setting.planete_deplacement(Continue, Diff_de_ref); | ||
}; | ||
for (int i = 0; i<game_setting.n(); i++) { | ||
Corps[i].setPosition(Objets[i].position_().x_() - Objets[i].rayon_() - Diff_de_ref.x_(), Objets[i].position_().y_() - Objets[i].rayon_() - Diff_de_ref.y_()); | ||
Corps[i].setRadius(Objets[i].rayon_()); | ||
sf::Texture texture = Objets[i].texture_(); | ||
Corps[i].setTexture(& texture); | ||
game_.draw(Corps[i]); | ||
}; | ||
sf::sleep(time - clock.getElapsedTime()); | ||
} | ||
else { | ||
game_.display(); | ||
game_.clear(); | ||
game_.draw(game_setting.game_over().text()); | ||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::C)) { | ||
end = true; | ||
game_.close(); | ||
param_.close(); | ||
} | ||
else { | ||
end = false; | ||
}; | ||
}; | ||
}; | ||
} | ||
else { | ||
end = false; | ||
}; | ||
return (end); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef Input_h | ||
#define Input_h | ||
#include <SFML/Graphics.hpp> | ||
#include <iostream> | ||
#include <string> | ||
#include "Text.h" | ||
|
||
class Input : public Text { | ||
public: | ||
Input (); | ||
Input (sf::RectangleShape INPUT_ZONE, string INPUT, Text TEXT); | ||
|
||
sf::RectangleShape input_zone (); | ||
string input (); | ||
Text input_text(); | ||
bool focus_zone (); | ||
|
||
void set_input (string ipt); | ||
void input_zone (sf::Vector2f size, Vecteur position); | ||
|
||
protected: | ||
sf::RectangleShape input_zone_; | ||
string input_; | ||
Text text_; | ||
bool focus_zone_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,32 @@ | ||
#ifndef Objet_h | ||
#define Objet_h | ||
#include <SFML/Graphics.hpp> | ||
#include <vector> | ||
#include <string> | ||
#include "Vecteur.h" | ||
|
||
|
||
class Objet { | ||
public: | ||
Objet(); | ||
Objet(Vecteur position_, Vecteur position_precedente_, Vecteur acceleration_, Vecteur vitesse_, Vecteur vitesse_precedente_); | ||
|
||
void Acceleration (); | ||
void Euler (double dTime); | ||
Objet (); | ||
Objet (const double masse_, const Vecteur vitesse_, const Vecteur position_, const sf::Texture texture_); | ||
|
||
Vecteur position_ () const; | ||
double x_ () const; | ||
double y_ () const; | ||
//Vecteur acceleration_ () const; | ||
double vitesse_x () const; | ||
double vitesse_y () const; | ||
double acceleration_x () const; | ||
double acceleration_y () const; | ||
double masse_ () const; | ||
sf::Texture texture_ () const; | ||
|
||
void affiche_acceleration_x (double x); | ||
void affiche_acceleration_y (double y); | ||
void set_position (Vecteur & Vect_); | ||
void set_position (double x, double y); | ||
void set_vitesse (Vecteur & Vect_); | ||
void set_texture (std::string nom_texture); | ||
void set_Objet (double & masse_, Vecteur & vitesse_, Vecteur & position_, sf::Texture & texture_); | ||
|
||
private: | ||
Vecteur position; | ||
Vecteur position_precedente; | ||
Vecteur acceleration; | ||
Vecteur vitesse; | ||
Vecteur vitesse_precedente; | ||
double Distance (const Vecteur & Vecteur1, const Vecteur & Vecteur2); | ||
|
||
protected: | ||
double masse; | ||
Vecteur vitesse; | ||
Vecteur position; | ||
sf::Texture texture; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.