Advertisement
Guest User

lunatic

a guest
Apr 26th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. function = Lunatic(x,y,grille,ageMin, ageMax, minRep){
  2. this.x=x;
  3. this.y=y;
  4. this.rep= r || 0,1;
  5. this.minAge= minAge || 10;
  6. this.maxAge= maxAge || 110;
  7. this.minRepAge= minRep || 20;
  8.  
  9. this.age= 0;
  10. this.alive = true;
  11.  
  12. this.wasBorn= false;
  13. this.wasKilled= false;
  14. this.lifeSpan= Helper.randomBetween(this.minAge, this.maxAge);
  15.  
  16. this.map=map;
  17. }
  18.  
  19. //reproduction
  20. if (Math.random() <=0.1) PAS DE BEBE elses BEBE
  21.  
  22. Lunatic.prototype.epoch = function(){
  23. this.x+=1
  24. grille.isPositionACoteLibre(x,y)
  25. }
  26.  
  27. //ajouter personnages
  28. lunatics_tab= [];
  29. for() {
  30. lunatics_tab.push(new Lunatic (...))
  31. }
  32.  
  33. var lunatic = new Lunatic (0,0);
  34. grille [lunatic.y][lunatic.x]= lunatic;
  35.  
  36. for (var i=0; i<this.epoch; i++){
  37. mihai.epoch();
  38. print(dessinerGrille(grille,largeur,hauteur));
  39. };
  40.  
  41. //// ex de mihai pour aider? ////
  42.  
  43. /*function Lunatic(x,y){
  44. this.x=x;
  45. this.y;
  46. this.age=0;
  47. };
  48.  
  49. lunatic.protoype.epoch=function(){
  50. grille[this.y][this.x]= null;
  51. this.x = this.x++%largeur;
  52. grille[this.y][this.x]= this;
  53. };
  54.  
  55. lunatics_tab= []; //pour accumuler les nouveaux personnages
  56. for() {
  57. lunatics_tab.push(new Lunatic (...))
  58. }
  59. //var mihai c un exemple de comment faire
  60. var mihai= new Lunatic(0,0);
  61. grille[mihai.y][mihai.x]=mihai;
  62.  
  63.  
  64. for (var i=0; i<this.epoch; i++){
  65. mihai.epoch();
  66. print(dessinerGrille(grille,largeur,hauteur));
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement