/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.3KciTS5UEuX/rev.15 * * authors: * Natalia Valencia * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ Pelicula[] peliculas; String urllove; int numMovieVisible; void setup() { size(600, 500); background(255); urllove = "http://www.omdbapi.com/?s=love&r=XML"; XML xmlPeliculas = loadXML( urllove ); XML[] etiquetasMovie = xmlPeliculas.getChildren("Movie"); int numHijos = etiquetasMovie.length; peliculas = new Pelicula[numHijos]; numMovieVisible = 0; int i = 0; while (i < numHijos) { String idPos = etiquetasMovie[i].getString("imdbID"); String titlePos = etiquetasMovie[i].getString("Title"); String typePos = etiquetasMovie[i].getString("Type"); String yearPos = etiquetasMovie[i].getString("Year"); peliculas[i] = new Pelicula(titlePos, yearPos, idPos, typePos); i = i + 1; } } void draw() { background(0); peliculas[numMovieVisible].pintarse(); if(peliculas[numMovieVisible].darPosX() < 0 ) { peliculas[numMovieVisible].reiniciar(); numMovieVisible = numMovieVisible + 1; if (numMovieVisible== peliculas.length) { numMovieVisible=0; } } } class Pelicula { float posx= 20; float posy= 200; int velx; PFont fuente; String titulo; String ano; String id; String tipo; String urlPoster; PImage imgPoster; float x; float y; String textoVisible; int numeroVisible; Pelicula(String elTitulo, String elano, String elId, String eltipo) { titulo = elTitulo; ano = elano; id = elId; tipo = eltipo; fuente= loadFont("BanglaMN-Bold-100.vlw"); posx= random(width); posy= random(height); velx= -2; XML xmlPelicula = loadXML("http://www.omdbapi.com/?i="+id+"&r=XML"); XML[] xmlHijosPelicula = xmlPelicula.getChildren("movie"); urlPoster = xmlHijosPelicula[0].getString("poster"); imgPoster = loadImage(urlPoster); x = width; y = 20; } void pintarse() { image(imgPoster, x, y); textFont(fuente, 40); fill(216, 10, 140, 200); text(tipo, posx, posy); text(titulo, posx, posy +40); text(ano, posx, posy+80); x = x + velx; posx= posx + velx; } void reiniciar() { x = width; y = 0; posx= -width; posy= -height; } float darPosX() { return x; } }