2016-03-08 22:28:50 +00:00
|
|
|
#ifndef __PTF_BALL_HPP__
|
|
|
|
#define __PTF_BALL_HPP__
|
2016-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <iostream>
|
2016-03-08 18:50:21 +00:00
|
|
|
#include "state.hpp"
|
|
|
|
#include "physics_object.hpp"
|
2016-03-04 15:29:31 +00:00
|
|
|
|
2016-03-08 18:50:21 +00:00
|
|
|
class Ball : public PhysicsObject {
|
2016-03-04 15:29:31 +00:00
|
|
|
protected:
|
2016-03-12 10:22:10 +00:00
|
|
|
sf::Texture texture;
|
2016-03-10 20:47:19 +00:00
|
|
|
sf::CircleShape shape;
|
|
|
|
|
2016-03-08 18:50:21 +00:00
|
|
|
/**
|
|
|
|
* Calcule les forces appliquées à l'objet
|
|
|
|
*/
|
2016-03-11 14:36:21 +00:00
|
|
|
virtual sf::Vector2f getForces(State state);
|
2016-03-04 15:29:31 +00:00
|
|
|
|
2016-03-11 15:15:11 +00:00
|
|
|
static constexpr float ATTRACTION = 25000;
|
|
|
|
static constexpr float MOVE = 100;
|
2016-03-08 20:15:08 +00:00
|
|
|
|
2016-03-04 15:29:31 +00:00
|
|
|
public:
|
2016-03-10 20:47:19 +00:00
|
|
|
Ball(float x, float y) : PhysicsObject(x, y), shape(10 * mass) {
|
2016-03-11 15:15:11 +00:00
|
|
|
shape.setOrigin(sf::Vector2f(10 * mass, 10 * mass));
|
|
|
|
shape.setFillColor(sf::Color(255, 245, 131));
|
2016-03-10 20:47:19 +00:00
|
|
|
}
|
2016-03-09 19:01:15 +00:00
|
|
|
|
2016-03-08 17:07:21 +00:00
|
|
|
/**
|
2016-03-08 18:50:21 +00:00
|
|
|
* Dessine la balle dans la fenêtre donnée
|
2016-03-08 17:07:21 +00:00
|
|
|
*/
|
2016-03-08 18:50:21 +00:00
|
|
|
void draw(sf::RenderWindow& window);
|
2016-03-04 15:29:31 +00:00
|
|
|
|
2016-03-08 17:07:21 +00:00
|
|
|
/**
|
2016-03-08 18:50:21 +00:00
|
|
|
* Détermine la couche d'affichage de l'objet
|
2016-03-08 17:07:21 +00:00
|
|
|
*/
|
2016-03-08 18:50:21 +00:00
|
|
|
unsigned int getLayer() {
|
|
|
|
return 1;
|
|
|
|
}
|
2016-03-04 15:29:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|