Primer acercamiento a Processing

Formas, texto y color

Uno de los primeros ejercicios de práctica que subieron al foro. La consigna consistía en resolver el trabajo usando únicamente líneas.

  • Ver código
    void setup(){
    size(500, 500); }
    void draw() {
    background(240);
    line(50, 450, 250, 50);
    line(250, 50, 450, 450);
    line(50, 450, 450, 450);
    line(200, 150, 300, 150);
    line(200, 150, 250, 250);
    line(250, 250, 300, 150);
    line(150, 250, 350, 250);
    line(150, 250, 200, 350);
    line(200, 350, 250, 250);
    line(250, 250, 300, 350);
    line(300, 350, 350, 250);
    line(100, 350, 400, 350);
    line(100, 350, 150, 450);
    line(150, 450, 200, 350);
    line(200, 350, 250, 450);
    line(250, 450, 300, 350);
    line(300, 350, 350, 450);
    line(350, 450, 400, 350);
    }

Es la primera consigna que completamos en el foro. Trabajamos figuras, distintos rellenos y texto. (Comisión 4, Leonardo Garay)

  • Ver código
    void setup(){
    size(400, 400);
    background(240);
    strokeWeight(1);
    fill(0, 255, 0);
    rect(250, 50, 100, 100);
    fill(0, 0, 255);
    ellipse(300, 300, 100, 100);
    fill(0);
    textSize(16);
    text("Esto es un cuadrado verde", 15, 100);
    text("Esto es una ellipse azul", 15, 300); }

Primer trabajo práctico obligatorio del año. La consigna consistía en realizar un círculo cromático (libre elección).

  • Ver código
    void setup() {
    size(600, 600);
    background(255);
    }
    void draw() {
    strokeWeight(5);
    stroke(0, 255, 0);
    line(50, 300, 300, 300);
    stroke(255, 0, 0);
    size(600, 600);
    background(255);
    line(50, 300, 300, 300);
    line(300, 300, 550, 300);
    line(300, 50, 300, 300);
    line(300, 300, 300, 550);
    line(125, 125, 300, 300);
    line(300, 300, 475, 475);
    line(125, 475, 300, 300);
    line(300, 300, 475, 125);
    noStroke();
    fill(255, 255, 0);
    ellipse(300, 50, 50, 50); fill(0, 255, 0);
    ellipse(50, 300, 50, 50);
    fill(0, 0, 255);
    ellipse(300, 550, 50, 50);
    fill(255, 0, 0);
    ellipse(550, 300, 50, 50);
    fill(255, 255, 0);
    ellipse(300, 150, 50, 50);
    fill(150, 255, 0);
    ellipse(200, 200, 50, 50);
    fill(0, 255, 0);
    ellipse(150, 300, 50, 50);
    fll(0, 255, 255);
    ellipse(200, 400, 50, 50);
    fill(0, 0, 255);
    ellipse(300, 450, 50, 50);
    fill(255, 0, 255);
    ellipse(400, 400, 50, 50);
    fill(255, 0, 0);
    ellipse(450, 300, 50, 50);
    fill(251, 112, 0);
    ellipse(400, 200, 50, 50);
    fill(210, 255, 0);
    ellipse(230, 60, 30, 30);
    fill(190, 255, 0);
    ellipse(175, 85, 30, 30);
    fill(150, 255, 0);
    ellipse(125, 125, 30, 30);
    fill(100, 255, 0);
    ellipse(85, 170, 30, 30);
    fill(50, 255, 0);
    ellipse(62, 225, 30, 30);
    fill(0, 255, 90);
    ellipse(62, 375, 30, 30);
    fill(0, 255, 150);
    ellipse(85, 430, 30, 30);
    fill(0, 255, 255);
    ellipse(125, 475, 30, 30);
    fill(0, 180, 255);
    ellipse(175, 515, 30, 30);
    fill(0, 80, 255);
    ellipse(230, 540, 30, 30);
    fill(80, 0, 255);
    ellipse(370, 540, 30, 30);
    fill(180, 0, 255);
    ellipse(425, 515, 30, 30);
    fill(255, 0, 255);
    ellipse(475, 475, 30, 30);
    fill(255, 0, 180);
    ellipse(515, 430, 30, 30);
    fill(255, 0, 80);
    ellipse(538, 375, 30, 30);
    fill(255, 50, 0);
    ellipse(538, 225, 30, 30);
    fill(255, 100, 0);
    ellipse(515, 170, 30, 30);
    fill(251, 112, 0);
    ellipse(475, 125, 30, 30);
    fill(255, 160, 0);
    ellipse(425, 85, 30, 30);
    fill(255, 200, 0);
    ellipse(370, 60, 30, 30);
    }

Animación e interactividad

El ejercicio consistía en realizar un cuadrado que se desplace con las flechas del teclado.

  • Ver código
    int posx, posy, tam;
    void setup() {
    size(500, 400);
    rectMode(CENTER);
    posx = width/2;
    posy = height/2;
    tam = 50;
    } void draw() {
    rect(posx, posy, tam, tam);
    }
    void keyPressed(){
    if ( keyCode == LEFT) {
    posx = posx - tam;
    }
    else if (keyCode == RIGHT) {
    posx = posx + tam;
    } else if (keyCode == UP) {
    posy = posy - 50;
    } else if (keyCode == DOWN) {
    posy = posy + 50; }
    }

El programa permite dibujar como si fuese un lápiz únicamente en el área gris.

  • Ver código
    int pos1, pos2, pos3, alto;
    boolean posicion;
    void setup() {
    size(600, 500);
    pos1 = width/6;
    pos2 = width/2;
    pos3 = width/3;
    alto = height;
    } void draw() {
    posicion = ((mouseX > 0 && mouseX < pos1) || (mouseX > pos3 && mouseX < pos2) || (mouseX > alto && mouseX < width)
    && (pmouseX > 0 && pmouseX < pos1) || (pmouseX > pos3 && pmouseX < pos2) || (pmouseX > alto && pmouseX < width));
    noStroke();
    rect(pos1, 0, pos1, alto);
    rect(pos2, 0, pos3, alto);
    if (posicion) {
    stroke(1);
    line(pmouseX, pmouseY, mouseX, mouseY); }
    }

En la medida que el cursor se desplaza por la pantalla, se van pintando los colores.

  • Ver código
    int fondo1, fondo2, fondo3, valor;
    void setup(){
    size(600, 600);
    background(255);
    valor = 255;
    }
    void draw(){
    fondo1 = round(map(mouseX, 0, 200, 255, 0));
    fill(valor, fondo1, fondo1);
    noStroke();
    rect(0,0,200,height);
    fondo2 = round(map(mouseX, 200, 400, 255, 0));
    fill(fondo2, valor, fondo2);
    rect(200, 0, 200, height);
    fondo3 = round(map(mouseX, 400, 600, 255, 0));
    fill(fondo3, fondo3, valor);
    rect(400, 0, 600, height);
    }

Trabajo práctico n°2: Créditos

El trabajo práctico consistió en armar los créditos de una película, serie o videojuego a elección.

En mi caso, elegí tomar parte de los créditos de la película "Ratatouille", mi película animada preferida, y los adapté y recreé en Processing. Intenté respetar la tipografía. Las imágenes son ilustraciones tomadas de la película.


PFont italic, sarif, s2;
PImage bground, endcred;

float posy1 = height + 600, posy2 = posy1 + 70, posy3 = posy2 + 70, posy4 = posy3 + 100, posy5 = posy4 + 70, posy6 = posy5 + 125, posy7 = posy6 + 70, posy8 = posy7 + 70;
float posy9 = posy8 + 70, posy10 = posy9 + 70, posy11 = posy10 + 70, posy12 = posy11 + 110, posy13 = posy12 + 70, posy14 = posy13 + 70, posy15 = posy14 + 150, posy16 = posy15 + 70;
float posy17 = posy16 + 70, posy18 = posy17 + 70, posy19 = posy18 + 70, posy20 = posy19 + 70, posy21 = posy20 + 70, posy22 = posy21 + 70, posy23 = posy22 + 7, posy24 = posy23 + 70;
float posy25 = posy24 + 70, posy26 = posy25 + 70, posy27 = posy26 + 70, posy28 = posy27 + 250, posy29 = posy28 + 45, posy30 = posy29 + 45, posy31 = posy30 + 45, posy32 = posy31 + 45;
float posy33 = posy32 + 45, posy34 = posy33 + 45, posy35 = posy34 + 45, posy36 = posy35 + 45, posy37 = posy36 + 45, posy38 = posy37 + 45, posy39 = posy38 + 45, posy40 = posy39 + 45;
float posy41 = posy40 + 45, posy42 = posy41 + 45, posy43 = posy42 + 45, posy44 = posy43 + 45, posy45 = posy44 + 45, posy53 = 4980, posy54 = posy53 + 50, posy55 = posy54 + 40;
float posy56 = posy55 + 80, posy57 = posy56 + 30, posy58 = posy57 + 100, posy59 = posy58 + 30, posy60 = posy59 + 480, posy61 = posy60 + 50, posy62 = posy61 + 40, posy63 = posy62 + 40;
float posy64 = posy63 + 40, posy65 = posy64 + 40, posy66 = posy65 + 40, posy67 = posy66 + 80, posy69 = posy67 + 80, posy70 = posy69 + 40, posy71 = posy70 + 120, posy72 = posy71 + 40;
float posy73 = posy72 + 40, posy74 = posy73 + 40, posy75 = posy74 + 40, posy76 = posy75 + 40, posy77 = posy76 + 40, posy79 = posy77 + 90, posy80 = posy79 + 40, posy81 = posy80 + 200;
float posy82 = posy81 + 40, posx1 = 4900, posx2 = -8400, posx3 = -8550, speedY = 1.2, speedX = 1.3, speedX2 = 1.4;

void setup() {
size(1000, 600);
italic = loadFont("FreestyleScript-Regular-45.vlw");
sarif = loadFont("MVBoli-25.vlw");
s2 = loadFont("TimesNewRomanPSMT-23.vlw");
bground = loadImage("Fondo1.jpg");
endcred = loadImage("Endcredits.jpg");
}
void draw() {
image(bground, 0, 0, width, height);
float miColor1 = map (mouseX, 0, 1000, 0, 255);
float miColor2 = map (mouseX, 0, 1000, 0, 55);
float miColor3 = map (mouseX, 0, 1000, 0, 3);
fill(miColor1, miColor2, miColor3);
textFont(s2);
textAlign(RIGHT);
text("Screenwriter and Director", 500, posy1);
text("Produced by", 500, posy2);
text("Executive Producers", 500, posy3);
text("Associate Producer", 500, posy4);
text("Original Story by", 500, posy5);
text("Music by", 500, posy6);
text("Story Supervisor", 500, posy7);
text("Film Editor", 500, posy8);
text("Supervision Technical Director", 500, posy9);
text("Production Designer", 500, posy10);
text("Supervising Animators", 500, posy11);
text("Director of Photography & Lighting", 500, posy12);
text("Director of Photography & Camera", 500, posy13);
text("Character Design", 500, posy14);
text("Character Supervisor", 500, posy15);
text("Sets Art Director", 500, posy16);
text("Sets Supervisor", 500, posy17);
text("Shading Art Director", 500, posy18);
text("Shading Supervisor", 500, posy19);
text("Global Technology Supervisor", 500, posy20);
text("Effects Supervisor", 500, posy21);
text("Simulation Supervisor", 500, posy22);
text("Groom Supervisor", 500, posy23);
text("Crowds Supervisor", 500, posy24);
text("Production Manager", 500, posy25);
text("Sound Designer", 500, posy26);
text("Casting by", 500, posy27);
textFont(italic);
textAlign(LEFT);
textSize(50);
text("Brad Bird", 550, posy1);
text("Brad Lewis", 550, posy2);
textLeading(30);
text("John Lasseter\nAndrew Stanton", 550, posy3);
textLeading(50);
text(" Galyn Susman", 550, posy4);
textLeading(30);
text("Jan Pinkava\nJim Capobianco\nBrad Bird", 550, posy5);
textLeading(50);
text("Michael Giacchino", 550, posy6);
text("Mark Andrews", 550, posy7);
text("Darren Holmes A.C.E", 550, posy8);
text("Michael Fong", 550, posy9);
text("Harley Jessup", 550, posy10);
text("Dylan Brown\nMark Walsh", 550, posy11);
text("Sharon Calahan", 550, posy12);
text("Robert Anderson", 550, posy13);
textLeading(30);
text("Jason Deamer\nGreg Dykstra\nCarter Goodrich\nDan Lee", 550, posy14);
textLeading(50);
text("Brian Green", 550, posy15);
text("Robert Kondo", 550, posy16);
text("David Gisenmann", 550, posy17);
text("Belinda Van Valkenburg", 550, posy18);
text("Daniel McCoy", 550, posy19);
text("William Reeves", 550, posy20);
text("Apura Shah", 550, posy21);
text("Christine Waggoner", 550, posy22);
text("Sanjay Bakshi", 550, posy23);
text("Ziah Sarah Fogel", 550, posy24);
text("Nicole Paradis Grindle", 550, posy25);
text("Randy Thom", 550, posy26);
textLeading(30);
text("Kevin Reher\nNatalie Lyon", 550, posy27);

posy1-= speedY;
posy2-= speedY;
posy3-= speedY;

posy4-= speedY;
Font italic, sarif, s2;
PImage bground, endcred;
float posy1 = height + 600, posy2 = posy1 + 70, posy3 = posy2 + 70, posy4 = posy3 + 100, posy5 = posy4 + 70, posy6 = posy5 + 125, posy7 = posy6 + 70, posy8 = posy7 + 70;
float posy9 = posy8 + 70, posy10 = posy9 + 70, posy11 = posy10 + 70, posy12 = posy11 + 110, posy13 = posy12 + 70, posy14 = posy13 + 70, posy15 = posy14 + 150, posy16 = posy15 + 70;
float posy17 = posy16 + 70, posy18 = posy17 + 70, posy19 = posy18 + 70, posy20 = posy19 + 70, posy21 = posy20 + 70, posy22 = posy21 + 70, posy23 = posy22 + 7, posy24 = posy23 + 70;
float posy25 = posy24 + 70, posy26 = posy25 + 70, posy27 = posy26 + 70, posy28 = posy27 + 250, posy29 = posy28 + 45, posy30 = posy29 + 45, posy31 = posy30 + 45, posy32 = posy31 + 45;
float posy33 = posy32 + 45, posy34 = posy33 + 45, posy35 = posy34 + 45, posy36 = posy35 + 45, posy37 = posy36 + 45, posy38 = posy37 + 45, posy39 = posy38 + 45, posy40 = posy39 + 45;
float posy41 = posy40 + 45, posy42 = posy41 + 45, posy43 = posy42 + 45, posy44 = posy43 + 45, posy45 = posy44 + 45, posy53 = 4980, posy54 = posy53 + 50, posy55 = posy54 + 40;
float posy56 = posy55 + 80, posy57 = posy56 + 30, posy58 = posy57 + 100, posy59 = posy58 + 30, posy60 = posy59 + 480, posy61 = posy60 + 50, posy62 = posy61 + 40, posy63 = posy62 + 40;
float posy64 = posy63 + 40, posy65 = posy64 + 40, posy66 = posy65 + 40, posy67 = posy66 + 80, posy69 = posy67 + 80, posy70 = posy69 + 40, posy71 = posy70 + 120, posy72 = posy71 + 40;
float posy73 = posy72 + 40, posy74 = posy73 + 40, posy75 = posy74 + 40, posy76 = posy75 + 40, posy77 = posy76 + 40, posy79 = posy77 + 90, posy80 = posy79 + 40, posy81 = posy80 + 200;
float posy82 = posy81 + 40, posx1 = 4900, posx2 = -8400, posx3 = -8550, speedY = 1.2, speedX = 1.3, speedX2 = 1.4;

void setup() {
size(1000, 600);
italic = loadFont("FreestyleScript-Regular-45.vlw");
sarif = loadFont("MVBoli-25.vlw");
s2 = loadFont("TimesNewRomanPSMT-23.vlw");
bground = loadImage("Fondo1.jpg");
endcred = loadImage("Endcredits.jpg");
}
void draw() {
image(bground, 0, 0, width, height);
float miColor1 = map (mouseX, 0, 1000, 0, 255);
float miColor2 = map (mouseX, 0, 1000, 0, 55);
float miColor3 = map (mouseX, 0, 1000, 0, 3);
fill(miColor1, miColor2, miColor3);
textFont(s2);
textAlign(RIGHT);
text("Screenwriter and Director", 500, posy1);
text("Produced by", 500, posy2);
text("Executive Producers", 500, posy3);
text("Associate Producer", 500, posy4);
text("Original Story by", 500, posy5);
text("Music by", 500, posy6);
text("Story Supervisor", 500, posy7);
text("Film Editor", 500, posy8);
text("Supervision Technical Director", 500, posy9);
text("Production Designer", 500, posy10);
text("Supervising Animators", 500, posy11);
text("Director of Photography & Lighting", 500, posy12);
text("Director of Photography & Camera", 500, posy13);
text("Character Design", 500, posy14);
text("Character Supervisor", 500, posy15);
text("Sets Art Director", 500, posy16);
text("Sets Supervisor", 500, posy17);
text("Shading Art Director", 500, posy18);
text("Shading Supervisor", 500, posy19);
text("Global Technology Supervisor", 500, posy20);
text("Effects Supervisor", 500, posy21);
text("Simulation Supervisor", 500, posy22);
text("Groom Supervisor", 500, posy23);
text("Crowds Supervisor", 500, posy24);
text("Production Manager", 500, posy25);
text("Sound Designer", 500, posy26);
text("Casting by", 500, posy27);
textFont(italic);
textAlign(LEFT);
textSize(50);
text("Brad Bird", 550, posy1);
text("Brad Lewis", 550, posy2);
textLeading(30);
text("John Lasseter\nAndrew Stanton", 550, posy3);
textLeading(50);
text(" Galyn Susman", 550, posy4);
textLeading(30);
text("Jan Pinkava\nJim Capobianco\nBrad Bird", 550, posy5);
textLeading(50);
text("Michael Giacchino", 550, posy6);
text("Mark Andrews", 550, posy7);
text("Darren Holmes A.C.E", 550, posy8);
text("Michael Fong", 550, posy9);
text("Harley Jessup", 550, posy10);
text("Dylan Brown\nMark Walsh", 550, posy11);
text("Sharon Calahan", 550, posy12);
text("Robert Anderson", 550, posy13);
textLeading(30);
text("Jason Deamer\nGreg Dykstra\nCarter Goodrich\nDan Lee", 550, posy14);
textLeading(50);
text("Brian Green", 550, posy15);
text("Robert Kondo", 550, posy16);
text("David Gisenmann", 550, posy17);
text("Belinda Van Valkenburg", 550, posy18);
text("Daniel McCoy", 550, posy19);
text("William Reeves", 550, posy20);
text("Apura Shah", 550, posy21);
text("Christine Waggoner", 550, posy22);
text("Sanjay Bakshi", 550, posy23);
text("Ziah Sarah Fogel", 550, posy24);
text("Nicole Paradis Grindle", 550, posy25);
text("Randy Thom", 550, posy26);
textLeading(30);
text("Kevin Reher\nNatalie Lyon", 550, posy27);

posy1-= speedY;
posy2-= speedY;
posy3-= speedY;
posy4-= speedY;
posy5-= speedY;
posy6-= speedY;
posy7-= speedY;
posy8-= speedY;
posy9-= speedY;
posy10-= speedY;
posy11-= speedY;
posy12-= speedY;
posy13-= speedY;
posy14-= speedY;
posy15-= speedY;
posy16-= speedY;
posy17-= speedY;
posy18-= speedY;
posy19-= speedY;
posy20-= speedY;
posy21-= speedY;
posy22-= speedY;
posy23-= speedY;
posy24-= speedY;
posy25-= speedY;
posy26-= speedY;
posy27-= speedY;

textFont(italic);
textSize(50);
textAlign(CENTER);
text("CAST", 525, posy28);
posy28-= speedY;
textFont(s2);
textSize(23);
textAlign(RIGHT);
text("Remy", 500, posy29);
text("Skinner", 500, posy30);
text("Linguini", 500, posy31);
text("Django", 500, posy32);
text("Emile", 500, posy33);
text("Anton Ego", 500, posy34);
text("Gusteu", 500, posy35);
text("Colette", 500, posy36);
text("Horst", 500, posy37);
text("Lalo & Grancois", 500, posy38);
text("Larousse", 500, posy39);
text("Mustafa", 500, posy40);
text("Lawyer", 500, posy41);
text("Pompidou & Heatlh", 500, posy42);
text("Git (LabRat)", 500, posy43);
text("Ambrister Minion", 500, posy44);
text("TV Narrator", 500, posy45);
textFont(sarif);
textAlign(LEFT);
text("Patton Oswalt", 550, posy29);
text("Ian Holm", 550, posy30);
text("Lou Romano", 550, posy31);
text("Brian Dennchy", 550, posy32);
text("Peter Sohn", 550, posy33);
text("Peter O'Toole", 550, posy34);
text("Brand Garett", 550, posy35);
text("Janeane Garofalo", 550, posy36);
text("Will Arnett", 550, posy37);
text("Julius Callahan", 550, posy38);
text("James Remar", 550, posy39);
text("John Ratzenberger", 550, posy40);
text("Teddy Newton", 550, posy41);
text("Tony Fucile", 550, posy42);
text("Jake Steinfeld", 550, posy43);
text("Brad Bird", 550, posy44);
text("Stephane Roux", 550, posy45);

posy29-= speedY;
posy30-= speedY;
posy31-= speedY;
posy32-= speedY;
posy33-= speedY;
posy34-= speedY;
posy35-= speedY;
posy36-= speedY;
posy37-= speedY;
posy38-= speedY;
posy39-= speedY;
posy40-= speedY;
posy41-= speedY;
posy42-= speedY;
posy43-= speedY;
posy44-= speedY;
posy45-= speedY;
textFont(s2);
textAlign(CENTER);
text("Co-Directed by", posx1, 200);
text("Additional Story material by", posx1, 280);
text("Production Accountant", posx1, 360);
textFont(sarif);
text("Jan Pinkava", posx1, 240);
text("Emily Cook & Kathy Greenberg", posx1, 320);
text("Bob Peterson", posx1, 400);
text("Marc S. Greenberg", posx1, 440);

posx1 -= speedX;

textFont(italic);
textSize(50);
text("ANIMATION", 525, posy53);
posy53-=speedY;
textAlign(RIGHT);
textFont(s2);
text("Animation Manager", 500, posy54);
text("Directing Animators", 500, posy55);
textAlign(CENTER);
textSize(20);
text("Animation Production", 525, posy56);

textAlign(LEFT);
textFont(sarif);
textSize(23);
text("Audra Koklys Plummer", 550, posy54);
text("David DeVan\nMichael Venturini", 550, posy55);
textAlign(RIGHT);
text("Belhem Bouchiba\nAndrew Gordon\nAndrew L. Schmidt", 500, posy57);
textAlign(LEFT);
text("Doug Dooley\nRobert H. Russ\n Kureah Vegne", 550, posy57);

posy54-=speedY;
posy55-=speedY;
posy56-=speedY;
posy57-=speedY;

textAlign(CENTER);
textFont(s2);
textSize(20);
text("Animators", 525, posy58);

posy58-= speedY;

textAlign(RIGHT);
textFont(sarif);
textSize(21);
text("Carlos Baena\nJason Boose\nAdam Burke\nBrett Coderre\nDon Crum\nDoug Dooley\nIke Feidmann\nTom Gately\nStephen Gregory\nJohn Kahrs", 500, posy59);
textAlign(LEFT);
text("Rodrigo Blaas Nacle\nBelhem Bouchiba\nShaun Chacko\nTim Crawfurd\nPatrick Delage\nEverett R. Dowing\nDoug Frankei\nAndrew Gordon\nTravis Hathaway\nNathy Kato", 552, posy59);

posy59-= speedY;

textAlign(CENTER);
textFont(italic);
textSize(40);
text("MUSIC", 525, posy60);
posy60-= speedY;
textAlign(RIGHT);
textFont(sarif);
textSize(23);
text("Music Orchestrated by", 500, posy61);
text("Music Recorded and Mixed by", 500, posy62);
text("Music Editor", 500, posy63);
text("Music Contractor", 500, posy64);
text("Supervising Music Copyist", 500, posy65);
text("Additional Orchestrations by", 500, posy66);
text("Assistan Music Editors", 500, posy67);
text("Score Assistan", 500, posy69);
text("Scoring Crew", 500, posy70);
text("Exective Music Producer", 500, posy71);
text("Music Supervisor", 500, posy72);
text("Music Production Director", 500, posy73);
text("Music Recorded at", 500, posy74);
text("Music Mixed at", 500, posy75);

textAlign(LEFT);
text("Tim Simonee", 550, posy61);
text("Dan Wallin", 550, posy62);
text("Stephen M. Davis", 550, posy63);
text("Reggie Wilson", 550, posy64);
text("Walt Disney M.Lybrary", 550, posy65);
text("Jack.J. Hayes\nLarry Kenton", 550, posy66);
text("Paul Apelgren\nAlan Schalfer", 550, posy67);
text("Andrea Datzman", 550, posy69);
text("Adam Michalak\nGreg Dennen\nRyan Robbinson", 550, posy70);
text("Chris Montan", 550, posy71);
text("Tom MacDougall", 550, posy72);
text("Andrew Page", 550, posy73);
text("Sony Scoring Stage", 550, posy74);
text("Warner Bros. Eastwood\nScoring Stage", 550, posy75);
posy61-= speedY;
posy62-= speedY;
posy63-= speedY;
posy64-= speedY;
posy65-= speedY;
posy66-= speedY;
posy67-= speedY;
posy69-= speedY;
posy70-= speedY;
posy71-= speedY;
posy72-= speedY;
posy73-= speedY;
posy74-= speedY;
posy75-= speedY;
posy76-= speedY;
posy77-= speedY;

textAlign(CENTER);
textFont(sarif);
textSize(23);
text("Information Systems", 525, posy79);
textFont(sarif);
text("Danniel Annereau\nGran Gatzie\nGreg Brandeau", 130, posy80);
text("Edgar Quiñones\nKelli Townley\nBob Frey", 380, posy80);
text("Christopher Fehring\nWarren Lastimer\nMarty Lew", 630, posy80);
text("M.T Silvia\nJason Walkins\nAlex Stahl", 880, posy80);
posy79-= speedY;
posy80-= speedY;

textAlign(CENTER);
textFont(sarif);
textSize(30);
text("SPECIAL THANKS", 525, posy81);
textSize(21);
text("Lee Armstrong\nMary Murphy\nJohn Glikey\nNarc Louria\nKamela Porgutes\nDiane Langlume", 130, posy82);
text("Simon Bax\nWill Csakies\nKathleen Holliday\nSarah MacArthur\nMichele Spane-Rivera\nAmy Gary", 380, posy82);
text("Matthew Robbins\nAnthony Beurdain\nDoubble Ducommun\nDavid Heselton\nIrene Mecchi\nKerry Phelean", 630, posy82);
text("Lorne Cameron\nKaren Farlbank\nDr. Steven Isono\nTerry Paulding\nStuart Stumida\nFred Tie", 880, posy82);
posy81-= speedY;
posy43-= speedY;
posy44-= speedY;
posy45-= speedY;
textFont(s2);
textAlign(CENTER);
text("Co-Directed by", posx1, 200);
text("Additional Story material by", posx1, 280);
text("Production Accountant", posx1, 360);
textFont(sarif);
text("Jan Pinkava", posx1, 240);
text("Emily Cook & Kathy Greenberg", posx1, 320);
text("Bob Peterson", posx1, 400);
text("Marc S. Greenberg", posx1, 440);

posx1 -= speedX;

textFont(italic);
textSize(50);
text("ANIMATION", 525, posy53);
posy53-=speedY;
textAlign(RIGHT);
textFont(s2);
text("Animation Manager", 500, posy54);
text("Directing Animators", 500, posy55);
textAlign(CENTER);
textSize(20);
text("Animation Production", 525, posy56);

textAlign(LEFT);
textFont(sarif);
textSize(23);
text("Audra Koklys Plummer", 550, posy54);
text("David DeVan\nMichael Venturini", 550, posy55);
textAlign(RIGHT);
text("Belhem Bouchiba\nAndrew Gordon\nAndrew L. Schmidt", 500, posy57);
textAlign(LEFT);
text("Doug Dooley\nRobert H. Russ\n Kureah Vegne", 550, posy57);

posy54-=speedY;
posy55-=speedY;
posy56-=speedY;
posy57-=speedY;

textAlign(CENTER);
textFont(s2);
textSize(20);
text("Animators", 525, posy58);

posy58-= speedY;

textAlign(RIGHT);
textFont(sarif);
textSize(21);
text("Carlos Baena\nJason Boose\nAdam Burke\nBrett Coderre\nDon Crum\nDoug Dooley\nIke Feidmann\nTom Gately\nStephen Gregory\nJohn Kahrs", 500, posy59);
textAlign(LEFT);
text("Rodrigo Blaas Nacle\nBelhem Bouchiba\nShaun Chacko\nTim Crawfurd\nPatrick Delage\nEverett R. Dowing\nDoug Frankei\nAndrew Gordon\nTravis Hathaway\nNathy Kato", 552, posy59);

posy59-= speedY;

textAlign(CENTER);
textFont(italic);
textSize(40);
text("MUSIC", 525, posy60);
posy60-= speedY;
textAlign(RIGHT);
textFont(sarif);
textSize(23);
text("Music Orchestrated by", 500, posy61);
text("Music Recorded and Mixed by", 500, posy62);
text("Music Editor", 500, posy63);
text("Music Contractor", 500, posy64);
text("Supervising Music Copyist", 500, posy65);
text("Additional Orchestrations by", 500, posy66);
text("Assistan Music Editors", 500, posy67);
text("Score Assistan", 500, posy69);
text("Scoring Crew", 500, posy70);
text("Exective Music Producer", 500, posy71);
text("Music Supervisor", 500, posy72);
text("Music Production Director", 500, posy73);
text("Music Recorded at", 500, posy74);
text("Music Mixed at", 500, posy75);

textAlign(LEFT);
text("Tim Simonee", 550, posy61);
text("Dan Wallin", 550, posy62);
text("Stephen M. Davis", 550, posy63);
text("Reggie Wilson", 550, posy64);
text("Walt Disney M.Lybrary", 550, posy65);
text("Jack.J. Hayes\nLarry Kenton", 550, posy66);
text("Paul Apelgren\nAlan Schalfer", 550, posy67);
text("Andrea Datzman", 550, posy69);
text("Adam Michalak\nGreg Dennen\nRyan Robbinson", 550, posy70);
text("Chris Montan", 550, posy71);
text("Tom MacDougall", 550, posy72);
text("Andrew Page", 550, posy73);
text("Sony Scoring Stage", 550, posy74);
text("Warner Bros. Eastwood\nScoring Stage", 550, posy75);
posy61-= speedY;
posy62-= speedY;
posy63-= speedY;
posy64-= speedY;
posy65-= speedY;
posy66-= speedY;
posy67-= speedY;
posy69-= speedY;
posy70-= speedY;
posy71-= speedY;
posy72-= speedY;
posy73-= speedY;
posy74-= speedY;
posy75-= speedY;
posy76-= speedY;
posy77-= speedY;

textAlign(CENTER);
textFont(sarif);
textSize(23);
text("Information Systems", 525, posy79);
textFont(sarif);
text("Danniel Annereau\nGran Gatzie\nGreg Brandeau", 130, posy80);
text("Edgar Quiñones\nKelli Townley\nBob Frey", 380, posy80);
text("Christopher Fehring\nWarren Lastimer\nMarty Lew", 630, posy80);
text("M.T Silvia\nJason Walkins\nAlex Stahl", 880, posy80);
posy79-= speedY;
posy80-= speedY;

textAlign(CENTER);
textFont(sarif);
textSize(30);
text("SPECIAL THANKS", 525, posy81);
textSize(21);
text("Lee Armstrong\nMary Murphy\nJohn Glikey\nNarc Louria\nKamela Porgutes\nDiane Langlume", 130, posy82);
text("Simon Bax\nWill Csakies\nKathleen Holliday\nSarah MacArthur\nMichele Spane-Rivera\nAmy Gary", 380, posy82);
text("Matthew Robbins\nAnthony Beurdain\nDoubble Ducommun\nDavid Heselton\nIrene Mecchi\nKerry Phelean", 630, posy82);
text("Lorne Cameron\nKaren Farlbank\nDr. Steven Isono\nTerry Paulding\nStuart Stumida\nFred Tie", 880, posy82);
posy81-= speedY;
posy82-= speedY;

textAlign(CENTER);
textFont(italic);
textSize(50);
text("Thanks to Everyone at Pixar who Supported this Productions", posx2, 300);
image(endcred, posx3, 400, 300, 100);
posx2+= speedX2;
posx3+= speedX2;
}
void keyPressed(){
bground = loadImage("Fondo2.jpg");
}
void mouseClicked() {
speedY = speedY * -1;
speedX = speedX *-1;
speedX2 = speedX2 * -1;
}

Aventura gráfica

Las reliquias de la muerte

El trabajo práctico consistió en armar una aventura gráfica basada en una historia a elección.

En mi caso, elegí partir del relato de "Las Reliquias de la Muerte", el cual aparece en una de las películas de Harry Potter. Modifiqué algunos aspectos de la historia para generar otros caminos alternativos dentro de la aventura. Las imágenes e ilustraciones fueron sacadas tanto de la película como de la web.

PImage sc1, sc2, sc3, sc4, sc5, sc6, sc7, sc8, sc9, sc10, sc11, sc12, sc13, sc14, sc15, sc16, sc17, sc18, sc19, sc20, sc21, sc22;
PFont historia, creditos;
int pantalla = 1;
float vel = 0.7;
float posy1_i = 610;
float posy1 = posy1_i;

void setup() {
size(800, 600);
sc1 = loadImage ("Imagen1.jpg");
sc2 = loadImage ("Imagen2.jpg");
sc3 = loadImage ("Imagen3.jpg");
sc4 = loadImage ("Imagen4.jpg");
sc5 = loadImage ("Imagen5.jpg");
sc6 = loadImage ("Imagen6.jpg");
sc7 = loadImage ("Imagen7.jpg");
sc8 = loadImage ("Imagen8.jpg");
sc9 = loadImage ("Imagen9.jpg");
sc10 = loadImage ("Imagen10.jpg");
sc11 = loadImage ("Imagen11.jpg");
sc12 = loadImage ("Imagen12.jpg");
sc13 = loadImage ("Imagen13.jpg");
sc14 = loadImage ("Imagen14.jpg");
sc15 = loadImage ("Imagen15.jpg");
sc16 = loadImage ("Imagen16.jpg");
sc17 = loadImage ("Imagen17.jpg");
sc18 = loadImage ("Imagen18.jpg");
sc19 = loadImage ("Imagen19.jpg");
sc20 = loadImage ("Imagen20.jpg");
sc21 = loadImage ("Imagen21.jpg");
sc22 = loadImage ("Imagen22.jpg");
historia = loadFont ("Gabriola-34.vlw");
creditos = loadFont ("Garamond-40.vlw");
}
void draw() {
if (pantalla == 1) {
image(sc1, 0, 0);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
|| (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565))
{
cursor(HAND);
} else {
cursor(ARROW);}
} else if (pantalla == 2) {
image(sc2, 0, 0);
fill(0);
textAlign(LEFT);
textFont(historia);
textSize(28);
text("Había una vez tres hermanos, Antioch, Cadmus e Ignotus Peverell,\nque viajaban a la hora del crepúsculo por una solitaria y sinuosa \ncarretera.", 35, 240);
text("Los hermanos llegaron a un río demasiado profundo para vadearlo\n y demasiado peligroso para cruzarlo a nado.", 35, 350);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 3) {
image(sc3, 0, 0);
textAlign(LEFT);
text("Pero como eran muy diestros en", 380, 200);
textSize(34);
text("las artes mágicas, no tuvieron que", 400, 225);
textSize(28);
text("hacer nada más que agitar sus varitas.", 435, 250);
textAlign(CENTER);
text("ELIGE UN HECHIZO", 400, 450);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
|| (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 4) {
image(sc4, 0, 0);
textAlign(LEFT);
text("Congelaron las peligrosas aguas que los amenazaban y\ncontinuaron con su travesía a pie.\n\nPero para su desgracia, ninguno de los tres había recordado un\nimportantísimo detalle: el encantamiento solo duraba quince\nminutos.", 35, 200);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 5) {
image(sc5, 0, 0);
fill(219, 207, 186);
textSize(28);
text("El encantamiento se rompió antes que llegaran", 280, 100);
text("al otro lado, y las fuertes corrientes regresaron.", 315, 125);
text("Una figura encapuchada apareció y se llevó consigo las", 280, 240);
text("de los Peverell.", 580, 265);
textSize(34);
text("tres valiosas vidas", 380, 265);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 6) {
image(sc6, 0, 0);
fill(0);
textSize(28);
textAlign(LEFT);
text("Hicieron aparecer un puente y cruzaron a pie.\n\nCuando se hallaban a mitad de camino, una\nfigura encapuchada les cerró el paso.", 360, 90);
textSize(34);
text("Y la Muerte les habló.", 500, 240);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 7) {
image(sc7, 0, 0);
textAlign(LEFT);
textSize(28);
text("Estaba contrariada porque acababa de perder a tres posibles", 35, 75);
text("Pero ella fue muy\nla opción a cada uno de elegir una recompensa por\nhaberla eludido", 35, 150);
text("y, fingiendo felicitarlos, les dio", 260, 150);
text("El hermano mayor, que era muy combativo, pidió\nla varita mágica más poderosa que existiera.\n\nEl hermano del medio, arrogante, pidió el poder de\ndevolver la vida a los muertos.\n\nIgnotus, más humilde, pidió algo que le permitiera marcharse\nsin que ella pudiera seguirlo.", 35, 270);
textSize(34);
text("víctimas.", 35, 105);
text("astuta", 190, 150);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 8) {
image(sc8, 0, 0);
textAlign(CENTER);
fill(0);
textSize(26);
text("La Muerte hizo una varita con una rama de un sáuco y se la entregó a Antioch.\nLuego, sacó una piedra de la orilla del río y se la entregó a Cadmus, diciéndole que tenía el\npoder de resucitar a los muertos.\nFinalmente, de mala gana, le entregó su propia capa de invisibilidad al menor de los tres.\nEntonces se apartó, y dejó que los Peverell siguiera cada quien su camino.", 400, 50);
textAlign(CENTER);
text("ELIGE A UN HERMANO", 400, 230);
if ((mouseX > 325 && mouseX < 475 && mouseY > 510 && mouseY < 570)
|| (mouseX > 615 && mouseX < 765 && mouseY > 510 && mouseY < 570)
|| (mouseX > 35 && mouseX < 185 && mouseY > 510 && mouseY < 570)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 9) {
image(sc9, 0, 0);
textAlign(LEFT);
textSize(28);
text("Antioch siguió viajando algo más de una semana.\nAl llegar a una lejana aldea, buscó a un mago con el que mantenía una grave disputa.\nNaturalmente, armado con la Varita de Saúco, era inevitable que ganara el duelo.\n\nTras matarlo, se marchó.", 35, 45);
textAlign(CENTER);
text("REALIZA UNA ACCIÓN", 400, 475);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
|| (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 10) {
image(sc10, 0, 0);
textAlign(LEFT);
text("Se dirigió a una posada donde se jactó de lo invencible que se había vuelto\ngracias a la varita, y festejó sus victorias.\nEsa misma noche, un hechicero se acercó con sigilio mientras el hermano mayor\nyacía borracho en su cama, le robó la varita y, por si acaso, le cortó el cuello.", 75, 50);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 11) {
image(sc11, 0, 0);
fill(219, 207, 186);
textSize(28);
text("Y así fue como", 150, 85);
text("se llevó al hermano mayor.", 250, 110);
textSize(34);
text("la Muerte", 283, 85);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 12) {
image(sc12, 0, 0);
fill(219, 207, 186);
textAlign(LEFT);
textSize(28);
text("Decidió descansar antes de retomar su viaje por la mañana temprano.", 150, 50);
text("Esa misma noche, un hechicero se acercó con sigilo e intentó robar ", 200, 75);
text("la varita, pero Antioch, astuto y perspicaz, logró defenderse", 250, 100);
text("a tiempo, evitando el robo y acabando con la vida del", 300, 125);
text("hechicero como recompensa.", 350, 150);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 13) {
image(sc13, 0, 0);
fill(0);
textAlign(LEFT);
text("La muerte, enfurecida porque la habían burlado\nnuevamente, se apareció en la habitación de Antioch.\nAstuta como siempre, lo retó a un duelo que él aceptó sin saber\nque estaba condenado a perder.\nAsí fue como, en un intercambio sin sentido y desigual,\nla Muerte se llevó al hermano mayor", 35, 280);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 14) {
image(sc14, 0, 0);
fill(219, 207, 186);
textAlign(LEFT);
text("Entretanto, el hermano del medio regresó a su casa \ndonde vivía en soledad.\nCon la piedra filosofal en mano, debía decidir el uso\nque iba a darle.", 35, 75);
textAlign(RIGHT);
text("ELIGE QUÉ HACER", 400, 475);
textAlign(LEFT);
fill(0);
text("CON LA PIEDRA", 410, 475);
if ((mouseX > 200 && mouseX <350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)){
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 15) {
image(sc15, 0, 0);
text("Arrogante y sediento de poder, se encargó de preparar", 210, 175);
text("la cantidad suficiente de elíxeres como para vivir eternamente.", 280, 200);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 16) {
image(sc16, 0, 0);
fill(219, 207, 186);
textSize(28);
text("Pasado un tiempo y habiendo quedado solo,", 150, 75);
textSize(24);
text("Cadmus se arrepintió del uso que le había dado a la piedra.", 200, 100);
textSize(26);
text(" Comprendió que vivir eternamente no tenía sentido", 250, 125);
text("si sus seres queridos no podían acompañarlo.", 300, 150);
text("Y en medio de la angustia, decidió poner", 350, 175);
textSize(33);
text("fin a su vida.", 580, 200);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 17) {
image(sc17, 0, 0);
textAlign(LEFT);
textSize(28);
fill(219, 207, 186);
text("Cadmus giró tres veces la piedra en la mano.\nPara su asombro y placer, apareció ante él la figur\nde la muchacha con quien se habría casado si ella no \nhubiera muerto prematuramente\n\nPero la muchacha estaba triste y distante, separada de él por\n una especie de velo.", 30, 30);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 18) {
image(sc18, 0, 0);
fill(219, 297, 186);
textSize(26);
text("Pese a que ella había regresado al mundo de los mortales, no pertenecía a él y por eso sufría.\nAl fin, el hombre enloqueció a causa de su desesperada nostalgia y se suicidó para\nreunirse de una vez por todas con su amada.", 30, 30);
text("Y así fue como ", 30, 120);
text("se llevó al hermano mediano.", 250, 120);
textSize(32);
text("la Muerte", 150, 120);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 19) {
image(sc19, 0, 0);
fill(0);
textSize(24);
textAlign(LEFT);
text("Ignouts continuó con su camino alejado de sus dos", 380, 30);
text("hermanos.", 395, 55);
text("La Muerte lo buscó durante años pero nunca", 410, 100);
text("logró encontrarlo.", 425, 125);
text("Llegado a una edad muy avanzada, el hermano menor", 380, 185);
text("decidió por fin quitarse la capa de invisibilidad.", 395, 210);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 20) {
image(sc20, 0, 0);
textSize(26);
text("A diferencia de sus hermanos, Ignotus era de corazón noble.", 50, 80);
text("Decidió regalarle la capa a su hijo y recibió a la Muerte como si fuera una vieja amiga.", 80, 105);
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 21) {
image(sc21, 0, 0);
textSize(30);
fill(0);
textAlign(CENTER);
text("Y así, como iguales, ambos se alejaron de la vida", 400, 800);
if ((mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565)
||(mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565)) {
cursor(HAND);
} else {
cursor(ARROW);
}
} else if (pantalla == 22) {
image(sc22, 0, 0);
fill(0);
textAlign(CENTER);
textFont(creditos);
textSize(36);
text("Este trabajo se realizó a partir de la historia\n'La fabula de los tres hermanos',\nescrita por J.K Rowling.\n\n\n\nPara la edición de imágenes se utilizaron los programas:\nPhotoshop CC 2020\n&\nIllustrator CC 2020\n\n\n\nAlumna encargada del trabajo: Lara Belén Ignoffo.\n\n\n\n¡Espero que lo hayas disfrutado!", 400, posy1);
posy1 = posy1 - vel;
if (mouseX > 45 && mouseX < 195 && mouseY > 505 && mouseY < 565) {
cursor(HAND);
} else {
cursor(ARROW);
}
}
}

void mouseClicked() {
if (pantalla == 1) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 2;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 22;
}
} else if (pantalla == 2) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 3;
}
} else if (pantalla == 3) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 4;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 6; }
} else if (pantalla == 4) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 5;
}
} else if (pantalla == 5) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 1;
}
} else if (pantalla == 6) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 7;
}
} else if (pantalla == 7) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
} else if (pantalla == 8) {
if (mouseX > 325 && mouseX < 475 && mouseY > 510 && mouseY < 565) {
pantalla = 9; }
if (mouseX > 615 && mouseX < 765 && mouseY > 510 && mouseY < 570) {
pantalla = 14;
}
if (mouseX > 35 && mouseX < 185 && mouseY > 510 && mouseY < 570) {
pantalla = 19;
}
} else if (pantalla == 9) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 10;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 12;
}
} else if
(pantalla == 10) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 710) {
pantalla = 11;
}
} else if (pantalla == 11) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 1;
}
} else if
(pantalla == 12) {
605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 13; }
} else if (pantalla == 13) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 1;
}
} else if (pantalla == 14) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 15;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 17;
}
} else if (pantalla == 15) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 16;
}
} else if (pantalla == 16) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 1;
}
} else if (pantalla == 17) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 18;
}
} else if (pantalla == 18) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 1;
}
} else if (pantalla == 19) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 20;
}
} else if (pantalla == 20) {
if (mouseX > 605 && mouseX < 755 && mouseY > 505 && mouseY < 565) {
pantalla = 21;
}
} else if (pantalla == 21) {
if (mouseX > 200 && mouseX < 350 && mouseY > 505 && mouseY < 565) {
pantalla = 8;
}
if (mouseX > 450 && mouseX < 600 && mouseY > 505 && mouseY < 565) {
pantalla = 1; }
} else if
(pantalla == 22) {
if (mouseX > 45 && mouseX < 195 && mouseY > 505 && mouseY < 565) {
posy1 = posy1_i;
pantalla = 1;
}
}
}

Ciclo for y arreglos

Ejercicos de práctica

Un cuadrado sigue al mouse. Al clickear en la mitad izquierda, incrementa +1 cuadrado hacia abajo. Al clickear en la mitad derecha, incrementa +1 hacia la derecha. Al presionar una tecla, la cantidad de ambos disminuye.

  • Ver código
    int aum = 1, tam = 50, aum2 = 1;
    void setup() {
    size(500, 500);
    }
    void draw() {
    background(204);
    for (int i = 0; i rect(mouseX + (i*tam), mouseY, tam, tam);
    }
    for (int j = 0; j rect(mouseX, mouseY + (j*tam), tam, tam);
    }
    }
    void mouseClicked() {
    if (mouseX > width/2) {
    aum++;
    } else {
    aum2++;
    }
    }
    void keyPressed() {
    aum--;
    aum2--;
    }

El programa consta de diez posiciones. Al presionar un número del teclado, se incrementa +1 en la posición correspondiente al número presionado

  • Ver código

    int cant = 10, dist, posInicial, suma = 1;
    int numeros[] = new int [cant];

    void setup() {
    size(500, 300);
    dist = width/ cant;
    for (int i = 0; i < cant; i++) {
    numeros [i] = 0;
    textSize(25);
    }
    } void draw() {
    background(255);
    for (int i = 0; i < cant; i++) {
    fill(0);
    text(numeros[i], (i * dist) + (dist * 0.25), 150);
    posInicial = i;
    text(posInicial, (i * dist) + (dist * 0.25), 50);
    }
    }

    void keyPressed() {
    if (key == '0') {
    numeros[0] += suma;
    } else if (key == '1') {
    numeros[1] += suma;
    } else if (key == '2') {
    numeros[2] += suma;
    } else if (key == '3') {
    numeros[3] += suma;
    } else if (key == '4') {
    numeros[4] += suma;
    } else if (key == '5') {
    numeros[5] += suma;
    } else if (key == '6') {
    numeros[6] += suma;
    } else if (key == '7') {
    numeros[7] += suma;
    } else if (key == '8') {
    numeros[8] += suma;
    } else if (key == '9') {
    numeros[9] += suma;
    }
    }

Grilla de rectángulos. La ficha negra se maneja con las flechas del teclado. A la derecha se indica la posición actual de la ficha.

  • Ver código

    int celdas = 10, filas = 5, tamCeldas, tamFilas, posIColSelec = 0, colSelec = posIColSelec, filaSelec = 0;
    void setup() {
    size(500, 300);
    tamCeldas = width/celdas;
    tamFilas = height/filas;
    textSize(30);
    }
    void draw() {
    for (int cantCeldas = 0; cantCeldas < celdas; cantCeldas++) {
    for (int cantFilas = 0; cantFilas < filas; cantFilas++) {
    if (cantCeldas == colSelec && cantFilas == filaSelec) {
    fill(0);
    } else {
    fill(255);
    }
    rect(cantCeldas*tamCeldas, cantFilas*tamFilas, tamCeldas, tamFilas);
    }
    }
    fill (0);
    text("Fila: " + filaSelec, 300, 125);
    text("Col: " + colSelec, 300, 175);
    }
    void keyPressed() {
    if (keyCode == LEFT) {
    if (colSelec > 0) {
    colSelec --;
    } else {
    colSelec = celdas - 1;
    }
    } else if (keyCode == RIGHT) {
    if (colSelec < celdas - 1) {
    colSelec ++;
    } else {
    colSelec = 0;
    }
    } else if (keyCode == UP) {
    if (filaSelec > 0) {
    filaSelec --;
    } else {
    filaSelec = filas - 1;
    }
    } else if (keyCode == DOWN) {
    if (filaSelec < filas - 1) {
    filaSelec ++;
    } else {
    filaSelec = 0;
    }
    }
    }

