Friday, September 23, 2016

imágenes y formas

PImage dibujo;
PShape forma;

void setup(){
size(1080,720);
dibujo = loadImage("forma_imagen.png");
forma = loadShape("dibujo_forma.svg");
}
void draw(){
  background(0);
  tint (255,0,0);
  image(dibujo, 100,100);
  shape(forma, 500,100);
}

Friday, September 9, 2016

pelota que bota


float xPos, yPos, diam, vel;
int dirX, dirY;
void setup() {
  size (1080, 720);
  xPos = width/2;
  yPos = height/2;
  dirX=1;
  dirY=1;
  diam = 100;
  vel = 2;
}
void draw() {
  background(110);
  diam = mouseY;
  vel = mouseX/10;
  xPos += vel * dirX;
  yPos += vel * dirY;
  ellipse (xPos, yPos, diam, diam);
  if (xPos>width-(diam/2)||xPos<0+(diam/2)) {
  dirX=-dirX;
  }
  if (yPos>height-(diam/2)||yPos<0+(diam/2)){
  dirY=-dirY;
  }
}