mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 20:14:00 -04:00
Handle coordinate precision the same as Scratch 2 (#1722)
This commit is contained in:
parent
2ca735eab4
commit
bb82c46f8a
3 changed files with 39 additions and 17 deletions
test/unit
26
test/unit/blocks_motion.js
Normal file
26
test/unit/blocks_motion.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const test = require('tap').test;
|
||||
const Motion = require('../../src/blocks/scratch3_motion');
|
||||
const Runtime = require('../../src/engine/runtime');
|
||||
const Sprite = require('../../src/sprites/sprite.js');
|
||||
const RenderedTarget = require('../../src/sprites/rendered-target.js');
|
||||
|
||||
test('getPrimitives', t => {
|
||||
const rt = new Runtime();
|
||||
const motion = new Motion(rt);
|
||||
t.type(motion.getPrimitives(), 'object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Coordinates have limited precision', t => {
|
||||
const rt = new Runtime();
|
||||
const motion = new Motion(rt);
|
||||
const sprite = new Sprite(null, rt);
|
||||
const target = new RenderedTarget(sprite, rt);
|
||||
const util = {target};
|
||||
|
||||
motion.goToXY({X: 0.999999999, Y: 0.999999999}, util);
|
||||
|
||||
t.equals(motion.getX({}, util), 1);
|
||||
t.equals(motion.getY({}, util), 1);
|
||||
t.end();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue