Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean moveMouse(WidgetChild w) {
- int x = w.getAbsoluteX() + Random.nextInt(0, w.getWidth()), y = w.getAbsoluteY() + Random.nextInt(0, w.getHeight());
- int startX = Mouse.getX(),
- startY = Mouse.getY(),
- startDX = Mouse.getX(),
- startDY = Mouse.getY(); // where mouse started
- double distX = Math.abs( (double) startX - x ),
- distY = Math.abs( (double) startY - y ),
- dist = Math.sqrt( distX * distX + distY * distY ); // Distance from start to finish
- double width = 2.0 * dist* ( (0.5 * (double) w.getWidth()) / Math.max(distX, distY));
- double time = Random.nextDouble(125, 150) + Random.nextDouble(90, 100) * (Math.log( 2.0 * dist / width ) / Math.log(2)); // fitts law brah
- double bPoint = 0;
- if(dist > 100) bPoint = dist / 20; // Last 20% of the distance
- double friction = Random.nextDouble(-1.00, 1.00); //Random friction, to be safe
- for(int i = 0; i < (int) dist; i++) {
- if(startDX < x)
- startDX++;
- else if (startDX > x) startDX--;
- if(startDY < y)
- startDY++;
- else if (startDY > y) startDY--;
- //TODO: save points, randomize using friction, find different friction for diff surfaces
- }
- if(Mouse.getX() == x && Mouse.getY() == y) return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement