I was mistaken by this paragraph in the tutos:
To control playback, the following functions are available:
play starts or resumes playback
Resume playback here does not mean continue the playback (necessary to play the sound) but to resume from being paused.
Play starts the sound playing and it will continue to play until finished, paused, stopped, destroyed, or its buffer is changed.
Do we need to put in the main loop only code for the window realted stuff?
I was in the belief that the event loop integrated itself into the main loop doubles as 'supervisor', or the loop that helps create the passing by of the game.
Hopefully, with your hints and code, I'll be able to identify that part of my many doubts
The testings showed me to play fine outside the main loop, now I want to integrate it (with every portion of any program) inthe correct loop. Is the event loop only for the management of the events itself? and how is it different from the main one?
Many thanks and I understand that this post may falls under another module
This is off-topic for the SFML forum so I'll try to be brief.
The main loop is for code that continuously runs, not for things that exist during that time.
Generally, all objects should be created before the loop, modified in the main loop and then destroyed after the main loop (this is usually automatic).
Generally...
In the main loop, you need three general things: input, update, render.
The event loop is a way of processing the input given to your window. That's all that should be in the event loop - processing the events.
Then, update everything. Text, graphics, physics, hp, score, colour of background etc.. The way this is updated may changed depending on events that may have occurred. Also, in some cases, this update may be looped. This is a timestep thing and might be a little advanced but you can read an article about this:
http://gafferongames.com/game-physics/fix-your-timestep/After the input has been processed, then everything is updated to be what it should, you render. That is, you clear the window, draw the objects required, and then display the window.
If things are sometimes shown but sometimes not shown, just don't draw them; it's likely that you don't need to destroy it if it'll be re-created or it will re-appear.
So, generally, create everything before the loop.
There are, of course, exceptions to this. Things like bullets that are dynamically created can be...created dynamically within the main loop. They are still only created once (per bullet, for example); once they are created, they are then modified while needed and then finally destroyed when they are no longer needed.
For information about events, you
should read, read, re-read, and read again
this tutorial until you
fully understand it.
You should probably google about this topic too. "Game loop", "event loop", "message loop" and "time step" are all probably good starting points for your searches.
I guess I was not as brief as I had hoped...