HI there guys, it's the first time I use this API. I come from SDL (3 years, ppff, lotta time) and got bored of doing "low-level" stuff...(not really low, but lower than this for sure).
It's been no more than 12 hours since I've installed SFML and I'm making a Scrolling Shooter, and this API is damn easy to use...I got used really fast. If you aimed that L, then two thumbs up for you
Ok, right to the question:
I ran a while loop with the GetEvent(mEvent) thing, "similar" to SDL's way
while (mApp.GetEvent(mEvent))
{
if ((mEvent.Type == sf::Event::Closed) || ( (mEvent.Type == sf::Event::KeyPressed) && (mEvent.Key.Code == sf::Key::Escape) ) )
Quit();
//Step functions calls
mPlayer.Step(mEvent);
//Drawing stuff
mApp.Draw(mPlayer.Get());
mApp.Display();
}
As you can see, the Step method of the mPlayer instance (actually it's a "Player" class instance) asks for a mEvent. The Step source is right below:
//LEFT
if ( (Ev.Type==sf::Event::KeyPressed) && (Ev.Key.Code == sf::Key::A) )
{
mCurrentImg = 1;
mMotionX = -5.0f;
}
//RIGHT
else if ( (Ev.Type==sf::Event::KeyPressed) && (Ev.Key.Code == sf::Key::D))
{
mCurrentImg = 2;
mMotionX = 5.0f;
}
//DOWN
else if ( (Ev.Type==sf::Event::KeyPressed) && (Ev.Key.Code == sf::Key::S) )
{
mMotionY = -1.0f;
}
//UP
else if ( (Ev.Type==sf::Event::KeyPressed) && (Ev.Key.Code == sf::Key::W))
{
mMotionY = 2.5f;
}
else
{
mCurrentImg = 0;
mMotionX = 0.0f;
mMotionY = 0.0f;
mScaleFactor = 0.0f;
}
mSprite.Move(mMotionX,mMotionY);
mSprite.Scale(mScaleFactor,mScaleFactor);
But the movement I get is not "smooth". By "smooth" I mean that once you press the key you have to wait for less than a second for the Sprite to start moving and you can't just get a nice bidirectional movement when you press A and W or A and S and so on...
So my question is what the heck I'm doing wrong that doesnt let me get that smooth, nice and sweet movement I'm trying to get?
Thanks beforehand
L
PD: Nevermind the Sprite.Scale & mCurrentImg things, I am planning to do some multidirectional-like effect...and I will upload progress =)