> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.ahpKjW-nyXO/rev.80
 * 
 * authors: 
 *   Hugo Santander

 * 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.3546/landscape.jpg"; */

Cometa a;
Cometa b;
Cometa c;

Globo d;
Globo e;
Globo f;
Globo g;
Globo h;
Globo i;

Ovni l;
Ovni m;
Ovni n;
Ovni o;




color relleno;
float posx;
float posy;
float velocidadx;
float r;

void setup()
{
size(600, 400);
background(loadImage("/static/uploaded_resources/p.3546/landscape.jpg"));

a = new Cometa();
b = new Cometa();
c = new Cometa();

d = new Globo();
e = new Globo();
f = new Globo();
g = new Globo();
h = new Globo();
i = new Globo();

l = new Ovni();
m = new Ovni();
n = new Ovni();
o = new Ovni();



}

void draw()
{
 background(loadImage("/static/uploaded_resources/p.3546/landscape.jpg"));
 a.pintar();
 a.mover();
 b.pintar();
 b.mover();
 c.pintar();
 c.mover();
 d.pintar();
 d.mover();
 e.pintar();
 e.mover();
 f.pintar();
 f.mover();
 g.pintar();
 g.mover();
 h.pintar();
 h.mover();
 i.pintar();
 i.mover();

 l.pintar();
 l.mover();
 m.pintar();
 m.mover();
 n.pintar();
 n.mover();
 o.pintar();
 o.mover();
 

 
 
}

//clase Ovni
class Ovni
{
 //atributos Ovni
color relleno;
float posx;
float posy;
float velocidadx;
float velocidady;

//metodo constructor
Ovni()
{
 posx = (int)random(width);
posy = (int)random(height);
relleno = color(212, 206, 32);
velocidadx = -1;
velocidady = -1;

}

//metodo pintar Ovni
void pintar()
{

 fill(relleno);
beginShape();
ellipse(posx, posy, 60, 20);

fill(0);
ellipse(posx+20, posy, 5, 5);

fill(0);
ellipse(posx+10, posy, 5, 5);

fill(0);
ellipse(posx+1, posy, 5, 5);

fill(0);
ellipse(posx-10, posy, 5, 5);

fill(0);
ellipse(posx-20, posy, 5, 5);

fill(255);
ellipse(posx, posy-10, 25, 7);
}

//metodo mover Ovni
void mover()
{
 posx = posx + velocidadx;
posy = posy + velocidady;

if (posx <= 0)
  {
  posx = 600; 
    }
    
    if (posy <= 0)
  {
  posy = 400; 
    }
}
}


//clase de Globo
class Globo
{
 //atributos Globo
 color relleno;
float posx;
float posy;
float velocidady;

 //metodo constructor
  Globo()
  {
    posx = (int)random(width);
    posy = 400;
    relleno = color(160, 110, 240, 150);
    velocidady = -3;
    }
    
    //metodo pintar globo
    void pintar()
    {
     fill (relleno);
    ellipse(posx, posy, 60, 60);
   
   fill(121, 67, 209, 150);
  ellipse(posx, posy, 40, 40);
 
 fill(72, 23, 152, 150);
ellipse(posx, posy, 20, 20);

fill(182, 105, 136, 150);
rect(posx-10, posy+30, 20, 20);
    }
    
    //metodo mover globo
    void mover()
    {
     posy = posy + velocidady;
  
  if (posy <= 0)
  {
  posy = 400; 
    }
    }
}

//clase de cometa
class Cometa
{
 //atributos cometa
 color relleno;
float posx;
float posy;
float velocidadx;
float r;

//metodo constructor
Cometa()
{
 posx = 0;
 posy = (int)random(height);
 velocidadx = 2;
 r = 3;
relleno = color(233, 127, 25); 
}
//metodo pintar cometa
void pintar()
{
fill(relleno);
beginShape();
vertex(posx, posy);
vertex(posx+30, posy-50);
vertex(posx+60, posy);
vertex(posx+30, posy+50);
vertex(posx, posy);
endShape(CLOSE);

color(0);
line(posx+30, posy-50, posx+30, posy+50);
line(posx, posy, posx+60, posy); 

fill(246, 75, 22);
triangle(posx+30, posy-50, posx+60, posy, posx+30, posy);
fill(49, 249, 22);
triangle(posx, posy, posx+30, posy, posx+30, posy+50);


fill(255);
triangle(posx+30, posy+50, posx+20, posy+60, posx+20, posy+40);
triangle(posx+30, posy+50, posx+40, posy+40, posx+40, posy+60);

}

//metodo mover Cometa
void mover()
{
 posx = posx + velocidadx;
  
  if (posx >= 600)
  {
  posx = 0;
  }
}
}