Game for OLC Code Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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. }