/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.ZmbWvBkgSg9/rev.37 * * authors: * Natalia Valencia * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /* @pjs preload="/static/uploaded_resources/p.14209/chapulin.jpg"; */ Banner elBanner; PImage ch; void setup () { size (800,800); background (255); ch= loadImage("/static/uploaded_resources/p.14209/chapulin.jpg"); elBanner=new Banner(200); } void draw () { background (255,10); noTint(); image(ch,0,0,800,800); background (255,10); noTint(); image(ch,0,0,800,800); elBanner.dibujar(); elBanner.mover(); } class Banner { PFont f; float posx; float posy; float velx; String txtVisible1; int postxtVisible; String[]txt; Banner (float laposy) { txt=loadStrings("/static/uploaded_resources/p.14209/dichosChapulin.txt");//cargo el texto que quiero que cargar en la composicion //txt.length// me dice el numero de lineas del archivo f=loadFont ("AdobeGothicStd-Bold-60.vlw"); posx= width; posy= laposy; velx=-2; txtVisible1= txt[0]; postxtVisible=0;// //txt[0]="“No por mucho madrugar, cuchillo de palo.”"; //txt[1]="“En casa de herrero, se amanece más temprano.” "; //txt[2]= "“Silencio... mis antenitas de vinil están detectando la presencia del enemigo.”"; //txt[3]= "“Síganme los buenos.” "; //txt[4]= "“Se aprovechan de mi nobleza.”"; //txt[5]= "“No contaban con mi astucia.” "; //txt[6]= " Oh! Y ahora quien podrá defenderme?"; //txt[7]= "Lo sospeché desde un principio."; //txt[8]= "Es exactamente lo que iba yo a decir"; //txt[9]= "Chanfle! , Rechanfle!! , Recontrachanfle!!!"; } void dibujar() { textAlign (LEFT, CENTER); textFont(f,48); fill (0,150); smooth(); text(txtVisible1,posx,posy); } void mover () { posx=posx+velx; if (posx<0-textWidth (txtVisible1)) { //volver al extremo derecho posx=width; //cambiar el mensaje postxtVisible =postxtVisible+1; if ( postxtVisible==txt.length) { postxtVisible=0; } txtVisible1=txt[postxtVisible]; } } }