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

HALP!

By: a guest on May 8th, 2012  |  syntax: Java  |  size: 1.17 KB  |  hits: 46  |  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. //This was made using a program called Processing which uses java.
  2.  
  3. void setup() //just sets up the window and the background color.
  4. {
  5.   size(650,650);
  6.   background(155,65,241);
  7. }
  8. int x = 0;
  9. int y = 0;
  10. int speedx=20;
  11. int speedy=2;
  12. int milli;
  13. int tick;
  14. int dmx;
  15. int dmy;
  16. Random oRand = new Random();
  17. void draw()
  18. {
  19.    milli=millis(); //A unit of time, 1 millisecond.
  20.    tick = milli/100;
  21.    dmx = tick*speedx; // distance moved.
  22.    dmy = tick*speedy;
  23.    //rect(mouseX-45, mouseY-45, 90,90); disregard this
  24.    //stroke(255);and this
  25.    ellipse(x,y,85,85); //makes a circle. first two arguments are position, last two are size.
  26.    fill(oRand.nextInt(255),oRand.nextInt(255),oRand.nextInt(255)); //just assigns a random color to it.
  27.    x=dmx;
  28.    y=dmy;
  29.    if(x>650) // for some reason, these if statements aren't happening :/
  30.    {
  31.       speedx=-speedx;
  32.              ++dmx;
  33.    }
  34.    if(x<0)
  35.    {
  36.       speedx=-speedx;
  37.              ++dmx;
  38.    }
  39.    if(y>650)
  40.    {
  41.      speedy=-speedy;
  42.              ++dmy;
  43.    }
  44.    if(y<0)
  45.    {
  46.      speedy=-speedy;
  47.      ++dmy;
  48.    }
  49.  
  50. }
  51. //If you were wondering, just treat this draw() like a while loop as far as iterations.