Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: modifying old code  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

TwoFingeredPointer

  • Newbie
  • *
  • Posts: 4
    • View Profile
modifying old code
« on: August 31, 2015, 01:42:17 am »
Hello all. I have recently started playing around with SFML. I have found an excellent tutorial online and I am working through it. The tutorial was written for version 1.6 to be used for microsoft  visual 2010. However I am using microsoft visual 2013 and i have installed version 2.3.1 I have been modifying the code and all seems to to work reasonably well. However I am stuck with these lines of code here:

 void PlayerPaddle::Update(float elapsedTime)
{

   if (Game::GetInput().IsKeyDown(sf::Keyboard::Left))
   {
      _velocity -= 3.0f;
   }
   if (Game::GetInput().IsKeyDown(sf::Keyboard::Right))
   {
      _velocity += 3.0f;
   }

   if (Game::GetInput().IsKeyDown(sf::Keyboard::Down))
   {
      _velocity = 0.0f;
   }

   if (_velocity > _maxVelocity)
      _velocity = _maxVelocity;

   if (_velocity < -_maxVelocity)
      _velocity = -_maxVelocity;


   sf::Vector2f pos = this->GetPosition();

   if (pos.x  < GetSprite().GetSize().x / 2
      || pos.x >(Game::SCREEN_WIDTH - GetSprite().GetSize().x / 2))
   {
      _velocity = -_velocity; // Bounce by current velocity in opposite direction
   }

   GetSprite().Move(_velocity * elapsedTime, 0);
}


I am reading through the documentation in order to create a suitable modification. But in order to speed up my build does anybody have an existing solution to this. Has this problem been solved already?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: modifying old code
« Reply #1 on: August 31, 2015, 07:05:28 am »
I am reading through the documentation in order to create a suitable modification. But in order to speed up my build does anybody have an existing solution to this. Has this problem been solved already?
A solution to what? I don't see any problem, apart from following a tutorial for a very old version of SFML.
Use sf::Keyboard? Read the 2.3 tutorials? Or search?
« Last Edit: August 31, 2015, 07:08:20 am by G. »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: modifying old code
« Reply #2 on: August 31, 2015, 01:34:57 pm »
You have already posted a thread about this old tutorial and converting it to the new version of SFML. Are the official SFML tutorials not enough?

You must think that this 1.6 tutorial has something that others do not. Would it be possible for you to inform us which tutorial you are using?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*