2.0.2 • Published 6 years ago

@dnode/move.2d v2.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

dependencies | 0 | 0

Usage

Get a single move of the object to the target

const getMove = require('@dnode/move.2d');

const objectPosition = { x: -1, y: 5 };
const objectSpeed = 5;
const targetPosition = { x: 10, y: -10 };

const move = getMove(objectPosition, objectSpeed, targetPosition);

Move the object till it arrives the target

const getMove = require('@dnode/move.2d');

const objectPosition = { x: 10, y: -10 };
const objectSpeed = 20;
const targetPosition = { x: 800, y: 700 };

let move;
do {
  move = getMove(objectPosition, objectSpeed, targetPosition);
  objectPosition.x += move.x;
  objectPosition.y += move.y;
} while (move.move && !move.arrive);
2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago