Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Resetting a game #387185
11/15/11 14:22
11/15/11 14:22
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Hi Folks, I am trying to restart the game upon completing a level, I was wonder what are the things like entites that needs to be reset?

like for entity there is the following is there something like this for panel?
Code:
you = ent_next(NULL);

while(you)
{
	ENTITY* temp = you;
	you = ent_next(you);
	ent_remove(temp);
}



Thanks!

Re: Resetting a game [Re: hanselkoh] #387315
11/17/11 08:59
11/17/11 08:59
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
Those entities which has no own global entity pointer assigned, are not required to be removed by ent_remove/ptr_remove, they are cleared by level_load().

If a global entity pointer is assigned, you should remove it, and set to NULL, like this:

Code:
ENTITY*  created_entity;

...somewhere after level load:
created_entity = ent_create("filename.mdl",nullvector,NULL);

...on closing the level, and before new level load:
ptr_remove(created_entity);
created_entity = NULL;



this way when you load the level again, you can create it again safely.

the same is valid for created panels.

Last edited by sivan; 11/17/11 09:00.

Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Resetting a game [Re: sivan] #387434
11/18/11 15:53
11/18/11 15:53
Joined: Dec 2009
Posts: 128
China
frankjiang Offline
Member
frankjiang  Offline
Member

Joined: Dec 2009
Posts: 128
China
just do it like this code:

...
ptr_remove(ent);
ent = NULL;


development 3d game is interesting!
Re: Resetting a game [Re: frankjiang] #387437
11/18/11 16:04
11/18/11 16:04
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Thank you for all the suggestion, 1 more thing is regarding the timer, it seems like everytime I restart the game there seems to be another thread in the schedule list.

Like an example below, saying I have a loop to spawn enemies, so by right the enemy will spawn everytime when respawnTime reach 0. but after I restart the game, it will spawn before reaching 0, it felt as there were another thread behind.

var respawnTime = -1;

while(!gameOverFlag)
{
respawnTime -= time_step;
showTimeOnScreen = respawnTime;

if(respawnTime <= 0)
{
respawnTime = 200;
}

wait(1);
}

So my question here now is, if it is possible to clear the threads in the schedule list when I restart the game?

Thanks for reading.

Re: Resetting a game [Re: hanselkoh] #387455
11/18/11 21:00
11/18/11 21:00
Joined: Dec 2009
Posts: 128
China
frankjiang Offline
Member
frankjiang  Offline
Member

Joined: Dec 2009
Posts: 128
China
better code like this,you can save your object`s addrsss, and remove them .
//save your object address;
int point[10];

int i;
for(i=0;i<3;i++)
{
ENTITY* e = ent_create("resourceflod//baul_armed.mdl",vector(0,100*i,0),NULL);
point[i] = e;
}

//clear your scene now
for(i=0;i<3;i++)
{
ptr_remove(point[i]);
wait(24);
}


Last edited by frankjiang; 11/18/11 21:03.

development 3d game is interesting!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1