Déplacement des implémentations dans les fichiers source
This commit is contained in:
parent
8b8102eeb0
commit
cb0dd83817
|
@ -20,9 +20,7 @@ protected:
|
||||||
static constexpr float MOVE = 100;
|
static constexpr float MOVE = 100;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ball(float x, float y) : PhysicsObject(x, y), shape(10 * mass) {
|
Ball(float x, float y);
|
||||||
shape.setOrigin(sf::Vector2f(10 * mass, 10 * mass));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dessine la balle dans la fenêtre donnée
|
* Dessine la balle dans la fenêtre donnée
|
||||||
|
@ -37,9 +35,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Détermine la couche d'affichage de l'objet
|
* Détermine la couche d'affichage de l'objet
|
||||||
*/
|
*/
|
||||||
unsigned int getLayer() {
|
unsigned int getLayer();
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,9 +14,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
static constexpr float GRID = 32;
|
static constexpr float GRID = 32;
|
||||||
|
|
||||||
Block(float x, float y) : Object(x, y), shape(sf::Vector2f(Block::GRID, Block::GRID)) {
|
Block(float x, float y);
|
||||||
shape.setOrigin(sf::Vector2f(Block::GRID / 2, Block::GRID / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dessin du bloc dans la fenêtre donnée
|
* Dessin du bloc dans la fenêtre donnée
|
||||||
|
@ -37,9 +35,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Détermine la couche d'affichage de l'objet
|
* Détermine la couche d'affichage de l'objet
|
||||||
*/
|
*/
|
||||||
unsigned int getLayer() {
|
unsigned int getLayer();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct EngineState {
|
||||||
std::array<bool, sf::Keyboard::KeyCount> keys;
|
std::array<bool, sf::Keyboard::KeyCount> keys;
|
||||||
float delta;
|
float delta;
|
||||||
|
|
||||||
EngineState() {
|
EngineState() : delta(0.f) {
|
||||||
// aucune touche n'est enfoncée au démarrage
|
// aucune touche n'est enfoncée au démarrage
|
||||||
keys.fill(false);
|
keys.fill(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ protected:
|
||||||
int charge;
|
int charge;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Object(float x, float y) :
|
Object(float x, float y);
|
||||||
position(x, y), charge(0) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dessine l'objet dans la fenêtre donnée
|
* Dessine l'objet dans la fenêtre donnée
|
||||||
|
@ -57,9 +56,7 @@ public:
|
||||||
* qui doit être dessinée avant celle du second
|
* qui doit être dessinée avant celle du second
|
||||||
*/
|
*/
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator()(Object* const &t1, Object* const &t2) {
|
bool operator()(Object* const &t1, Object* const &t2);
|
||||||
return t1->getLayer() > t2->getLayer();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,9 +22,7 @@ protected:
|
||||||
static constexpr float GRAVITY = 20;
|
static constexpr float GRAVITY = 20;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PhysicsObject(float x, float y) :
|
PhysicsObject(float x, float y);
|
||||||
Object(x, y), mass(1), accelLine(sf::LinesStrip, 2),
|
|
||||||
velLine(sf::LinesStrip, 2) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dessine l'objet dans la fenêtre donnée
|
* Dessine l'objet dans la fenêtre donnée
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "ball.hpp"
|
#include "ball.hpp"
|
||||||
|
|
||||||
|
Ball::Ball(float x, float y) : PhysicsObject(x, y), shape(10 * mass) {
|
||||||
|
shape.setOrigin(sf::Vector2f(10 * mass, 10 * mass));
|
||||||
|
}
|
||||||
|
|
||||||
void Ball::draw(sf::RenderWindow& window) {
|
void Ball::draw(sf::RenderWindow& window) {
|
||||||
PhysicsObject::draw(window);
|
PhysicsObject::draw(window);
|
||||||
|
|
||||||
|
@ -22,6 +26,10 @@ std::unique_ptr<sf::FloatRect> Ball::getAABB() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Ball::getLayer() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sf::Vector2f Ball::getForces(EngineState& state) {
|
sf::Vector2f Ball::getForces(EngineState& state) {
|
||||||
sf::Vector2f forces = PhysicsObject::getForces(state);
|
sf::Vector2f forces = PhysicsObject::getForces(state);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "block.hpp"
|
#include "block.hpp"
|
||||||
|
|
||||||
|
Block::Block(float x, float y) : Object(x, y), shape(sf::Vector2f(Block::GRID, Block::GRID)) {
|
||||||
|
shape.setOrigin(sf::Vector2f(Block::GRID / 2, Block::GRID / 2));
|
||||||
|
}
|
||||||
|
|
||||||
void Block::draw(sf::RenderWindow& window) {
|
void Block::draw(sf::RenderWindow& window) {
|
||||||
// chargement de la texture de test
|
// chargement de la texture de test
|
||||||
if (!texture.loadFromFile("./res/block.png")) {
|
if (!texture.loadFromFile("./res/block.png")) {
|
||||||
|
@ -31,3 +35,7 @@ std::unique_ptr<sf::FloatRect> Block::getAABB() {
|
||||||
Block::GRID, Block::GRID
|
Block::GRID, Block::GRID
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Block::getLayer() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
|
|
||||||
|
Object::Object(float x, float y) : position(x, y), charge(0) {}
|
||||||
|
|
||||||
sf::Vector2f Object::getPosition() {
|
sf::Vector2f Object::getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
@ -11,3 +13,7 @@ int Object::getCharge() {
|
||||||
void Object::setCharge(int set_charge) {
|
void Object::setCharge(int set_charge) {
|
||||||
charge = set_charge;
|
charge = set_charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObjectCompare::operator()(Object* const &t1, Object* const &t2) {
|
||||||
|
return t1->getLayer() > t2->getLayer();
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "physics_object.hpp"
|
#include "physics_object.hpp"
|
||||||
|
|
||||||
|
PhysicsObject::PhysicsObject(float x, float y) :
|
||||||
|
Object(x, y), mass(1), accelLine(sf::LinesStrip, 2),
|
||||||
|
velLine(sf::LinesStrip, 2) {}
|
||||||
|
|
||||||
void PhysicsObject::draw(sf::RenderWindow& window) {
|
void PhysicsObject::draw(sf::RenderWindow& window) {
|
||||||
velLine[0].position = position;
|
velLine[0].position = position;
|
||||||
velLine[0].color = sf::Color::Green;
|
velLine[0].color = sf::Color::Green;
|
||||||
|
|
Loading…
Reference in New Issue