martes, 27 de enero de 2015

CiculoClase

<CirculoDeb>




import de.looksgood.ani.*;
import de.looksgood.ani.easing.*;

Circulo circulo;
ArrayList<Circulo> circulos = new ArrayList<Circulo>();
PShape boton;
PShape cuadrado;
PShape menu;
boolean botonOpen = false;



void setup() {
  size(720, 480);
  boton=loadShape("MENU.svg");
  cuadrado = boton.getChild("cuadrado");
  menu = boton.getChild("menu");
  shapeMode(CENTER);

  Ani.init(this);
  circulo= new Circulo(2.0);
  textAlign(CENTER, CENTER);

  for (int i=0; i<10; i++) {
    Circulo c = new Circulo(i*80+60, height/2);
    circulos.add(c);
  }
}





void draw() {
  background(0);
  for (int i=circulos.size ()-1; i>=0; i--)
  {
    circulos.get(i).display();
  }
  if (botonOpen) {
    cuadrado.disableStyle();
    menu.disableStyle();
    fill(0);
    stroke(90, 255, 204);
  } else {
    cuadrado.enableStyle();
   menu.enableStyle();
  }
  shape(cuadrado, 300, 150);
  shape(menu, 300, 150);
}



void mouseClicked() {
  for (int i=0; i<circulos.size (); i++) {
    circulos.get(i).actualizar();
  }

  botonOpen=!botonOpen;
}


----------------------------------------------------------------------------------------------------------
<Circulo>

class Circulo {
  float x, y;
  float destx, desty;
  float origenx, origeny;
  float size;
  float tiempo;
  boolean menuabierto;


Circulo() {
    x = width/2;
    y = height/4;
    size = 50;
    tiempo = 2.0;
  }
  


    Circulo(float destx_, float desty_) {
    menuabierto= false;
    
    x = width/2;
    y = height/4;
    origenx = x;
    origeny = y;
    destx = destx_;
    desty = desty_;
    size = 50;
    tiempo = 2.0;
  }


  
   Circulo(float tiempo_) {
    x = width/2;
    y = height/2;
    size = 50;
    tiempo = tiempo_;
  }
  




  void actualizar() {
    if (menuabierto == false) {
      Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
      Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
      menuabierto = true;
    } else {
      Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
      Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
      menuabierto = false;
    }
  }





  void display (){
    fill(145,200,145);
    ellipse(x, y, size, size);
    textSize(0.25*size);
    fill(255, 255, 255);
  }
}
  

jueves, 22 de enero de 2015

Circulos- Ani libreria



--------------------------------------------------------------------------
<Circulos>

import de.looksgood.ani.*;
import de.looksgood.ani.easing.*;

//----------------------------------------

Circulo circulo;
ArrayList<Circulo> circulos = new ArrayList<Circulo>();

void setup() {

  size(720, 480);
  Ani.init(this);
  circulo= new Circulo(2.0);
  textAlign(CENTER, CENTER);

  for (int i=0; i<10; i++) {
    Circulo c = new Circulo(i*80+60, height/2);
    circulos.add(c);
  }
}





void draw() {
  background(0);

  for (int i=circulos.size ()-1; i>=0; i--)
  {
    circulos.get(i).display();
  }
}

void mouseClicked() {
  for (int i=0; i<circulos.size (); i++) {
    circulos.get(i).actualizar();
  }
}



-----------------------------------------------------------------------------------------------
<Circulo>

class Circulo {

  float x, y;
  float destx, desty;
  float origenx, origeny;
  float size;
  float tiempo;
  boolean menuabierto;

  Circulo() {
    x = width/2;
    y = height/4;
    size = 15;
    tiempo = 2.0;
  }

    Circulo(float destx_, float desty_) {
    menuabierto= false;
 
    x = width/2;
    y = height/4;
    origenx = x;
    origeny = y;
    destx = destx_;
    desty = desty_;
    size = 75;
    tiempo = 2.0;
  }

   Circulo(float tiempo_) {
    x = width/2;
    y = height/2;
    size = 25;
    tiempo = tiempo_;
  }

  void actualizar() {
    if (menuabierto == false) {
      Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
      Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
      menuabierto = true;
    } else {
      Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
      Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
      menuabierto = false;
    }
  }


  void display (){
    fill(#105F5F);
    ellipse(x, y, size, size);
    textSize(0.25*size);
    fill(255, 255, 255);
  }
}

jueves, 30 de octubre de 2014

Particulas



ParticulasAnimacion:


Particula
particula1,
particula2,
particula3,
particula4,
particula5;

void setup() {
  size(720,480);

  particula1 = new Particula(width/2, 0);
  particula2 = new Particula( random (0,800), 0);
  particula3 = new Particula( random (0,800), 0);
  particula4 = new Particula( random (0,800), 0);
  particula5 = new Particula( random (0,800), 0);





}


void draw() {

  background(0);
  if ( particula1.estaMuerta()) {
    fill (particula1.color1 + (random(0,255)),particula1.color1 + (random(0,255)),particula1.color1 + (random(0,255)));
    particula1 = new Particula(random(0, width), 0);
 
 
 
 
  }
  particula1.display();
  particula1.actualizar();

  if ( particula2.estaMuerta()) {
 
    particula2 = new Particula(random(0, width), 0);
 
 
 
 
 
  }

  particula2.display();
  particula2.actualizar();

  if ( particula3.estaMuerta()) {
 
    particula3 = new Particula(random(0, width), 0);
 
 
 
 
 
  }

  particula3.display();
  particula3.actualizar();



  if ( particula4.estaMuerta()) {
 
    particula4 = new Particula(random(0, width), 0);
 
 
 
 
  }




  particula4.display();
  particula4.actualizar();





  if ( particula5.estaMuerta()) {
 
    particula5 = new Particula(random(0, width), 0);
 
  }
  particula5.display();
  particula5.actualizar();








}


--------------------------------------------------------------------------------------------------------


Particula:


class Particula {
  PVector posicion;
  PVector velocidad;
  float tamano;
  float tamano2;
  color color1;



  Particula() {
    posicion = new PVector(width/2, height/2);
    velocidad = new PVector(0, 1.5);
    color1 = color( 255,0,0);
 
 
 
 
 
  }

  Particula (float posX, float posY) {
    posicion = new PVector(posX, posY);
    velocidad = new PVector(0, random(3, 30));
 
 
    tamano = (random(0, 100));
 
 
    tamano2 = (random (0 ,100));
 
 
 
 
  }

  void actualizar() {
    posicion.add(velocidad);




   
  }



  void display () {
 
    ellipse(posicion.x, posicion.y, 20 + tamano2, 20 + tamano);
 
 
 
  }

  boolean estaMuerta() {
    if (posicion.y > height) {
      return true;
   
   
    }
    return false;
 
 
 
  }





}

Juego_Naves



Nave Juego:

Nave1 jg_nave;
Nave2 nave_2;
Bala bala;
PImage fondo;

void setup() {
  size(1080, 720);
  fondo = loadImage("fondo.jpg");
  jg_nave= new Nave1();
  nave_2 = new Nave2();
  bala = new Bala();



}

void draw() {
  image(fondo, width/2, height/2, width, height);

  jg_nave.display();

  nave_2.mover();
  nave_2.display();


  bala.display();



  float setX = jg_nave.posX;
  bala.setposX(setX);



  if (keyCode == SHIFT) {
    jg_nave.disparar();
 
 
 
 
  }
}



void keyPressed() {
  if (keyCode == RIGHT) {
    jg_nave.moverderecha();
 
 
 
 
  }

  if (keyCode == LEFT) {
    jg_nave.moverizquierda();
 
 
 
 
 
  }
}


------------------------------------------------------------------------------------------------


Bala:

class Bala {
  PImage image;
  float posX;
  float posY;
  String nombre;
  float desp;

  Bala() {
    posX = width/2;
    posY = 700;
    nombre = "bala";
    image = loadImage("bala.png");
    desp = 15;
 
 
 
  }



  void setposX(float newX) {
    posX = newX;
 
 
 
 
  }

  void setposY(float newY) {
    posY = newY;
 
 
 
 
  }

  void display() {
    imageMode(CENTER);
    image(image, posX, posY, 100, 100);
 
 
 
 
 
 
  }
}



--------------------------------------------------------------------------------------------

Nave1:


class Nave1 {
  PImage image;
  float posX;
  float posY;
  String nombre;

  Nave1() {
    posX = width/2;
    posY = height-50;
    nombre = "naveBuena";
    image = loadImage("Nave1.png");
    
    
    
  }


  void setposX(float newX) {
    posX = newX;
    
    
    
  }

  void moverderecha() {
    posX = posX +15;
    if (posX> width)
      posX= 24;
      
      
  }
  
  
  
  void moverizquierda() {
    posX = posX -15;
    if (posX< 0)
      posX= 1024;
      
      
  }
  
  

  void disparar() {

   if ( bala.posY < 0) 
      bala.posY = jg_nave.posY;
      bala.posX = jg_nave.posX;
    bala.posY = bala.posY - bala.desp;
    
    
    
    
    
  
    if ( bala.posY > width) 
      bala.desp = -1*bala.desp;
      

   
    
    
    
  }
  
  

  void display() {
    imageMode(CENTER);
    image(image, posX, posY, 300, 150);
    
    
    
    
    
    
  }
}



-----------------------------------------------------------------------------------------------------


Nave2:



class Nave2 {
  PImage image;
  float posX;
  float posY;
  String nombre;
  float desp;  
  
