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

175
Visualizações
How can I remove a given element from an array of objects knowing only the contents of said object?

I am making an evolution simulator where food will spawn in the world and cells will go around and eat the food. However, the "eating" mechanic is going wrong, currently the food won't be deleted when eaten, which leads to infinite food supply and exponential growth of the population. Each food object is marked with a 2 on the 2d matrix world, and is also an element in an array called foodVec. The former issue is fixed(checks if a cell is occupying a marked space and unmarks it):

if(matrix[obj.x][obj.y] == 2){
    matrix[obj.x][obj.y] = 0;
}

but I need a reliable way of also removing this value from foodVec so the array doesn't just remark and replace the food particle next frame. How do I remove an object from an array knowing only its contents?

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