We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, since Quarks launched his brilliant AI_4_Games library I am testing it for a future project of a game. Until right now the lib was working just perfect, but now I am stuck with something. I am not having success using the world.birth(BaseEntity entity,double timeToBirth); method. We are not supposed to use world.add(...) after the setup (indeed, it crashes the program), but the birth method does seems to add a new MovingEntity.
I tried to look at the World.java code, and I may have fund the problem (or not). I think the if logic is wrong:
public void birth(BaseEntity entity, double timeToBirth){
if(entity != null && allEntities.containsKey(entity.ID()))
entityChangeList.add(new Changling(entity, timeToBirth, false));
}
It shouldn't be if(entity != null && !allEntities.containsKey(entity.ID()))
? Since the entity is not yet born, its ID should not be in allEnteties list.
Or am I doing something else wrong?
Thanks, StefanW
Answers
Hi StefanW
Glad to see you having a go with this library.
I have double checked the source code and can confirm that you are right..., I made a mistake :\">
If I understand the problem correctly it will not allow you to give birth to an entity unless it had been added in setup with world.add(...) - which obviously defeats the purpose - if is this correct then let me know and I will rush out a new version.
Quark
Hi Quarks,
that's right. I am trying to give birth to a new entity in the middle of the game, but the entity doesn't come to life. So I figured out it may be this logic problem on the world.birth(...) method. I would be very glad if you could fix that :D
Thanks, StefanW
You can download the latest version (1.0.1) from here
Thanks for reporting the bug but more thanks for identifying the problem code =D> - saved me a lot of bother.