CodingTrain / CodingTrain/Suggestion-Box
my flower aint deleting
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 570
- Fork
- 85
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Riproduci il gioco ed esamina il codice di Flower e i cicli di eliminazione inclusi nell’issue, in particolare il modo in cui vengono attraversati gli array dopo che un oggetto è stato contrassegnato per l’eliminazione. Conferma che ogni fiore possa essere rimosso da un proiettile e che gli oggetti rimanenti e il comportamento del movimento restino corretti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- game-dev
- Tipo di issue
- Bug
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100