mardi 1 septembre 2020

p5 editor trying to make a project with objects to spawn randomly

i am making a project in which i have to make objects randomly appear in the game i am just a beginner so i cant figure out what is happening the error is randomly coming on numbers so i think it is a prob with the if select statement pls help me

  if (World.frameCount % 80 == 0){
    if (select_baloon == 1) {
      baloon1();
    }
    if (select_baloon == 2) {
      baloon2();
    }
    if (select_baloon == 3) {
      baloon3();
    }
    if (select_baloon == 4) {
      baloon4();
    }
    
  }
  
  function Baloon1() {
    var baloon1 = createSprite(0,Math.round(random(20,370)) , 10,10) ;
    baloon1.addImage("baloon" , baloon1.img );
    baloon1.velocityX = -3;
    baloon1.lifetime = 150;
    baloon1.scale = 0.1
  }
  
   function Baloon2() {
    var baloon2 = createSprite(0,Math.round(random(20,370)) , 10,10) ;
    baloon2.addImage("baloon2" , baloon2.img );
    baloon2.velocityX = -3;
    baloon2.lifetime = 150;
    baloon2.scale = 0.1
  }
   function Baloon3() {
    var baloon3 = createSprite(0,Math.round(random(20,370)) , 10,10) ;
    baloon3.addImage("baloon3" , baloon3.img );
    baloon3.velocityX = -3;
    baloon3.lifetime = 150;
    baloon3.scale = 0.1
  }
   function Baloon4() {
    var baloon4 = createSprite(0,Math.round(random(20,370)) , 10,10) ;
    baloon4.addImage("baloon4" , baloon4.img );
    baloon4.velocityX = -3;
    baloon4.lifetime = 150;
    baloon4.scale = 0.1
  }
  



Aucun commentaire:

Enregistrer un commentaire