xxxxxxxxxx
44
let pics = []
let pic
let img
let test
function preload() {
pic = loadImage('pics/pic0.png');
for (let i = 0; i < 4; i++) {
pics[i] = loadImage('pics/pic' + i + '.png');
}
}
function setup() {
createCanvas(windowWidth, windowHeight)
myfun()
setInterval(myfun, 1000)
let x = 200
let y = 200
test = new Test(img, x, y)
}
function myfun() {
img = pics[Math.round(random(3))]
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
function draw() {
background(222)
test.show()
}
class Test {
constructor(img, x, y) {
this.img = img
this.x = x
this.y = y
}
show() {
image(this.img, this.x, this.y)
}
}