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

Author Topic: Poll event vs GetInput()  (Read 2569 times)

0 Members and 1 Guest are viewing this topic.

knox_rolley

  • Newbie
  • *
  • Posts: 5
    • View Profile
Poll event vs GetInput()
« on: August 24, 2011, 07:59:36 pm »
Hello, i'm curious about something regarding player input.
I understand both polling events and doing a .GetInput().IsKeyDown can work for detecting when a key is pressed, and I seem to be using both in my current project.
Polling events handles going through a door (W key) and i usec getinput to incorporate a yoyo item when return is pressed, i guess because i did that later on in the programming progress. movement is also with GetInput (A and D keys).

Is there a big difference here, is it recommendable to stick with one of these methods?

I have seen poll event be applied for closing the screen a lot but directional movement seems to work with GetInput() is many programs, to cite an example of both being in the same program. i guess thats my question. my program is functional and i seem to be becoming more efficient at debugging so i might as well work out the minor details. by the way i just organized all my code which was a little scrambled up, which is why i got to this question in the first place

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Poll event vs GetInput()
« Reply #1 on: August 24, 2011, 08:05:37 pm »
I'm guessing your using SFML 1.6?

You will always be forced to poll events because else the Input object won't be updated. The Event's are more suitable for one-shot things. Like "when this happens do this" while the Input object becomes suitable for when we want to check the state every frame/iteration.

I think just do what you feel is natural.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

knox_rolley

  • Newbie
  • *
  • Posts: 5
    • View Profile
Poll event vs GetInput()
« Reply #2 on: August 24, 2011, 08:36:18 pm »
Oh that sounds right, the event stack is better suited for actual events and GetInput() naturally checks each frame and in doing so is good for movement and the like. Thanks for the quick & concise reply.

By the way, no actually i use SFML 2.0, in fact my other 3 or 4 posts were all about problems i encountered building it a while back :D

and if i recall correctly sfml 1.6 uses GetEvent instead of PollEvent for syntax
luckily that was about all the changed syntax i encountered during the transition with my low level skills

thanks again, i'll be back with actual problems sooner or later, this one was just a conceptual quarry hehe

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Poll event vs GetInput()
« Reply #3 on: August 24, 2011, 08:42:29 pm »
Well then you don't have the latest SFML2.

Input has been removed for some time now. It is seperated into Keyboard, Mouse and Joystick.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio