CodingTrain / CodingTrain/Suggestion-Box
my flower aint deleting
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 570
- Forks
- 85
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
So I'm trying to create a javascript space invaders game I got flowers, a spaceship & some bullet, but for some reason 2 of my 6 flowers refuse to be deleted no matter how many bullets i send into them. It starts off with 6 flowers and only 4 of them will allow me to delete them.

here the flower code:
`function Flower(x,y) {
this.x = x;
this.y = y;
this.r = 15;
this.life = 1;
this.toDelete = false;
this.xdir = 1;
this.grow = function(){
this.life -= 1;
if (this.life <= 0){
this.toDelete = true;
}
}
this.shiftDown = function(){
this.xdir *= -1;
this.y += this.r*2;
}
this.move = function() {
this.x = this.x + this.xdir;
}
this.show = function(){
fill(255,0,200);
ellipse(this.x,this.y,this.r*2,this.r*2);
}
}`
here the place where it is shown and deleted on the main
`var edge = false;
for (var i = 0; i < flowers.length; i++){
flowers[i].show();
flowers[i].move();
if (flowers[i].x > width || flowers[i].x < 0){
edge = true;
}
}
if (edge) {
for (var i = 0; i < flowers.length; i++){
flowers[i].shiftDown();
}
}
for (var i = drops.length-1; i > 1; i--){
if (drops[i].toDelete){
drops.splice(i,1);
}
}
for (var i = flowers.length-1; i > 1; i--){
if (flowers[i].toDelete){
flowers.splice(i,1);
}
}`
can anyone tell me why the flowers wont delete like the other 4? if need to see anymore just asked I copied it from space invaders coding train with an added life.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduce el juego e inspecciona el código de Flower y los bucles de eliminación incluidos en el issue, especialmente cómo se recorren los arrays después de marcar un objeto para su eliminación. Confirma que una bala puede eliminar cada flor y que los objetos restantes y el comportamiento del movimiento siguen siendo correctos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- game-dev
- Tipo de issue
- Error
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100