SHARE
TWEET

Untitled

a guest Feb 5th, 2014 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //http://www.processing.org/tutorials/drawing/
  2.  
  3. void setup() {
  4.   size(200, 200);
  5.   rectMode(CENTER);
  6. }
  7.  
  8. int ballx = 0;
  9.  
  10. void draw() {
  11.   int k = 1;
  12.   int offsetX = 100;
  13.   int offsetY = 0;
  14.   offsetX = mouseX - 100;
  15.   background(230);
  16.   text("offsetX "+offsetX, 20, 20);
  17.  
  18.   if (offsetX >= 0)
  19.   {
  20.     text("RIGHT", 20, 180);
  21.     stroke(0);
  22.     fill(0, 200, 0);
  23.   }
  24.   else
  25.   {
  26.     text("LEFT", 20, 180);
  27.     stroke(0);
  28.     fill(0, 0, 200);
  29.   }
  30.  
  31.   if(Math.abs(ballx - mouseX) > 3)
  32.   {
  33.     if (ballx <= mouseX)
  34.     {
  35.       ballx += 1;
  36.     }
  37.     else
  38.     {
  39.       ballx -= 1;
  40.     }
  41.   }
  42.  
  43.  
  44.   ellipse(offsetX+100, 70, 100, 100);
  45.  
  46.   //Draw the ball...
  47.   fill(200, 0, 0);
  48.   ellipse(ballx, 120, 10, 10);
  49. }
RAW Paste Data
Top