xxxxxxxxxx
54
let w=900
let h=750
let x=w/2
let y=100
let robot
let lasers=[]
function setup() {
createCanvas(w, h);
robot=loadImage('robot.png')
}
function draw() {
background(0);
image(robot,x,y,300,300)
/*strokeWeight(1)
circle(x,y,100)
circle(x,y+175,200)
stroke(255)
strokeWeight(20)
line(x,y,x,y+175)
line(x-50,y+175,x-50,y+425)
line(x+50,y+175,x+50,y+425)
line(x-225,y+175,x+225,y+175)54lsmzvchtrqnf6vt780rils9fly7m.yhbnt3p.,t4gdc*/
if(keyIsDown(DOWN_ARROW)){
y++
}
if(keyIsDown(UP_ARROW)){
y--
}
if(keyIsDown(LEFT_ARROW)){
x--
}
if(keyIsDown(RIGHT_ARROW)){
x++
}
if(keyIsDown(32)){
lasers.push(new laser(x+300,y+150))
}
for(let i=0;i<lasers.length;i++){
lasers[i].shoot()
}
}
class laser{
constructor(x,y){
this.x=x
this.y=y
}
shoot(){
this.x++
stroke('orange')
strokeWeight(10)
point(this.x,this.y)
}
}