
HALP!
By: a guest on
May 8th, 2012 | syntax:
Java | size: 1.17 KB | hits: 46 | expires: Never
//This was made using a program called Processing which uses java.
void setup() //just sets up the window and the background color.
{
size(650,650);
background(155,65,241);
}
int x = 0;
int y = 0;
int speedx=20;
int speedy=2;
int milli;
int tick;
int dmx;
int dmy;
Random oRand = new Random();
void draw()
{
milli=millis(); //A unit of time, 1 millisecond.
tick = milli/100;
dmx = tick*speedx; // distance moved.
dmy = tick*speedy;
//rect(mouseX-45, mouseY-45, 90,90); disregard this
//stroke(255);and this
ellipse(x,y,85,85); //makes a circle. first two arguments are position, last two are size.
fill(oRand.nextInt(255),oRand.nextInt(255),oRand.nextInt(255)); //just assigns a random color to it.
x=dmx;
y=dmy;
if(x>650) // for some reason, these if statements aren't happening :/
{
speedx=-speedx;
++dmx;
}
if(x<0)
{
speedx=-speedx;
++dmx;
}
if(y>650)
{
speedy=-speedy;
++dmy;
}
if(y<0)
{
speedy=-speedy;
++dmy;
}
}
//If you were wondering, just treat this draw() like a while loop as far as iterations.