  Nave2() {
    posX = width/2;
    posY = 130;
    nombre = "naveMala";
    image = loadImage("Nave2.png");
    desp = 5.0;
    
    
    
  }

  
  void setposX(float newX) {
    posX = newX;
    
    
    
  }

  void setposY(float newY) {
    posY = newY;
    
    
    
  }


  void mover() {

    if ( posX > width) 
      desp = -1*desp;
    if ( posX < 0) 
      desp = -desp;
    posX =posX + desp;
    
    
    
  }


  void display() {
    imageMode(CENTER);
    image(image, posX, posY, 200, 200);
    
    
    
    
    
    
  }
}



miércoles, 29 de octubre de 2014

NaveEspacio



NaveEspacio:

Nave1 nave1;
Nave2 nave2;
Bala bala;
PImage fondo;


void setup(){
  size(720, 480);
  fondo = loadImage("fondo.jpg");
  bala = new Bala();
  nave1 = new Nave1();
  nave2 = new Nave2();
 
 
 

 
}

void draw(){
  fondo = loadImage("fondo.jpg");
  image(fondo, 0, 0);
  bala.display();
  nave1.display();
  nave2.display();

 

 
 
}


Bala(new Tab):

class Bala{
  PImage balaImg;
  float posX;
  float posY;
 
  Bala(){
  balaImg = loadImage("bala.png");
 
   
  }
 
 
  //____________________________
 
  void setPosX(float x_){
    posX = x_;
   
   
  }
 
    void setPosY(float y_){
    posY = y_;
   
   
  }
 
  void display(){
    image(balaImg, 400, 10,50,50);
   
   
  }
 
 
 
 
}




Nave1(New Tab):

 class Nave1{
  PImage nave1img;
  float posX;
  float posY;
  
  Nave1(){
    nave1img = loadImage("Nave1.png");
    
    
    
    
    
  }
  
  //------------------------------------
  
  void setPosX(float x_){
    posX = x_;
    
    
    
  }
  
    void setPosY(float y_){
    posY = y_;
    
    
    
  }
  
  
  void display(){
    image(nave1img, 10, 10,100,200);
    
    
    
    
  }
  
  
  
}



Nave2(NewTab):

class Nave2{
  PImage nave2img;
  float posX;
  float posY;
  
  Nave2(){
    nave2img = loadImage("Nave2.png");
    
    
    
  }
  
  
  
  //----------------------------
  
  void setPosX(float x_){
    posX = x_;
    
    
    
  }
  
    void setPosY(float y_){
    posY = y_;
    
    
    
  }
  
  void display(){
    image(nave2img, 100, 100,200,200);
    
    
    
  }
  
  
  
  
}









Caminante


Colores:



caminante caminante1;

void setup() {
  size(720, 480);
  background(0);
  caminante1 = new caminante();
  caminante1.setPosX(200);
  caminante1.setPosY(300);
  println(caminante1.getPosX());
  println(caminante1.getPosY());
 
 
 
 
 
}

void draw() {
  caminante1.display();
  caminante1.actualizar();
 
 
 
 


}

-----------------------------------------------------------------------------------------------------------

caminante(new tab):



class caminante{
 
  float posX;
  float posY;
  color colorFill;

   
  caminante(){
    posX = width/2;
    posY = height/2;
    colorFill= color(0, 255, 0);
     
  }
   
    void setPosX(float newX) {
    posX = newX;
  }

  void setPosY(float newY) {
    posY = newY;
  }
 
  float getPosX(){
  return posX;
  }
 
  float getPosY(){
  return posY;
  }
 
  void setColorFill(color newColorFill){
    colorFill = newColorFill;
  }
 
  void actualizar(){
    posX = posX + random(-20, 20);
    posY = posY + random(-20,20);
    setColorFill(color(random(0,255), random(0,255), random(0,255)));
  }
 
 
  void display(){
    fill(colorFill);
    ellipse(posX, posY, 20, 20);
    ellipse((posX+20), posY, 20, 20);
 
}
  }


Formas



Primero:

void setup() {
 size(720, 480);
 ellipseMode(CENTER);
 rectMode(CENTER);
 //triangleMode(CENTER);
 strokeWeight(5);



}
void draw(){
 background(121, 145, 149);
fill(193, 70, 193);
stroke(145, 169, 132);
ellipse(350, 350, mouseX, mouseX);
fill(70, 118, 193);
stroke(145, 169, 132);
rect(400, 400, mouseX, mouseX);
fill(54, 152, 108);
stroke(145, 169, 132);
triangle(15,10,12, mouseX,mouseX,mouseX);




}