Rotation correcte des balles selon la gravité

This commit is contained in:
Mattéo Delabre 2016-04-11 23:29:59 +02:00
parent c0342f3a9e
commit c59d6eac0e
1 changed files with 6 additions and 4 deletions

View File

@ -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();