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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - CINEfilHD77

Pages: [1]
1
General / window.pollEvent() or real-time ?
« on: August 17, 2016, 11:22:27 pm »
Hi everybody !

To begin with, sorry for my bad english, especially if it sounds so cold and devoid of enthusiasm (cause the truth is that it's the absolute contrary).

11pm, i'm a bit tired, so I will be brief.
So ! I'm actually programming a 2D game with SFML (online action shooter), but I'm now stuck on the problematic of events. I know that there are 2 types of events : the ones we can retrieve with window.pollEvent(sf::Event), and the real-time ones (sf::Keyboard::[...]). What are the best practices for a videogame ? I have explored Google a couple of days without any conclusion. My system should work according to this "diagram" :

- Main loop :
   - Inputs handling
   - Game logic
   - Rendering

So, the "Inputs handling" can handle events in two ways :
1. Call window.pollEvent() and send each event to associated listeners (game entities, etc...)
2. Browse each entity and call a handleInputs() method that will check for real-time inputs

I'm asking myself also about a thing, what is the best way to handle player movements for example ?
Update the position when a corresponding keyboard event is received, or set a flag (for example : action = MOVE_UP | MOVE_RIGHT, when up and right arrows have been pressed) and update the position during the process of "Game logic" ?

I apologize if I'm not as clear as I hoped.

Have a good day (or night) !  ;D

Pages: [1]