Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://www.processing.org/tutorials/drawing/
- void setup() {
- size(200, 200);
- rectMode(CENTER);
- }
- int ballx = 0;
- void draw() {
- int k = 1;
- int offsetX = 100;
- int offsetY = 0;
- offsetX = mouseX - 100;
- background(230);
- text("offsetX "+offsetX, 20, 20);
- if (offsetX >= 0)
- {
- text("RIGHT", 20, 180);
- stroke(0);
- fill(0, 200, 0);
- }
- else
- {
- text("LEFT", 20, 180);
- stroke(0);
- fill(0, 0, 200);
- }
- if(Math.abs(ballx - mouseX) > 3)
- {
- if (ballx <= mouseX)
- {
- ballx += 1;
- }
- else
- {
- ballx -= 1;
- }
- }
- ellipse(offsetX+100, 70, 100, 100);
- //Draw the ball...
- fill(200, 0, 0);
- ellipse(ballx, 120, 10, 10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement