Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Is it possible to load and display different gifs into an array in p5.js?

Hello I'm a pretty new programmer working on a project where I'm trying to fill a pond with different color fish. I've drawn 7 gifs for 7 different fish. I uploaded them to an assets folder and used a loop to store them into an array.

Now, the code will display the different fish at random as I wanted but they are still images instead of animated gifs. (which works if I only upload/reference one gif at a time). Anyone have any ideas about why this might be happening/how to fix it? Thanks so much! Code below for setup()

let school = [];
let fishes = [];

function preload() {
  // koi = loadImage("assets/fish5.gif");
  for (let i = 1; i < 8; i++) {
    fishes[i] = loadImage("assets/fish" + i + ".gif");
  }
}

function setup() {
  createCanvas(840, 560);
  // let fish = random(fishes);
  for (let i = 0; i < 30; i++) school.push(new Fish());
}

function draw() {
  background(132, 209, 220);
  for (let fish of school) {
    fish.edges();
    fish.school(school);
    fish.update();
    fish.show();
  }
}

Image of what i'm getting below

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda