Nouvelles textures de test pour mieux voir les contours

This commit is contained in:
Mattéo Delabre 2016-03-12 23:15:03 +01:00
parent e7aa2c22e7
commit 624b377e72
9 changed files with 15 additions and 84741 deletions

View File

@ -22,7 +22,6 @@ protected:
public:
Ball(float x, float y) : PhysicsObject(x, y), shape(10 * mass) {
shape.setOrigin(sf::Vector2f(10 * mass, 10 * mass));
shape.setFillColor(sf::Color(255, 245, 131));
}
/**

View File

@ -16,7 +16,6 @@ public:
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));
shape.setFillColor(sf::Color(0, 0, 0));
}
/**

BIN
res/ball.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 6.2 MiB

BIN
res/block.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

View File

@ -2,7 +2,7 @@
void Ball::draw(sf::RenderWindow& window) {
// chargement de la texture de test
if (!texture.loadFromFile("./res/texture_test.jpeg")) {
if (!texture.loadFromFile("./res/ball.png")) {
// erreur
}
@ -39,7 +39,7 @@ sf::Vector2f Ball::getForces(State state) {
// la norme de ce vecteur est la distance entre les objets
float distanceSquared = attraction.x * attraction.x +
attraction.y * attraction.y;
// éviter la division par zéro
if (distanceSquared == 0) {
continue;

View File

@ -2,18 +2,18 @@
void Block::draw(sf::RenderWindow& window) {
// chargement de la texture de test
if (!texture.loadFromFile("./res/texture_test.jpeg")) {
if (!texture.loadFromFile("./res/block.png")) {
// erreur
}
shape.setTexture(&texture);
if (charge > 0) {
shape.setFillColor(sf::Color(0, 0, 255));
shape.setFillColor(sf::Color(180, 180, 255));
} else if (charge < 0) {
shape.setFillColor(sf::Color(255, 0, 0));
shape.setFillColor(sf::Color(255, 180, 180));
} else {
shape.setFillColor(sf::Color(75, 75, 75));
shape.setFillColor(sf::Color::White);
}
shape.setPosition(position);

View File

@ -14,10 +14,15 @@ int main() {
Block block3(4 * Block::GRID, 7 * Block::GRID);
Block block4(5 * Block::GRID, 7 * Block::GRID);
Block block5(6 * Block::GRID, 7 * Block::GRID);
Block block6(7 * Block::GRID, 7 * Block::GRID);
Block block7(8 * Block::GRID, 7 * Block::GRID);
Block block8(9 * Block::GRID, 7 * Block::GRID);
Block block9(10 * Block::GRID, 7 * Block::GRID);
ball1.setCharge(2);
ball2.setCharge(-2);
block3.setCharge(10);
block9.setCharge(-10);
engine.addObject(ball1);
engine.addObject(ball2);
@ -26,6 +31,10 @@ int main() {
engine.addObject(block3);
engine.addObject(block4);
engine.addObject(block5);
engine.addObject(block6);
engine.addObject(block7);
engine.addObject(block8);
engine.addObject(block9);
engine.start();
return 0;