Rotation correcte des balles selon la gravité
This commit is contained in:
parent
c0342f3a9e
commit
c59d6eac0e
|
@ -3,6 +3,7 @@
|
||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
#include "block.hpp"
|
#include "block.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
|
#include <iostream>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
const unsigned int Player::TYPE_ID = 1;
|
const unsigned int Player::TYPE_ID = 1;
|
||||||
|
@ -85,10 +86,11 @@ void Player::draw(Level& level) {
|
||||||
|
|
||||||
// on fait tourner le sprite selon la différence de position
|
// on fait tourner le sprite selon la différence de position
|
||||||
if (previous_position != sf::Vector2f(0, 0)) {
|
if (previous_position != sf::Vector2f(0, 0)) {
|
||||||
sprite.rotate(
|
sf::Vector2f right_dir = level.getRightDirection();
|
||||||
(getPosition() - previous_position).x *
|
sf::Vector2f diff = getPosition() - previous_position;
|
||||||
level.getRightDirection().x * .015f
|
|
||||||
);
|
float rotate = (right_dir.x * diff.x + right_dir.y * diff.y) * 3 / 200;
|
||||||
|
sprite.rotate(rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
previous_position = getPosition();
|
previous_position = getPosition();
|
||||||
|
|
Loading…
Reference in New Issue