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

Author Topic: SFML Game Developmet - Problem With Commands  (Read 889 times)

0 Members and 1 Guest are viewing this topic.

RevertiveDeath

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
SFML Game Developmet - Problem With Commands
« on: April 08, 2015, 11:40:21 pm »
So I have been following the book SFML Game Development and I am right at the end of chapter 4 (Where we bind keys to actions). The code I have is:

Player::Player()
{
    mKeyBinding[sf::Keyboard::W] = MoveUp;
    mKeyBinding[sf::Keyboard::A] = MoveLeft;
    mKeyBinding[sf::Keyboard::S] = MoveDown;
    mKeyBinding[sf::Keyboard::D] = MoveRight;

    mActionBinding[MoveUp].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.f, -0.1f * dt.asSeconds());
    };

    mActionBinding[MoveLeft].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(-0.1f * dt.asSeconds(), 0.f);
    };

    mActionBinding[MoveDown].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.f, 0.1f * dt.asSeconds());
    };

    mActionBinding[MoveRight].action =
        [] (SceneNode& node, sf::Time dt)
    {
        node.move(0.1f * dt.asSeconds(), 0.f);
    };

    for(auto &pair : mActionBinding)
        pair.second.category = Category::PlayerAircraft;
}
 

and for some reason I can move up down and right but not to the left. I have looked all over my code and compared it to the source code: https://github.com/SFML/SFML-Game-Development-Book/tree/master/04_Input

Any ideas why I can't move left?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: SFML Game Developmet - Problem With Commands
« Reply #1 on: April 09, 2015, 12:27:28 am »
Start your debugger and find out.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything