class Cuadrado{ //datos y variables color c; float xpos; float ypos; float tamanio; float velocidad; float incremento; //constructor Cuadrado (color unColor, float unaPosX, float unaPosY, float unTamanio){ c = unColor; xpos = unaPosX; ypos= unaPosY; tamanio = unTamanio; velocidad = 1; //el incremento no tiene por que estar como parametro del constructor incremento = 0; } //metodos void draw(){ rectMode(CENTER); fill(c); noStroke(); rect(xpos,ypos,tamanio, tamanio); //println(xpos); } void mover(){ ypos = ypos+ mouseX ; xpos = xpos +mouseY; incremento = incremento+2; if(ypos > height +tamanio){ incremento = 100; ypos = -ypos -tamanio; if(xpos > width +tamanio){ incremento = 1; xpos = -xpos -tamanio; } } } }