- float x,y,x1,y1;
- boolean mouse = false;
-
- void setup() {
- size(600,600);
- smooth();
- strokeWeight(5);
- x = 0;
- y = 0;
- }
-
- void draw() {
- background(0,0,255);
- stroke(0);
- fill(255);
- triangle(0,0,width/2,height,width,0);
- stroke(255);
- fill(0);
- triangle(width/2,0,0,height,width,height);
- ellipseMode(CENTER);
- if(mouseX != pmouseX || mouseY != pmouseY)
- {
- x = pmouseX;
- y = pmouseY;
- }
- else if(mouse==true)
- {
- noStroke();
- fill(0,255,0);
- ellipse(x1,y,50,50);
- fill(255,0,0);
- ellipse(x,y1,50,50);
- x1++;
- y1++;
- }
- }
-
- void mousePressed(){
- x1 = mouseX;
- y1 = mouseY;
- mouse = true;
- }
复制代码 楼主是想这样? |