3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
restart the game
#300749
12/04/09 20:45
12/04/09 20:45
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67"...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
|
Hi, I'm programming on a 2D game and now I want to include a restart function. How can I do this? I tried to save the game at the begin and then to load it to restart, but it created and changed any panels during the game so I've got an error. Is there a way to delete everything who hinder the game_load or is there another way to restart a game (sans exec and sys_exit)?
Hilf mir, dir zu helfen!
|
|
|
Re: restart the game
[Re: hopfel]
#300824
12/05/09 16:05
12/05/09 16:05
|
Joined: Oct 2009
Posts: 90
WickWoody
Junior Member
|
Junior Member
Joined: Oct 2009
Posts: 90
|
If you make a 2D game, I think reset values etc. . Or first open game with use exec, later close first game with sys_exit. Example for my second suggestion:
function restart_game()
{
exec(GAME EXE's NAME, ""); // for start game
wait(1); // wait sometime
sys_exit(NULL); // exit previous game
}
function main()
{
on_enter = restart_game; // on enter key run function
}
Last edited by WickWoody; 12/05/09 16:07.
|
|
|
Re: restart the game
[Re: hopfel]
#300827
12/05/09 16:53
12/05/09 16:53
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67"...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
|
or is there another way to restart a game (sans exec and sys_exit)? With exec and sys_exit it's an ugly restart, and I don't know a game who restarts at that way... but anyway thx for your answer.
Hilf mir, dir zu helfen!
|
|
|
Re: restart the game
[Re: hopfel]
#301935
12/15/09 14:09
12/15/09 14:09
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67"...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
|
Ok, I tried to make a restart function, but it don't works; it's very strange, I wrote this function for the restart:
function restart() { stopper=1; //<-- delete all Panels, Entities etc. while(!key_q){test+=2*time_step;wait(1);} //<-- test-counter, I can see it ingame with digits(...); media_stop(0); sys_exit(""); }
When the Function starts, the test-value count up and stops at 0.65, but I didn't press the 'q' key. The function stops groundless; it gets stuck. It didn't react if I push 'q'. I can move the mouse, so the Engine didn't crash. Do someone knows, what might be the fault, that a function can get stuck? Thx for help ^^
Hilf mir, dir zu helfen!
|
|
|
Re: restart the game
[Re: MrGuest]
#302333
12/18/09 16:39
12/18/09 16:39
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67"...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
|
The problem is, every Panel has his own function. So, I tried this in the Panel-function:
if(stopper==1) test_pan.flags=NULL;
But the function gets stuck... It must be another function but I can't understand it... How can a function get stuck groundless? If I know how a function can get stuck, I can find the fail, perhabs.
Hilf mir, dir zu helfen!
|
|
|
Re: restart the game
[Re: hopfel]
#306808
01/25/10 04:06
01/25/10 04:06
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
A reset function is simply a level star function. It should do EVERYTHING. Set every var that is needed in the start position.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|