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

Author Topic: Customizable controls  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

sdf123

  • Newbie
  • *
  • Posts: 1
    • View Profile
Customizable controls
« on: March 19, 2012, 09:51:03 pm »
I want to make customizable controls for my game. Currently I'm checking for input in-game using Keyboard::isKeyPressed(). Is it possible to define a Key type variable which would store a keycode defined by the user to use with isKeyPressed() instead of using keycodes like Keyboard::Up, for example? Which function do I use to assign a keycode to that variable? I'm using SFML 2.0.

Contadotempo

  • Full Member
  • ***
  • Posts: 167
  • Firelink Shrine
    • View Profile
Customizable controls
« Reply #1 on: March 20, 2012, 12:22:43 am »
See if this helps you:
http://www.sfml-dev.org/wiki/en/tutoriels/bindevents_en

It's for SFML 1 but the philosophy can be the same for SFML 2.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Customizable controls
« Reply #2 on: March 20, 2012, 12:41:44 pm »
You can store entered keys in sf::Keyboard::Key variables.

If you need more flexibility (like dynamic mapping from keys to actions, or combining different keys), you could take a look at my event system here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: