Cuando llamo a image() desde la biblioteca p5.js, me da el error de tipo 'e no está definido', a pesar de darle la imagen. Soy bastante nuevo en javascript y completamente nuevo en p5.js. La idea es que haría que las siguientes imágenes cayesen en la pantalla desde una coordenada x e y aleatoria.
var yVal; var accel; var velocity; var mass; var pieces = [] function preload () { images = ["/images/L.png", "/images/LL.png", "/images/T.png"] img_amount = getRandomInt(21); for (var i = 1; i <= img_amount; i++) { var img = loadImage(images[getRandomInt(3)]); pieces[i-1] = img; } } function setup() { createCanvas(window.innerWidth, 700); yVal = []; velocity = []; mass = 10; accel = mass * 0.1; for (var i = 0; i <= img_amount; i++) { var randX = getRandomInt(window.innerWidth); var randY = getRandomInt(700); image(pieces[i], randX, randY, mass, mass); } } function draw() { background(25); fill(255,0,0); for (var i = 0; i <= img_amount; i++) { velocity[i] += accel; yVal[i] += velocity[i]; image(pieces[i], pieces[i].xvalue, yVal[i], mass, mass); if (yVal[i] > height - mass/2) { // A little dampening when hitting the bottom velocity[i] *= -0.6; yVal[i] = height - mass/2; } } } function getRandomInt(max) { return Math.floor(Math.random() * max); }