Is It possible to clear WaitEvent() in middle of event?

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

Is It possible to clear WaitEvent() in middle of event?

Post by Bugala »

I was first making the ingame things and was using WaitEvent() for things.

However, Now I finally made a Titlescreen test and came into bit of a problem.

I use WaitEvent to check if "startgame" button is pressed, and if so, then it starts the game. Since InGame also has WaitEvent() inside it, it means that the ingame waitevent is called inside another waitevent, and hence error quits the program.

I already made the program so that it uses the same waitevent command for titlescreen as well as ingame stuff, but I am bit worried about my current solution and think that it would be safer if I could use own Waitevent inside the ingame function.

Is there therefore a way to clear current waitevent and preferably without exiting the current waitevent event.

For what I am hoping to be able to do is that when InGame event is woke up, its first line would be something like "ClearEvents()" and after that when next WaitEvent() comes, it would be the only WaitEvent() in execution.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Is It possible to clear WaitEvent() in middle of event?

Post by airsoftsoftwair »

Bugala wrote:I already made the program so that it uses the same waitevent command for titlescreen as well as ingame stuff, but I am bit worried about my current solution and think that it would be safer if I could use own Waitevent inside the ingame function.
No, you should always only use a single WaitEvent() call for your main loop. It's possible. Just set some flags that indicate whether you are in game or menu mode. Calling WaitEvent() from event handlers invoked by WaitEvent() is very bad practice and Hollywood will not allow this.
Post Reply