MCPcopy Create free account
hub / github.com/codemistic/Web-Development / getNewPosition

Function getNewPosition

Catch Me If You Can/script.js:26–41  ·  view source on GitHub ↗
(boxWidth, boxHeight)

Source from the content-addressed store, hash-verified

24
25
26function getNewPosition(boxWidth, boxHeight) {
27
28 // The boxWidth and boxHeight are subtracted so that they would not move out from the right and bottom direction
29 var newX = Math.floor((Math.random() * viewWidth) + 1 - boxWidth);
30 var newY = Math.floor((Math.random() * viewHeight) + 1 - boxHeight);
31
32 // These will satisfy that box does not move go out in the top and left direction
33 if(newX < 0) {
34 newX = 0;
35 }
36 if(newY < 0) {
37 newY = 0;
38 }
39
40 return {x: newX, y: newY};
41}

Callers 1

script.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected