Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
How to generate different spawn points for objects (Javascript)?

I am having trouble creating different spawn points for each object, as shown below. I have 4 spawn points set up, however, all objects are spawning from i = 0. Any feedback would be great!

Thanks,

            var spawnX = 0;
            var spawnY = 0;

            function getSpawnX(i){
                if(i=0 || 4 || 8 || 12 || 16 || 20 || 24 || 28){
                    spawnX = width/4
                    return spawnX;
                }else{
                    spawnX = width/2
                    return spawnX;
                }
            }

            function getSpawnY(i){
                if(i=0 || 4 || 8 || 12 || 16 || 20 || 24 || 28){
                    spawnY = height/4
                    return spawnY;
                }else{
                    spawnY = width*(3/4)
                    return spawnY;
                }
            }

            for (let i = 0; i < numParticles; i++) { //creates array of objects 
             for each rect
                p[i] = particle.create(
                    //spawn points
                    getSpawnX(i), //x starting x point
                    getSpawnY(i), //y starting y point
                    Math.random() * 45 + 45 , // random  w (minimum 45, max 90)
                    Math.random() * 45 + 45 , // random h (minimum 45, max 90)
                    Math.random() * 15 * randomSign(), //random dx
                    Math.random() * 15 * randomSign() //random dy
                )
            }

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda