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;
}
}
No comments:
Post a Comment