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

Author Topic: Updating the sprite and show it works for few seconds  (Read 2516 times)

0 Members and 1 Guest are viewing this topic.

LakySimi1

  • Newbie
  • *
  • Posts: 35
    • View Profile
Updating the sprite and show it works for few seconds
« 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)
« Last Edit: May 31, 2019, 11:27:46 am by LakySimi1 »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Updating the sprite and show it works for few seconds
« Reply #1 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

LakySimi1

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Updating the sprite and show it works for few seconds
« Reply #2 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)