POO: Programación orientada a objetos

Trabajo práctico n°5: Videojuego

Es un mini juego basado en la aventura gráfica realizada previamente. Para ganar, primero deberás cruzar el camino logrando esquivar las rocas, y luego tendrás que llenar una barra de energía (haciendo click) para completar el hechizo deseado. Solo tenes tres vidas para cruzar el camino, y un único intento para realizar el hechizo

El código está dividido en nueve pestañas en total. A continuación está cada pestaña con su código correspondiente.

  • arrow_drop_downtp5
    Juego juego;

    void setup() {
    size(800, 600);
    juego = new Juego();
    }

    void draw() {
    background(204);
    juego.dibujar();
    }

    void mouseClicked() {
    juego.mouse();
    }

    void keyPressed(){
    juego.teclas();
    }
  • arrow_drop_downJuego
    class Juego {
    int estado;
    PImage fondoMsj;
    PFont fuenteMsj;
    VideoJuego videoJuego;

    Juego() {
    inicializar();
    fondoMsj = loadImage("fondomensaje.png");
    fuenteMsj = loadFont("Consolas-Bold-48.vlw");
    }
    void dibujar() {
    if (estadoActual(0)) {
    dibujarMensaje("¡Bienvenido a mi minijuego!\n\n\nPresiona 'S' para comenzar.\n\n\n\n\n\nAlumna: Lara Belén Ignoffo");
    } else if (estadoActual(1)) {
    dibujaJuegoEnemigos();
    } else if (estadoActual(3)) {
    dibujaHechizos();
    } else if (estadoActual(4) || estadoActual(5)) {
    dibujarJuegoBarra();
    } else if (estadoActual(2)) {
    dibujarMensaje("¡Oh no!\n\nNo lo conseguiste esta vez.\n\n\nPresiona la tecla 'R' para comenzar de nuevo");
    } else if (estadoActual(6)) {
    dibujarMensaje("¡Enhorabuena!\n\nCompletaste el hechizo correctamente.\n\n\n\nPresiona la tecla 'R' para volver al inicio");
    }
    }

    void dibujaJuegoEnemigos() {
    videoJuego.dibujaJuegoEnemigos();
    if (videoJuego.controlaPasarOPerder() == 2) {
    estado = 2;
    } else if (videoJuego.controlaPasarOPerder() == 3) {
    estado = 3;
    }
    }

    void dibujaHechizos() {
    dibujarMensaje("¡Lograste atravesar los obstáculos!\nPero te topaste con un río\ndemasiado profundo y peligroso.\n\nElige un hechizo para poder cruzarlo.");
    videoJuego.dibujaHechizos();
    }

    void dibujarJuegoBarra() {
    dibujarMensaje("Clickea en cualquier parte de la pantalla\n\nlo más rápido que puedas para completar\n\nel hechizo.");
    videoJuego.dibujaBarra();
    if (videoJuego.controlaGanarOPerder() == 2) {
    estado = 2; } else if (videoJuego.controlaGanarOPerder() == 6) {
    estado = 6;
    }
    }

    void dibujarMensaje(String p_mensaje) {
    pushStyle();
    rectMode(CENTER);
    textFont(fuenteMsj);
    image(fondoMsj, 0, 0, width, height);
    textAlign(CENTER);
    textSize(26);
    text(p_mensaje, width/2, height/2 - 100);
    popStyle();
    }

    void mouse() {
    if (estadoActual(2)) {
    inicializar();
    } else if (estadoActual (3)) {
    clickHechizos();
    }
    else if (estadoActual (4) || estadoActual (5)) {
    videoJuego.clickBarra();
    }
    }

    void teclas() {
    if (estadoActual(0)) {
    if (key == 's' || key == 'S') {
    estado = 1;
    }
    else if (estadoActual(1)) {
    videoJuego.teclaPresionada();
    } else if (estadoActual(2) || estadoActual(6)) {
    if (key == 'r' || key == 'R') {
    inicializar();
    }
    } else if (estadoActual(6)) {
    if (key == 'r' || key == 'R') {
    inicializar();
    }
    }
    }

    void clickHechizos() {
    if (videoJuego.controlaClickHechizos() == 4) {
    estado = 4;
    } else if (videoJuego.controlaClickHechizos() == 5) {
    estado = 5;
    }
    }
    boolean estadoActual(int p_valor) {
    return estado == p_valor;
    }

    void inicializar() {
    videoJuego = new VideoJuego();
    estado = 0;
    }
    }
  • arrow_drop_downVideoJuego
    class VideoJuego {
    int cantEnemigos = 10;
    float jugadortam;
    float tam;
    float botonLargo;

    PImage fondo;
    PFont fuenteVida;

    Enemigo [] enemigos = new Enemigo [cantEnemigos];
    Jugador jugador;
    Vida vidas;
    Hechizo hechizo1, hechizo2;
    Barra energia;
    Boton boton;

    VideoJuego() {
    jugadortam = width/8;
    botonLargo = width/4;
    tam = width/cantEnemigos;
    fondo = loadImage("fondojuego.png");
    fuenteVida = loadFont("Consolas-28.vlw");
    inicializar();
    }

    void dibujaJuegoEnemigos() {
    image(fondo, 0, 0, width, height);
    dibujaEnemigos();
    boton.dibujar();
    jugador.dibujar();
    vidas.dibujar();
    }

    void dibujaEnemigos() {
    for (int i = 0; i < enemigos.length; i++) {
    enemigos[i].dibujar();
    if (enemigos[i].saleDePantalla()) {
    enemigos[i].reset(i*tam, 0);
    }
    if (jugador.colisionaCon(enemigos[i])) {
    enemigos[i].reset(i*tam, 0);
    vidas.decrementar();
    }
    }
    }

    void teclaPresionada() {
    jugador.moverLaterales();
    }

    void dibujaHechizos() {
    hechizo1.dibujar();
    hechizo2.dibujar();
    }
    void dibujaBarra() {
    energia.dibujar();
    }

    void clickBarra() {
    energia.clickear();
    }

    int controlaPasarOPerder() {
    if (jugador.haPerdido(vidas)) {
    return 2;
    } else if (jugador.pasoDeNivel(boton)) {
    return 3;
    }
    return 0;
    }

    int controlaClickHechizos() {
    if (hechizo1.clickHechizo()) {
    return 4;
    } else if (hechizo2.clickHechizo()) {
    return 5;
    } else return 0;
    }

    int controlaGanarOPerder() {
    if (jugador.haPerdido(energia)) {
    return 2;
    } else if (jugador.haGanado(energia)) {
    return 6;
    } else return 0;
    }

    void inicializar() {
    jugador = new Jugador(0, height - jugadortam * 2, width/8);
    vidas = new Vida (3, width - tam * 1.5, tam, fuenteVida);
    for (int i = 0; i < enemigos.length; i++) {
    int tipoEnemigo = int(random(0, 3));
    enemigos[i] = new Enemigo (i*tam + tam, 0, tam - cantEnemigos, random(5, 9), tipoEnemigo);
    }
    hechizo1 = new Hechizo ((width/4 * 0.85), height/2 + tam * 1.5, botonLargo, tam, 0);
    hechizo2 = new Hechizo((width/2 + 30), height/2 + tam * 1.5, botonLargo, tam, 1);
    boton = new Boton(width - 150, height - tam * 2.5, 150, 100);
    energia = new Barra(width/4, height * 0.07, 2.5, 15);
    }
    }
  • arrow_drop_downBarra
    class Barra {
    float x, y, ancho, alto;
    float valorMaxEnergia;
    float contadorEnergia;
    float velDec, velAum; PImage energia;

    Barra(float p_ancho, float p_alto, float p_velDec, float p_velAum) {
    alto = p_alto;
    ancho = p_ancho;
    velDec = p_velDec;
    velAum = p_velAum;
    x = width/2 - ancho/2;
    y = height/2 + alto * 3;
    valorMaxEnergia = p_ancho;
    contadorEnergia = valorMaxEnergia * 0.6;
    energia = loadImage("energia.png");
    }

    void dibujar() {
    pushStyle();
    image(energia, x+1, y+1, contadorEnergia - 1, alto-1);
    stroke(255);
    noFill();
    rect(x, y, ancho, alto);
    contadorEnergia -= velDec;
    popStyle();
    }

    void clickear() {
    if (valorMaxEnergia > 0) {
    contadorEnergia += velAum;
    }
    }
    }
  • arrow_drop_downBoton
    class Boton {
    float x, y, ancho, alto;
    PImage boton;

    Boton(float p_x, float p_y, float p_ancho, float p_alto) {
    x = p_x;
    y = p_y;
    ancho = p_ancho;
    alto = p_alto;
    boton = loadImage("flecha.png");
    }

    void dibujar() {
    image(boton, x, y, ancho, alto);
    }
  • arrow_drop_downEnemigo
    class Enemigo {
    float x, y;
    float tam, vel;
    int tipo;
    PImage enemigo;

    Enemigo(float p_x, float p_y, float p_tam, float p_vel, int p_tipo) {
    x = p_x;
    y = p_y;
    tam = p_tam;
    vel = p_vel;
    tipo = p_tipo;
    if (tipo == 0) {
    enemigo = loadImage("enemigo0.png");
    } else if (tipo == 1) {
    enemigo = loadImage("enemigo1.png");
    } else if (tipo == 2) {
    enemigo = loadImage("enemigo2.png");
    }
    enemigo.resize(int(tam), int(tam));
    }

    void dibujar() {
    image(enemigo, x, y); y = y + vel;
    }

    boolean saleDePantalla() {
    return y > height;
    }

    void reset(float p_x, float p_y) {
    x = p_x; y = p_y;
    }
    }
  • arrow_drop_downHechizos
    class Hechizo {
    float x, y, ancho, alto;
    int numHechizo;
    PImage [] hechizos = new PImage [2];

    Hechizo(float p_x, float p_y, float p_ancho, float p_alto, int p_numHechizo) {
    x = p_x;
    y = p_y;
    ancho = p_ancho;
    alto = p_alto;
    numHechizo = p_numHechizo;
    hechizos[0] = loadImage("glacius.png");
    hechizos[1] = loadImage("transgresus.png");
    }

    void dibujar() {
    image(hechizos[numHechizo], x, y, ancho, alto);
    }

    boolean clickHechizo() {
    if (mouseX > x && mouseX < x + ancho && mouseY > y && mouseY < y + alto) {
    return true;
    } else {
    return false; }
    }
    }
  • arrow_drop_downJugador
    class Jugador {
    float x, y, tam;
    PImage jugador;

    Jugador(float p_x, float p_y, float p_tam) {
    y = p_y;
    x = p_x;
    tam = p_tam;
    jugador = loadImage("jugador.png");
    jugador.resize(int(tam), int (tam));
    }
    void dibujar() {
    image(jugador, x, y);
    }

    void moverLaterales() {
    if (keyCode == LEFT) {
    x = x - tam;
    } else if (keyCode == RIGHT) {
    x = x + tam;
    }
    x = constrain (x, 0, width - tam);
    }

    void reset(float p_x, float p_y) {
    x = p_x;
    y = p_y;
    }

    boolean pasoDeNivel(Boton boton) {
    return x > boton.x;
    }

    boolean haPerdido(Vida vidas) {
    return vidas.cantVidas == 0;
    }

    boolean colisionaCon(Enemigo enemigos) {
    if (dist(x, y, enemigos.x, enemigos.y) <= tam/2) {
    return true;
    } else {
    return false;
    }
    }

    boolean haGanado(Barra energia) {
    return energia.contadorEnergia > energia.valorMaxEnergia;
    }

    boolean haPerdido(Barra energia) {
    return energia.contadorEnergia < 0;
    }
    }
  • arrow_drop_downVidas
    class Vida {
    int cantVidas;
    float x, y;
    PFont vidas;

    Vida (int p_cantVidas, float p_x, float p_y, PFont p_vidas) {
    cantVidas = p_cantVidas;
    x = p_x;
    y = p_y;
    vidas = p_vidas;
    }

    void dibujar() {
    pushStyle();
    fill(255);
    textFont(vidas);
    textSize(26);
    text("Vidas:" + cantVidas, x, y);
    popStyle();
    }

    void decrementar() {
    cantVidas--;
    }
    }

Trabajo final

Aventura gráfica + videojuego

El trabajo práctico final consistió en retomar la aventura gráfica, convertirla a objetos e incorporar el trabajo práctico n°5

El código está dividido en 15 pestañas en total. A continuación está cada pestaña con su código correspondiente.

  • arrow_drop_downtpfinal
    import processing.sound.*;
    Aventura aventura;
    Resize resize;

    void setup() {
    size(800, 600);
    surface.setResizable(true);
    aventura = new Aventura(this);
    resize = new Resize();
    }

    void draw() {
    aventura.dibujarPantallas();
    }

    void mouseClicked() {
    aventura.mouseClicked();
    }

    void keyPressed() {
    aventura.keyPressed();}
  • arrow_drop_downAventura
    class Aventura {
    AventuraGrafica aventuraGrafica;
    Juego juego;
    int estado;
    float yTextoInicial, yTexto, velocidad;
    SoundFile sonido;

    Aventura(PApplet miSonido_) {
    aventuraGrafica = new AventuraGrafica();
    juego = new Juego();
    estado = 0;
    yTextoInicial = 610;
    yTexto = yTextoInicial;
    sonido = new SoundFile (miSonido_, "deathlyhallows.mp3");
    sonido.play();
    sonido.loop();
    sonido.amp(0.5);
    velocidad = 1.7;
    }

    boolean estadoActual(int valor) {
    return estado == valor;
    }

    void dibujarPantallas() {
    if (estadoActual(0)) {
    aventuraGrafica.pantallaDosBotones(0, 0, 1, 0, 0, 0);
    } else if (estadoActual(1)) {
    aventuraGrafica.pantallaUnBoton(1, 3, 30, 280, 0);
    } else if (estadoActual(2)) {
    juego.dibujar();
    } else if (estadoActual(3)) {
    aventuraGrafica.pantallaUnBoton(3, 3, 35, 150, #361f02);
    } else if (estadoActual(4)) {
    aventuraGrafica.pantallaUnBoton(4, 5, 360, 180, #ded8a1);
    } else if (estadoActual(5)) {
    aventuraGrafica.pantallaUnBoton(5, 3, 360, 180, 0);
    } else if (estadoActual(6)) {
    aventuraGrafica.pantallaUnBoton(6, 3, 35, 90, 0);
    } else if (estadoActual(7)) {
    aventuraGrafica.pantallaTresBotones(7);
    } else if (estadoActual(8)) {
    aventuraGrafica.pantallaDosBotones(8, 9, 10, 35, 60, #030500);
    } else if (estadoActual(9)) {
    aventuraGrafica.pantallaUnBoton(9, 3, 240, 60, #FFF3D3);
    } else if (estadoActual(10)) {
    aventuraGrafica.pantallaDosBotones(10, 4, 5, 55, 60, #FFF3D3);
    } else if (estadoActual(11)) {
    aventuraGrafica.pantallaUnBoton(11, 3, 35, 60, #FFF3D3);
    } else if (estadoActual(12)) {
    aventuraGrafica.pantallaDosBotones(12, 4, 5, 35, 285, #030500);
    } else if (estadoActual(13)) {
    aventuraGrafica.pantallaDosBotones(13, 11, 12, 35, 60, #FFF3D3);
    } else if (estadoActual(14)) {
    aventuraGrafica.pantallaUnBoton(14, 3, 160, 150, #030500);
    } else if (estadoActual(15)) {
    aventuraGrafica.pantallaDosBotones(15, 4, 5, 40, 40, #FFF3D3);
    } else if (estadoActual(16)) {
    aventuraGrafica.pantallaUnBoton(16, 3, 25, 40, #FFF3D3);
    } else if (estadoActual(17))
    aventuraGrafica.pantallaDosBotones(17, 4, 5, 25, 40, #FFF3D3);
    } else if (estadoActual(18)) {
    aventuraGrafica.pantallaUnBoton(18, 3, 385, 25, #2d210b);
    } else if (estadoActual(19)) {
    aventuraGrafica.pantallaUnBoton(19, 3, 55, 85, #2d210b);
    } else if (estadoActual(20)) {
    aventuraGrafica.pantallaDosBotones(20, 4, 5, 200, 90, #2d210b);
    } else if (estadoActual(21)) {
    aventuraGrafica.pantallaCreditos(21, yTexto);
    yTexto -= velocidad;
    }
    }

    void mouseClicked() {
    if (estadoActual(0)) {
    clickDosBotones(1, 21);
    } else if (estadoActual(21)) {
    clickUnBoton(0);
    yTexto = yTextoInicial;
    } else if (estadoActual(1)) {
    clickUnBoton(2);
    } else if (estadoActual(2)) {
    juego.mouse();
  • arrow_drop_downAventuraGrafica
    class AventuraGrafica {
    int cantPantallas = 22;
    int cantBotones = 13;
    int posYBoton = 500;

    PImage [] fondo = new PImage [cantPantallas];
    PImage [] imgBoton = new PImage [cantBotones];

    Pantalla [] pantallas = new Pantalla [cantPantallas];
    Texto [] textos = new Texto[cantPantallas];
    Boton [] botones;
    Boton boton1, boton2, boton3;

    AventuraGrafica() {
    cargarFondos();
    cargarBotones();
    }

    void pantallaUnBoton(int pantalla, int i_boton1, float xTexto, float yTexto, int colorTexto) {
    boton1 = new Boton(imgBoton[i_boton1], 560, posYBoton);
    pantallas[pantalla] = new Pantalla(fondo[pantalla], boton1, null, null);
    textos[pantalla] = new Texto(pantalla, xTexto, yTexto, colorTexto);
    pantallas[pantalla].dibujar();
    textos[pantalla].historia();
    }

    void pantallaDosBotones(int pantalla, int i_boton1, int i_boton2, float xTexto, float yTexto, int colorTexto) {
    boton1 = new Boton(imgBoton[i_boton1], 150, posYBoton);
    boton2 = new Boton(imgBoton[i_boton2], 450, posYBoton);
    pantallas[pantalla] = new Pantalla(fondo[pantalla], boton1, boton2, null);
    textos[pantalla] = new Texto(pantalla, xTexto, yTexto, colorTexto);
    pantallas[pantalla].dibujar();
    textos[pantalla].historia();
    }
    void pantallaTresBotones(int pantalla) {
    boton1 = new Boton(imgBoton[6], (20), posYBoton);
    boton2 = new Boton(imgBoton[7], (300), posYBoton);
    boton3 = new Boton(imgBoton[8], (580), posYBoton);
    pantallas[pantalla] = new Pantalla(fondo[pantalla], boton1, boton2, boton3);
    textos[pantalla] = new Texto(pantalla, 35, 35, 0);
    pantallas[pantalla].dibujar();
    textos[pantalla].historia();
    }

    void pantallaCreditos(int pantalla, float yTexto) {
    boton1 = new Boton(imgBoton[2], 20, posYBoton);
    pantallas[pantalla] = new Pantalla(fondo[pantalla], boton1, null, null);
    textos[pantalla] = new Texto(pantalla, 400, yTexto, 0);
    pantallas[pantalla].dibujar();
    textos[pantalla].creditos();
    }

    void cargarFondos() {
    for (int i = 0; i < cantPantallas; i++) {
    fondo[i] = loadImage("imagen" + i + ".jpg");
    }
    }

    void cargarBotones() {
    for (int i = 0; i < cantBotones; i++) {
    imgBoton[i] = loadImage("boton" + i + ".png");
    }
    }

    int mouseClicked() {
    if (boton1 != null) {
    if (boton1.mouseClicked()) {
    return 1;
    }
    }
    if (boton2 != null) {
    if (boton2.mouseClicked()) {
    return 2;
    }
    }
    if (boton3 != null) {
    if (boton3.mouseClicked()) {
    return 3;
    }
    }
    return 0;
    }
    }
  • arrow_drop_downBoton
    class Boton {
    PImage imgBoton;
    float x, y, ancho, alto;

    Boton(PImage imgBoton, float x, float y) {
    this.imgBoton = imgBoton;
    this.x = x;
    this.y = y;
    ancho = 200;
    alto = 75;
    }

    void dibujar() {
    image(this.imgBoton, resize.porcentajeX(x), resize.porcentajeY(y), resize.porcentajeX(ancho), resize.porcentajeY(alto));

    }

    boolean mouseClicked() {
    if (mouseX > resize.porcentajeX(x) && mouseX < resize.porcentajeX(x + ancho) && mouseY > resize.porcentajeY(y) && mouseY < resize.porcentajeY(y + alto)) {
    return true;
    } else {
    return false;
    }
    }
    }
  • arrow_drop_downPantalla
    class Pantalla {
    PImage fondo;
    Boton boton1, boton2, boton3;

    Pantalla(PImage fondo, Boton boton1, Boton boton2, Boton boton3) {
    this.fondo = fondo;
    this.boton1 = boton1;
    this.boton2 = boton2;
    this.boton3 = boton3;
    }

    void dibujar() {
    image(this.fondo, 0, 0, width, height);
    if (boton1 != null) {
    boton1.dibujar();
    }
    if (boton2 != null) {
    boton2.dibujar();
    }
    if (boton3 != null) {
    boton3.dibujar();
    }
    }
    }
  • arrow_drop_downResize
    class Resize {

    float porcentajeX (float p_valor) {
    return round(map(p_valor, 0, 800, 0, width));
    }

    float porcentajeY (float p_valor) {
    return round(map(p_valor, 0, 600, 0, height));
    }
    }
  • arrow_drop_downTexto
    class Texto {
    String [] historia = new String [22];
    PFont narracion, creditos;
    float x, y;
    int colorTexto, numArreglo;

    Texto(int numArreglo, float x, float y, int colorTexto) {
    narracion = loadFont("Gabriola-34.vlw");
    creditos = loadFont("Garamond-40.vlw");
    inicializarTexto();
    this.numArreglo = numArreglo;
    this.x = x;
    this.y = y;
    this.colorTexto = colorTexto;
    }

    void historia() {
    push();
    textFont(narracion);
    textSize(resize.porcentajeX(26));
    fill(colorTexto);
    text(historia[numArreglo], resize.porcentajeX(x), resize.porcentajeY(y));
    pop();
    }

    void creditos() {
    push();
    textFont(creditos);
    textAlign(CENTER);
    textSize(resize.porcentajeX(36));
    fill(colorTexto);
    text(historia[numArreglo], resize.porcentajeX(x), resize.porcentajeY(y));
    pop();
    }

    void inicializarTexto() {
    historia[0] = "";
    historia[1] = "Había una vez tres hermanos, Antioch, Cadmus e Ignotus Peverell,\nque viajaban a la hora del crepúsculo por una solitaria y sinuosa \ncarretera.";
    historia[2] = "Pero como eran muy diestros en\n las artes mágicas, no tuvieron que hacer\n nada más que agitar sus varitas.";
    historia[3] = "Los hermanos congelaron las peligrosas aguas que los amenazaban y\ncontinuaron con su travesía a pie.\n\nPero para su desgracia, ninguno de los tres había recordado un\nimportantísimo detalle: el encantamiento solo duraba quince\nminutos.";
    historia[4] = "El encantamiento se rompió antes que llegaran\n al otro lado, y las fuertes corrientes regresaron.\n\n\n\nUna figura encapuchada apareció y se llevó\n las tres valiosas vidas de los Peverell.";
    historia[5] = "Los hermanos hicieron aparecer un puente\n y cruzaron a pie.\n Cuando se hallaban a mitad de camino,\n una figura encapuchada les cerró el paso.";
    historia[6] = "Estaba contrariada porque acababa de perder a tres posibles víctimas.\n\nPero ella fue muy astuta y, fingiendo feliciarlos, les dio\nla opción a cada uno de elegir una recompensa por\nhaberla eludido.\n\n El hermano mayor, que era muy combativo, pidió\n la varita mágica más poderosa que existiera.\n\nEl hermano del medio, arrogante, pidió el poder \nde devolver la vida a los muertos.\n\nIgnotus, más humilde, pidió algo que le permitiera marcharse\nsin que ella pudiera seguirlo";
    historia[7] = "La Muerte hizo una varita con una rama de un sáuco y se entregó a Antioch.\n\nLuego, sacó una piedra de la orilla del río y se la entregó a Cadmus, diciéndole que tenía\nel poder de resitar a los muertos.\n\nFinalmente, de mala gana, le entregó su propia capa de invisibilidad al menor de los tres.\nEntonces se apartó, y dejó que los Peverell siguiea cada quien su camino.";
    historia[8] = "Antioch siguió viajando algo más de una semana.\n\n\nAl llegar a una lejana aldea, buscó a un mago\ncon el que mantenía una grave disputa.\nNaturalmente, armado con la Varita de Saúco,\nera inevitable que ganara el duelo.\n\n\nTras matarlo, se marchó...";
    historia[9] = "Se dirigió a una posada donde se jactó de lo invencible que se\nhabía vuelto gracias a la varita, y festejó sus victorias.\n\nEsa misma noche, un hechicero se acercó con sigilio mientras\nel hermano mayor yacía borracho en su cama, le robó la varita y\npor si acaso, le cortó el cuello.";
    historia[10] = "Y así fue como La Muerte,\n se llevó al hermano mayor...";
    historia[11] = "Decidió descansar antes de retomar su viaje temprano por la mañana.\nEsa misma noche, un hechicero se acercó con sigilo e intentó robarle varita,pero Antioch\nlogró defenderse a tiempo, evitando el robo y acabando con la vida del hechicero\ncomo recompensa.";
    historia[12] = "La muerte, enfurecida porque la habían burlado\nnuevamente, se apareció en la habitación de Antioch.\nAstuta como siempre, lo retó a un duelo que él aceptó sin saber\nque estaba condenado a perder.\nAsí fue como, en un intercambio sin sentido y desigual,\nla Muerte se llevó al hermano mayor.";
    historia[13] = "Entretanto, el hermano del medio regresó a su casa\n donde vivía en soledad.\n Con la piedra filosofal en mano, debía decidir\n el uso que iba a darle.";
    historia[14] = "Arrogante y sediento de poder, se encargó de preparar\n la cantidad suficiente de elíxeres como para vivir eternamente.";
    historia[15] = "Pasado un tiempo y habiendo quedado solo,\n Cadmus se arrepintió del poder que le había dado a la piedra.\n Comprendió que vivir eternamente no tenía sentido sin sus queridos.\n\n Y en medio de tanta angustia, decidió ponerle fin a su vida.";
    historia[16] = "Cadmus giró tres veces la piedra en la mano.\nPara su asombro y placer, apareció ante él la figura de la muchacha con quien\nse habría casado si ella no hubiera muerto prematuramente\n\nPero la muchacha estaba triste y distante, separada de él por un velo.";
    historia[17] = "Pese a que ella había regresado al mundo de los mortales, no pertenecía a él y por eso sufría.\nAl fin, el hombre enloqueció a causa de su desesperada nostalgia\nse suicidó para reunirse con su amada.\n\nY así fue como la Muerte se llevó al hermano del medio.";
    historia[18] = "Ignouts continuó con su camino alejado de sus dos\n hermanos.\n La muerte lo buscó durante años pero nunca\n logró dar con él.\n\nLlegada una edad muy avanzada, el hermano del\n medio decidió quitarse por fin la capa.";
    historia[19] = "A diferencia de sus hermanos, Ignotus era de corazón noble.\n Decidió regalarle la capa a su hijo y recibió a la Muerte como si fuera una vieja amiga.";
    historia[20] = "Y así, como iguales, ambos se alejaron de la vida";
    historia[21] = "Este trabajo se realizó a partir de la historia\n'La fabula de los tres hermanos',\nescrita por J.K Rowling.\n\n\n\nAlgunas imágenes fueron tomadas de la película,\notras son ilustraciones sacadas de la web.\n\n\n\nPara su edición se utilizaron los programas:\nPhotoshop CC 2020\n&\nIllustrator CC 2020\n\n\n\nTipografías utilizadas:\n'Gabriola' para la narración,\n'Garamond' para los créditos\n&\n'Consolas' para el videojuego\n\n\n\nAlumna encargada del trabajo: Lara Belén Ignoffo.\n\n\n\n¡Espero que lo hayas disfrutado!";
    }
    }
  • arrow_drop_downEnemigo
    class Enemigo {
    float x, y;
    float tam, vel;
    int tipo;
    PImage enemigo;

    Enemigo(float p_x, float p_y, float p_tam, float p_vel, int p_tipo) {
    x = p_x;
    y = p_y;
    tam = p_tam;
    vel = p_vel;
    tipo = p_tipo;
    if (tipo == 0) {
    enemigo = loadImage("enemigo0.png");
    } else if (tipo == 1) {
    enemigo = loadImage("enemigo1.png");
    } else if (tipo == 2) {
    enemigo = loadImage("enemigo2.png");
    }
    enemigo.resize(int(tam), int(tam));
    }

    void dibujar() {
    image(enemigo, x, y); y = y + vel;
    }

    boolean saleDePantalla() {
    return y > height;
    }

    void reset(float p_x, float p_y) {
    x = p_x; y = p_y;
    }
    }
  • arrow_drop_downFlecha
    class Flecha {
    float x, y, ancho, alto;
    PImage boton;

    Flecha(float p_x, float p_y, float p_ancho, float p_alto) {
    x = p_x;
    y = p_y;
    ancho = p_ancho;
    alto = p_alto;
    boton = loadImage("flecha.png");
    }

    void dibujar() {
    image(boton, resize.porcentajeX(x), resize.porcentajeY(y), resize.porcentajeX(ancho), resize.porcentajeY(alto));
    }
    }
  • arrow_drop_downHechizos
    class Hechizo {
    float x, y, ancho, alto;
    int numHechizo;
    PImage [] hechizos = new PImage [2];

    Hechizo(float p_x, float p_y, float p_ancho, float p_alto, int p_numHechizo) {
    x = p_x;
    y = p_y;
    ancho = p_ancho;
    alto = p_alto;
    numHechizo = p_numHechizo;
    hechizos[0] = loadImage("glacius.png");
    hechizos[1] = loadImage("transgresus.png");
    }

    void dibujar() {
    image(hechizos[numHechizo], x, y, ancho, alto);
    }

    boolean clickHechizo() {
    if (mouseX > x && mouseX < x + ancho && mouseY > y && mouseY < y + alto) {
    return true;
    } else {
    return false; }
    }
    }
  • arrow_drop_downJuego
    class Juego {
    int estado;
    PImage fondoMsj;
    PFont fuenteMsj;
    VideoJuego videoJuego;

    Juego() {
    inicializar();
    fondoMsj = loadImage("fondomensaje.png");
    fuenteMsj = loadFont("Consolas-Bold-48.vlw");
    }

    void dibujar() {
    if (estadoActual(0)) {
    dibujarMensaje("Deberás esquivar los obstáculos que aparezcan\na lo largo de la sinuosa carretera.\n\n\n\nPresiona la tecla 'S' cuando estés listo.");
    } else if (estadoActual(1)) {
    dibujaJuegoEnemigos();
    } else if (estadoActual(2)) {
    dibujarMensaje("¡Ups! No lo haz conseguido esta vez.\n\n\n\n\nHaz click para continuar");
    } else if (estadoActual(3)) {
    dibujaHechizos();
    } else if (estadoActual(4) || estadoActual(5)) {
    dibujarJuegoBarra();
    }
    }

    void dibujaJuegoEnemigos() {
    videoJuego.dibujaJuegoEnemigos();
    if (videoJuego.controlaPasarOPerder() == 1) {
    estado = 2;
    } else if (videoJuego.controlaPasarOPerder() == 2) {
    estado = 3;
    }
    }

    void dibujaHechizos() {
    dibujarMensaje("¡Lograste atravesar los obstáculos!\nPero te topaste con un río\ndemasiado profundo y peligroso.\n\nElige algún hechizo para poder cruzarlo.");
    videoJuego.dibujaHechizos();
    }

    void dibujarJuegoBarra() { dibujarMensaje("Clickea en cualquier parte de la pantalla\n\nlo más rápido que puedas para completar\n\nla barra del hechizo.");
    videoJuego.dibujaBarra();
    if (videoJuego.controlaGanarOPerder() == 1) {
    estado = 2;
    }
    }
    void dibujarMensaje(String p_mensaje) {
    pushStyle();
    rectMode(CENTER);
    textFont(fuenteMsj);
    image(fondoMsj, 0, 0, width, height);
    textAlign(CENTER);
    textSize(resize.porcentajeX(26));
    text(p_mensaje, resize.porcentajeX(400), resize.porcentajeY(200));
    popStyle();
    }

    void mouse() {
    if (estadoActual (3)) {
    clickHechizos();
    } else if (estadoActual (4)) {
    videoJuego.clickBarra();
    if (videoJuego.controlaGanarOPerder() == 2) { estado = 6;
    }
    } else if (estadoActual (5)) {
    videoJuego.clickBarra();
    if (videoJuego.controlaGanarOPerder() == 2) {
    estado = 7;
    }
    } else if (estadoActual (2)) {
    estado = 8;
    }
    }

    void teclas() {
    if (estadoActual(0)) {
    if (key == 's' || key == 'S') {
    estado = 1;
    } else if (estadoActual(1)) {
    videoJuego.teclaPresionada();
    }
    }

    void clickHechizos() {
    if (videoJuego.controlaClickHechizos() == 4) {
    estado = 4;
    } else if (videoJuego.controlaClickHechizos() == 5) {
    estado = 5;
    }
    }

    boolean estadoActual(int p_valor) {
    return estado == p_valor;
    }

    void inicializar() {
    videoJuego = new VideoJuego();
    estado = 0;
    }
    }
  • arrow_drop_downJugador
    class Jugador {
    float x, y, tam;
    PImage jugador;

    Jugador(float p_x, float p_y, float p_tam) {
    y = p_y;
    x = p_x;
    tam = p_tam;
    jugador = loadImage("jugador.png");
    jugador.resize(int(tam), int (tam));
    }
    void dibujar() {
    image(jugador, x, y);
    }

    void moverLaterales() {
    if (keyCode == LEFT) {
    x = x - tam;
    } else if (keyCode == RIGHT) {
    x = x + tam;
    }
    }

    void reset(float p_x, float p_y) {
    x = p_x;
    y = p_y;
    }

    boolean pasoDeNivel(Boton boton) {
    return x > boton.x;
    }

    boolean haPerdido(Vida vidas) {
    return vidas.cantVidas == 0;
    }

    boolean colisionaCon(Enemigo enemigos) {
    if (dist(x, y, enemigos.x, enemigos.y) <= tam/2) {
    return true;
    } else {
    return false;
    }
    }

    boolean haGanado(Barra energia) {
    return energia.contadorEnergia > energia.valorMaxEnergia;
    }

    boolean haPerdido(Barra energia) {
    return energia.contadorEnergia < 0;
    }
    }
  • arrow_drop_downVidas
    class Vida {
    int cantVidas;
    float x, y;
    PFont vidas;

    Vida (int p_cantVidas, float p_x, float p_y, PFont p_vidas) {
    cantVidas = p_cantVidas;
    x = p_x;
    y = p_y;
    vidas = p_vidas;
    }

    void dibujar() {
    pushStyle();
    fill(255);
    textFont(vidas);
    textSize(26);
    text("Vidas:" + cantVidas, x, y);
    popStyle();
    }

    void decrementar() {
    cantVidas--;
    }
    }
  • arrow_drop_downVideoJuego
    class VideoJuego {
    int cantEnemigos = 10;
    float jugadortam;
    float tam;
    float botonLargo;

    PImage fondo;
    PFont fuenteVida;

    Enemigo [] enemigos = new Enemigo [cantEnemigos];
    Jugador jugador;
    Vida vidas;
    Hechizo hechizo1, hechizo2;
    Barra energia;
    Boton boton;

    VideoJuego() {
    jugadortam = width/8;
    botonLargo = width/4;
    tam = width/cantEnemigos;
    fondo = loadImage("fondojuego.png");
    fuenteVida = loadFont("Consolas-28.vlw");
    inicializar();
    }

    void dibujaJuegoEnemigos() {
    image(fondo, 0, 0, width, height);
    dibujaEnemigos();
    boton.dibujar();
    jugador.dibujar();
    vidas.dibujar();
    }

    void dibujaEnemigos() {
    for (int i = 0; i < enemigos.length; i++) {
    enemigos[i].dibujar();
    if (enemigos[i].saleDePantalla()) {
    enemigos[i].reset(i*tam, 0);
    }
    if (jugador.colisionaCon(enemigos[i])) {
    enemigos[i].reset(i*tam, 0);
    vidas.decrementar();
    }
    }
    }

    void teclaPresionada() {
    jugador.moverLaterales();
    }

    void dibujaHechizos() {
    hechizo1.dibujar();
    hechizo2.dibujar();
    }
    void dibujaBarra() {
    energia.dibujar();
    }

    void clickBarra() {
    energia.clickear();
    }

    int controlaPasarOPerder() {
    if (jugador.haPerdido(vidas)) {
    return 2;
    } else if (jugador.pasoDeNivel(boton)) {
    return 3;
    }
    return 0;
    }

    int controlaClickHechizos() {
    if (hechizo1.clickHechizo()) {
    return 4;
    } else if (hechizo2.clickHechizo()) {
    return 5;
    } else return 0;
    }

    int controlaGanarOPerder() {
    if (jugador.haPerdido(energia)) {
    return 2;
    } else if (jugador.haGanado(energia)) {
    return 6;
    } else return 0;
    }

    void inicializar() {
    jugador = new Jugador(0, height - jugadortam * 2, width/8);
    vidas = new Vida (3, width - tam * 1.5, tam, fuenteVida);
    for (int i = 0; i < enemigos.length; i++) {
    int tipoEnemigo = int(random(0, 3));
    enemigos[i] = new Enemigo (i*tam + tam, 0, tam - cantEnemigos, random(5, 9), tipoEnemigo);
    }
    hechizo1 = new Hechizo ((width/4 * 0.85), height/2 + tam * 1.5, botonLargo, tam, 0);
    hechizo2 = new Hechizo((width/2 + 30), height/2 + tam * 1.5, botonLargo, tam, 1);
    boton = new Boton(width - 150, height - tam * 2.5, 150, 100);
    energia = new Barra(width/4, height * 0.07, 2.5, 15);
    }
    }
  • arrow_drop_downBarra
    class Barra {
    float x, y, ancho, alto;
    float valorMaxEnergia;
    float contadorEnergia;
    float velDec, velAum; PImage energia;

    Barra(float p_ancho, float p_alto, float p_velDec, float p_velAum) {
    alto = p_alto;
    ancho = p_ancho;
    velDec = p_velDec;
    velAum = p_velAum;
    x = width/2 - ancho/2;
    y = height/2 + alto * 3;
    valorMaxEnergia = p_ancho;
    contadorEnergia = valorMaxEnergia * 0.6;
    energia = loadImage("energia.png");
    }

    void dibujar() {
    pushStyle();
    image(energia, x+1, y+1, contadorEnergia - 1, alto-1);
    stroke(255);
    noFill();
    rect(x, y, ancho, alto);
    contadorEnergia -= velDec;
    popStyle();
    }

    void clickear() {
    if (valorMaxEnergia > 0) {
    contadorEnergia += velAum;
    }
    }
    }
arrow_upward