title: Moving tile by tile
body: <p>I have done a map with Tiled. Every single tile of it measures <code>32x32 px</code> so does my main character sprite.</p>
  
  <p>In my class <code>Player.cpp</code>, I have some functions that calculates a <code>deltaY/X</code> which decide if you are going <code>Left/Right/Up/Down</code> and then you use them in the update function.</p>
  
  <p>That's my code so far:</p>
  
  <pre><code>void Player::moveX(int moveDirection) {
      deltaX = moveDirection * PlayerConstants::WALK_SPEED;
      playAnimation(deltaX &gt; 0 ? "WalkRight" : "WalkLeft");
      facing = deltaX &gt; 0 ? DIRECTION ::RIGHT : DIRECTION::LEFT;
  }
  
  void Player::moveY(int moveDirection) {
      deltaY = moveDirection * PlayerConstants::WALK_SPEED;
      playAnimation(deltaY &lt; 0 ? "WalkUp" : "WalkDown");
      facing = deltaY &lt; 0 ? DIRECTION ::UP : DIRECTION::DOWN;
  }
  
  void Player::update(float elapsedTime) {
      _x += deltaX * elapsedTime;
      _y += deltaY * elapsedTime;
  
      AnimatedSprite::update(elapsedTime);
  }
  </code></pre>
  
  <p>Walk Speed is <code>0.1</code> right now.</p>
  
  <p>Any guesses on how to move it tile by tile? </p>