Is it possible to use WaitEvent() in continuous program?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

Is it possible to use WaitEvent() in continuous program?

Post by Bugala »

I know there is CheckEvent(), and I have been using it, but since Andreas warns from using it, I have been thinking if WaitEvent could replace my needs.


Problem with WaitEvent is that as far as i understand it, program stops until something happens.

But I would like something to happen at same time.

As example, I am right now making a turn based game, and I am using buttons to handle pretty much everything.

However, What I would like to happen is that while WaitEvent() is waiting for something to happen, I would want some animations to happen on bacground, like unit ywaning, buttoimages flashing or something similar.

Is there any possibity to this with WaitEvent()?


If not, then is it possible to limit what all CheckEvent() keeps checking?

For what Andreas once mentioned is that using CheckEvent() makes it look through every possible place if something have happened.

I have been using CheckEvent() before, and while games itself seem to work fine, if you do something on background, there can happen lot of distortion from using that.


Therefore what I am thinking is that if i could limit CheckEvent() to just check all the created buttons for example, maybe that would solve my problem, or should i just abandon the buttons and replace them with layers with my own routines?
jalih
Posts: 281
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Is it possible to use WaitEvent() in continuous program?

Post by jalih »

Bugala wrote: However, What I would like to happen is that while WaitEvent() is waiting for something to happen, I would want some animations to happen on background, like unit ywaning, button images flashing or something similar.

Is there any possibity to this with WaitEvent()?
Use timer callback?
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Is it possible to use WaitEvent() in continuous program?

Post by djrikki »

Never use CheckEvent() just have a repeat..forever loop with all your code and functions initialiZed by InstallEventHandler(). For all animations that can start and stop through the course of play use SetInterval(). Whenever you need to pause them elsewhere in the program you can use ClearInterval() or alternatively leave interval functions running all the time and use conditioning code as necessary. If you use many displays I found it easier to use ClearInterval().
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Is it possible to use WaitEvent() in continuous program?

Post by djrikki »

For a working example of Events, Intervals and animation playback working together you can check out the sourcecode in this small app of mine on os4depot.

http://os4depot.net/index.php?function= ... e_code.lha
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

Re: Is it possible to use WaitEvent() in continuous program?

Post by Bugala »

Thanks from these tips, I will check about these things.
Post Reply