MCPcopy Create free account
hub / github.com/NianBroken/Firework_Simulator / updateSpeedFromEvent

Function updateSpeedFromEvent

js/script.js:1200–1213  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

1198let autoLaunchTime = 0;
1199
1200function updateSpeedFromEvent(event) {
1201 if (isUpdatingSpeed || event.y >= mainStage.height - 44) {
1202 // On phones it's hard to hit the edge pixels in order to set speed at 0 or 1, so some padding is provided to make that easier.
1203 const edge = 16;
1204 const newSpeed = (event.x - edge) / (mainStage.width - edge * 2);
1205 simSpeed = Math.min(Math.max(newSpeed, 0), 1);
1206 // show speed bar after an update
1207 speedBarOpacity = 1;
1208 // If we updated the speed, return true
1209 return true;
1210 }
1211 // Return false if the speed wasn't updated
1212 return false;
1213}
1214
1215// Extracted function to keep `update()` optimized
1216function updateGlobals(timeStep, lag) {

Callers 2

handlePointerStartFunction · 0.85
handlePointerMoveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected