0
Why won't this code work?
I was working on this code, amd it worked. I saved it and took a break, but when I came back, the circle that should have been appearing was gone. I'm not sure what happened and can't find anything wrong. https://sololearn.com/compiler-playground/Wc5anUbfe1l9/?ref=app
5 Antworten
0
Hi.👋
string 27:
//add circle brackets Date.now()
+ 2
Thanks for the tip
0
Thanks so much
0
👍🏻👍🏻👍🏻
0
u can store the enemies inside an array
let enemyes=[{x:5,y:7},{x:8,y:2}]
then to render them
just loop in enemies
```
for(let i in enemies){
ctx.circle(enemies[i].x,enemies[i].y,20,0,Math.Pi);
ctx.fill();
}
or use classe
class enemy{
constructor(x,y){
this.x=x;
this.y=y;
}
}
and store them in an array
let enemies=[new enemy(5,7),new enemy(8,2)];
and u can add an enemy by using
enemyes.push(new enemy(50,79));
and use the same loop to render them