# robot loop for an animation;

Page 1 of 1

## 0 Replies - 583 Views - Last Post: 01 July 2013 - 03:02 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=324034&amp;s=7fba70892320fa3a9be16690b6886abd&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 guntanis

Reputation: 1
• Posts: 11
• Joined: 20-June 13

# robot loop for an animation;

Posted 01 July 2013 - 03:02 PM

im tring to animate motion of the mouse from 1 button to another in an array with the class robot.
here are de two methods I used:
```public void optimusprime(int row, int column, JButton current) throws InterruptedException {
Point p;
Point p2;
double x;
double y;
double x2;
double y2;
double conx = 0;
double m;
double b;
double cony;
p = current.getLocationOnScreen();

x = (int) p.getX() + 30.5;
y = (int) p.getY() + 30.5;

optimus((int) x, (int) y);

p2 = mesa[row][column].getLocationOnScreen();
x2 = (int) p2.getX() + 30.5;
y2 = (int) p2.getY() + 30.5;

m = (y2 - y) / (x2 - x);
b = y2 - (m * x2);
while (conx != x2) {

conx = x;
cony = (m * conx) + b;
optimus((int) conx, (int) cony);
conx++;
}

}

public void optimus(int x, int y) {
try {

Robot robot = new Robot();
robot.mouseMove(x, y);
} catch (AWTException e) {
}
}
```

can any 1 help me here or at least give a recommendation?. got stock in an endless loop(had to shutdown the pc) and it didnt work at all; Im new to java it could be several stupid mistakes ;
i can post all my code if necessary;

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }