Don't like ads? PRO users don't see any ads ;-)
Guest

Cleaned Up Code

By: a guest on May 8th, 2012  |  syntax: Java  |  size: 0.56 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void setup()
  2. {
  3.   size(650,650);
  4.   background(0,0,0);
  5. }
  6. int x = 0;
  7. int y = 0;
  8. int speedx=15;
  9. int speedy=20;
  10. int milli, tick, dmx, dmy;
  11. Random oRand = new Random();
  12. void draw()
  13. {
  14.  
  15.    milli=1000%millis();
  16.    tick = milli/1000;
  17.    dmx = tick*speedx;
  18.    dmy = tick*speedy;
  19.    ellipse(x,y,85,85);
  20.    fill(oRand.nextInt(255),oRand.nextInt(255),oRand.nextInt(255));
  21.    x+=dmx;
  22.    y+=dmy;
  23.    if(x>650||x<0)
  24.    {
  25.       speedx=-speedx;        
  26.    }
  27.    if(y>650||y<0)
  28.    {
  29.      speedy=-speedy;
  30.    }
  31. }
  32. //I leave my code kinda messy until I'm done. :p