Skip to content

Instantly share code, notes, and snippets.

@furenku
Created September 17, 2020 20:12
Show Gist options
  • Select an option

  • Save furenku/5802e99b9897fb3020212ca43b4fde32 to your computer and use it in GitHub Desktop.

Select an option

Save furenku/5802e99b9897fb3020212ca43b4fde32 to your computer and use it in GitHub Desktop.
marco ejercicio
let grupoActual
let imagenActual = 0
let imagenes = {
grupoA: [
{
archivo: "imagenes/img1.png"
},
{
archivo: "imagenes/img2.png"
},
{
archivo: "imagenes/img3.png"
},
],
grupoB: [
{
archivo: "imagenes/img4.png"
},
{
archivo: "imagenes/img5.png"
},
{
archivo: "imagenes/img1.png"
},
],
}
function preload() {
// preparar sistema automaticamente a partir de db:
for( let [nombre,objetos] of Object.entries(imagenes) ) {
for( let o of objetos ) {
o.imagen = loadImage( o.archivo )
}
}
}
function setup() {
createCanvas(1000, 600 )
setInterval( ()=>{
if( grupoActual ) {
imagenActual++
imagenActual%=grupoActual.length
}
}, 300 )
}
function keyTyped() {
if( key == "a" ) {
grupoActual = imagenes.grupoA
}
if( key == "b" ) {
grupoActual = imagenes.grupoB
}
imagenActual = 0
}
function draw() {
if( grupoActual && imagenActual ) {
image( grupoActual[imagenActual].imagen, 0, 0, width, height )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment