SFML community forums
General => General discussions => Topic started by: Mind Calamity on October 04, 2011, 12:33:54 pm
-
So, I think that the tutorials need updating, as the API has changed a bit for the next version.
I will update only the tutorials that contain source from the updated API, I will leave out the ones that are still working.
(I'll post the tutorials as replies to this one.)
-
Do it if you want, but don't forget that I'll update them soon. And I won't just update the source code, I'll rewrite almost all of them.
-
Deleted by Laurent, the "tutorial" was full of mistakes. It was confusing and didn't help at all.
-
Do it if you want, but don't forget that I'll update them soon. And I won't just update the source code, I'll rewrite almost all of them.
Well, that might be the case, but until then, it's nice to have an alternative resource. As I'm reading through the tutorials, it won't hurt to post and updated version of them.
Besides, I have lots of free time today, and I'm planning to focus it on SFML.
-
sf::Keyboard keyboard = sf::Keyboard();
sf::Mouse mouse = sf::Mouse();
sf::Joystick joystick = sf::Joystick();
Althought this code works, it is misleading. One is not supposed to instanciate these classes, all their functions are static.
-
sf::Keyboard keyboard = sf::Keyboard();
sf::Mouse mouse = sf::Mouse();
sf::Joystick joystick = sf::Joystick();
Althought this code works, it is misleading. One is not supposed to instanciate these classes, all their functions are static.
Thanks for the note, I updated the post and added the full source, which I forgot at first.
-
int JoystickX = sf::Joystick::X;
int JoystickY = sf::Joystick::Y;
int JoystickPOVX = sf::Joystick::PovX;
int JoystickPOVY = sf::Joystick::PovY;
This code isn't doing anything useful, sf::Joystick::X (and Y, PovX, PovY) are constants that must be used as axes identifiers in sf::Joystick functions.
Seriously, you shouldn't do that. You'll waste a lot of time, you'll make mistakes (I won't correct everything), and in a few weeks the official tutorials for 2.0 will be there.
There's already a thread that gathers all the API changes:
http://www.sfml-dev.org/forum/viewtopic.php?t=5343
-
int JoystickX = sf::Joystick::X;
int JoystickY = sf::Joystick::Y;
int JoystickPOVX = sf::Joystick::PovX;
int JoystickPOVY = sf::Joystick::PovY;
This code isn't doing anything useful, sf::Joystick::X (and Y, PovX, PovY) are constants that must be used as axes identifiers in sf::Joystick functions.
Seriously, you shouldn't do that. You'll waste a lot of time, you'll make mistakes (I won't correct everything), and in a few weeks the official tutorials for 2.0 will be there.
There's already a thread that gathers all the API changes:
http://www.sfml-dev.org/forum/viewtopic.php?t=5343
I have no idea how the joystick works, so I did the joystick lines randomly, with the closest new function I could find, but anyway I'm not going to do any more tutorials, since you're going to make them (probably better) soon anyway.
-
I have no idea how the joystick works, so I did the joystick lines randomly, with the closest new function I could find
So you wanted to help other users with incorrect random lines of code? :shock:
-
I have no idea how the joystick works, so I did the joystick lines randomly, with the closest new function I could find
So you wanted to help other users with incorrect random lines of code? :shock:
I just wanted to help, I was going to add a comment stating that those lines aren't necessarily correct, but I forgot, I'm going to add them now.
BTW - I believe most users don't really have Joystick (again a random guess), so I don't think that is going to be much of a problem, but then again I put a warning in the code.
-
[...] when he presses the escape key :
OLD API:
while (App.GetEvent(Event))
{
// Escape key pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
Running = false;
}
NEW API:
while (App.PollEvent(Event))
{
// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (sf::Keyboard::IsKeyPressed(sf::Keyboard::Escape)))
App.Close();
}
This part confuses me, I'm pretty sure you just need to check the key code in the event structure, as you do in SFML 1.x.
I would rather write :
if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape)
It seems to me that the purpose of sf::Keyboard::IsKeyPressed is to retrieve real-time inputs, outside the PollEvent loop, as you did with the sf::Input class in SFML 1.x.
-
Absolutely.
This thread is more confusing than it helps, it should probably be deleted.
-
Ok, I didn't delete it but instead I removed the "tutorial" and locked the thread.
Sorry for OP, you wanted to help but these random lines of code were just confusing.