xxxxxxxxxx
51
var count=0
var x=200
var y=100
var widths=20
var bullet=[]
var heights=75
var fr=60
function setup() {
createCanvas(400, 400);
frameRate(fr)
for(var i=0;i<=count;i++) {
bullet[i]=new Bullet()
}
}
function draw() {
background(220);
if (keyIsDown(DOWN_ARROW)) {
count+=1
for(i=0;i<=count;i++) {
bullet[i]=new Bullet()
}
for (i=0;i<bullet.length;i++) {
bullet[i].move()
bullet[i].show()
}
}
rect(x,y,widths,heights)
}
class Bullet {
constructor(){
this.d=15
this.speed=6
this.x=x+widths/2
this.y=y+heights
}
show(){
circle(this.x,this.y,this.d)
}
move(){
this.y=this.y+this.speed
}
}