Java Reference
In-Depth Information
private void moveButterflies() {
int dir;
int i;
int x, y, width, height;
for ( i=0; i<butterfly.length; i++ ) {
dir = random.nextInt(9) + 1;
x = butterfly[i].getX();
y = butterfly[i].getY();
width = butterfly[i].getWidth();
height = butterfly[i].getHeight();
switch(dir)
{
/* 7 8 9
456
123 */
case 1:
x -= width/2;
y += height/2;
break;
case 2:
y += height/2;
break;
case 3:
x += width/2;
y += height/2;
break;
case 4:
x -= width/2;
break;
case 5:
break;
case 6:
x += width/2;
break;
case 7:
x -= width/2;
y -= height/2;
break;
case 8:
y -= height/2;
break;
 
Search WWH ::




Custom Search