Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / exit dosent work(using return;)

Author
Message
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Apr 2009 16:14
wtf:! i started on my new project and for some reason the return;
code which is what i use for exiting in my othere games.
but now dosent work :S
if i use somethink else then return; like dbHideSprite(2);
the sprite is hidden as it should.
here is the code:


Game.Love
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 13th Apr 2009 17:38
The return keyword in this block:


Will only return out of that function. What it does is just exit out of that function wherever it is called, but it doesn't exit the program. Right after it exits out of that function, it will go back to the function it came from, and everything is running from while(LoopGDK()). You need some way to communicate (perhaps a bool) with 'while(LoopGDK())', so that if the bool is true, the while loop breaks.

Try this:


But I didn't test it, so there could be a typo.

#ifdef _DEBUG
FixBugs(All);
#endif
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 13th Apr 2009 17:46
thank you brank flakes but i found out there is a function called
exit(int_code);
so i randomly just
used
exit(1);
and it works.
it would be great doe if someone could tell me why is it 1=! that works,
just to be shure in the future

Game.Love
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 13th Apr 2009 18:40
Programs end with an integer telling if they ended with errors or not usually for debugging purposes. In a basic c++ console program the main function does just that.



So exit(0) will exit with a return code of 0 and exit(1) with 1.

#ifdef _DEBUG
FixBugs(All);
#endif
nadir
16
Years of Service
User Offline
Joined: 18th May 2008
Location:
Posted: 13th Apr 2009 19:22
hi guys i had the same problem right few minutes ago :
the thing: you need to write "return;" in the DarkGDK Loop
do not write it in a void-function or something
maybe this is not the correct solution but it was so in my code

Attachments

Login to view attachments
KernMist
15
Years of Service
User Offline
Joined: 17th Apr 2009
Location:
Posted: 17th Apr 2009 16:00
Calling return in the main DarkGDK loop will simply exit that main function there and then, completely skipping any cleanup code you might have after the main loop...

Login to post a reply

Server time is: 2024-11-25 14:29:53
Your offset time is: 2024-11-25 14:29:53