Game for OLC Code Jam 2022
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

utils.js 598B

1234567891011121314151617181920
  1. const randRange = (low, high) => Math.random() * (high - low) + low;
  2. const toRadians = (degrees) => degrees * Math.PI / 180;
  3. const mapNumber = (value, fromLow, fromHigh, toLow, toHigh) => {
  4. const normalized = (value - fromLow) / (fromHigh - fromLow);
  5. return normalized * (toHigh - toLow) + toLow;
  6. };
  7. let fps_value = 0;
  8. let fps_frames = 0;
  9. let fps_last_capture = Date.now();
  10. const fps = () => {
  11. fps_frames++;
  12. if (Date.now() - fps_last_capture >= 500) {
  13. fps_value = fps_frames * 2;
  14. fps_frames = 0;
  15. fps_last_capture = Date.now();
  16. }
  17. return fps_value;
  18. }