mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Add facing threshold
This commit is contained in:
parent
4449ee7f0f
commit
6cbc71f8d1
1 changed files with 8 additions and 2 deletions
|
@ -43,6 +43,12 @@ const MOVED_THRESHOLD = 3;
|
||||||
*/
|
*/
|
||||||
const SHAKEN_THRESHOLD = 30;
|
const SHAKEN_THRESHOLD = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Threshold for acceleration magnitude, to check if we are facing up.
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
const FACING_THRESHOLD = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acceleration due to gravity, in m/s^2.
|
* Acceleration due to gravity, in m/s^2.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
@ -754,9 +760,9 @@ class Scratch3GdxForBlocks {
|
||||||
isFacing (args) {
|
isFacing (args) {
|
||||||
switch (args.FACING) {
|
switch (args.FACING) {
|
||||||
case FaceValues.UP:
|
case FaceValues.UP:
|
||||||
return this._peripheral.getAccelerationZ() > GRAVITY;
|
return this._peripheral.getAccelerationZ() > FACING_THRESHOLD;
|
||||||
case FaceValues.DOWN:
|
case FaceValues.DOWN:
|
||||||
return this._peripheral.getAccelerationZ() < GRAVITY * -1;
|
return this._peripheral.getAccelerationZ() < FACING_THRESHOLD * -1;
|
||||||
default:
|
default:
|
||||||
log.warn(`Unknown direction in isFacing: ${args.FACING}`);
|
log.warn(`Unknown direction in isFacing: ${args.FACING}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue