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

Function setPixelToWorldScale

JS - Chrome Dino Game Clone/script.js:81–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81function setPixelToWorldScale() {
82 let worldToPixelScale
83 if (window.innerWidth / window.innerHeight < WORLD_WIDTH / WORLD_HEIGHT) {
84 worldToPixelScale = window.innerWidth / WORLD_WIDTH
85 } else {
86 worldToPixelScale = window.innerHeight / WORLD_HEIGHT
87 }
88
89 worldElem.style.width = `${WORLD_WIDTH * worldToPixelScale}px`
90 worldElem.style.height = `${WORLD_HEIGHT * worldToPixelScale}px`
91}

Callers 1

script.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected