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