SFML community forums

Help => Window => Topic started by: LakySimi1 on May 28, 2019, 07:42:31 pm

Title: Updating the sprite and show it works for few seconds
Post by: LakySimi1 on May 28, 2019, 07:42:31 pm
Hi everyone!
i'm a very newbie with SFML, in trying to learn how to display my pixels array and refreshing window when needed. I've make this very basic program, it works, make me change the intesity of blue (whitch fill the window) based on my input but it works just for 2 or 3 seconds! Then the window doesn't not respond and freeze.

I'm using CodeBlocks

(click to show/hide)
Title: Re: Updating the sprite and show it works for few seconds
Post by: Hapax on May 28, 2019, 09:09:41 pm
You need an event handler to process the events given to the window.

See the SFML examples.
This one in particular is a pretty good skeleton example:
https://www.sfml-dev.org/tutorials/2.5/window-window.php#bringing-the-window-to-life

And this one is a good example of how your event loop will probably look:
https://www.sfml-dev.org/tutorials/2.5/window-events.php#the-sfevent-type
Title: Re: Updating the sprite and show it works for few seconds
Post by: LakySimi1 on May 31, 2019, 11:24:37 am
Thank you!! Does anyone have a "practical and fast" solution for the code i proposed?
I have to study a bit of SFML but for now the code i proposed is really the only (core) thing i need for my projects and games (the console prompt is coming a bit dull  ;D)