Created
September 17, 2020 20:12
-
-
Save furenku/5802e99b9897fb3020212ca43b4fde32 to your computer and use it in GitHub Desktop.
marco ejercicio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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