Bennu Game Development

Foros en Español => Mesa de Ayuda => Topic started by: Yawin on January 24, 2013, 01:04:29 PM

Title: Saber tipo de proceso del padre
Post by: Yawin on January 24, 2013, 01:04:29 PM
Os comento mi problema:


Tengo diseñado el proceso disparo al que lo llaman los procesos enemigo y nave. Y, claro, depende de quién lo llame, su comportamiento es distinto. ¿Hay algo que sirva para saber qué tipo de proceso es el padre?
Title: Re:Saber tipo de proceso del padre
Post by: alex on January 24, 2013, 01:29:59 PM
Modifica la llamada al proceso disparo es una opcion... Sobre lo que dices, con get_id(father) a lo mejor
Title: Re:Saber tipo de proceso del padre
Post by: panreyes on January 24, 2013, 01:39:57 PM

Lo recomendable es utilizar variables locales para averiguar cosas entre diferentes procesos.


De todas formas se puede averiguar el nombre del proceso, pero no es la forma más recomendable.


Para ello tendrás que utilizar un bucle, get_id(father) y una comparación con cada tipo de proceso que quieras comprobar.



tipo=0;
while(posible_id=get_id(type proceso1) and tipo==0)
  if(posible_id==father.id) tipo=1; break; end
end
while(posible_id=get_id(type proceso1) and tipo==0)
  if(posible_id==father.id) tipo=2; break; end
end
while(posible_id=get_id(type proceso1) and tipo==0)
  if(posible_id==father.id) tipo=3; break; end
end
while(posible_id=get_id(type proceso1) and tipo==0)
  if(posible_id==father.id) tipo=4; break; end
end



Por otro lado, si utilizas variables locales lo tendrás mucho más fácil:



Local
  tipo;
Begin
  tipo=4;
  gorila();
  while(!key(_esc)) frame; end
End


Process gorila();
Begin
  write(0,0,0,0,father.tipo);
End
Title: Re:Saber tipo de proceso del padre
Post by: SplinterGU on January 24, 2013, 02:45:31 PM
repetido...

variable local

reserved.process_type
Title: Re:Saber tipo de proceso del padre
Post by: Yawin on January 24, 2013, 03:03:57 PM
gracias! Al final he optado por crear un proceso a parte llamado disparoenemigo. Era mucho lio de colisiones. Así más fácil.