MCPcopy Create free account
hub / github.com/codecombat/codecombat / addRect

Function addRect

app/lib/terrain-generation.js:908–924  ·  view source on GitHub ↗
(result, rect)

Source from the content-addressed store, hash-verified

906}
907
908function addRect (result, rect) {
909 if (result.falseCount > 100) {
910 // console.log('infinite loop', rect)
911 result.falseCount = 0
912 return true
913 }
914
915 for (const existingRect of result.rects) {
916 if ((Math.abs(existingRect.x - rect.x) <= ((rect.width / 2) + (existingRect.width / 2))) && (Math.abs(existingRect.y - rect.y) <= ((rect.height / 2) + (existingRect.height / 2)))) {
917 result.falseCount++
918 return false
919 }
920 }
921
922 result.rects.push(rect)
923 return true
924}
925
926function getRandomThang (thangList) {
927 return thangList[_.random(0, thangList.length - 1)]

Callers 2

generateDecorationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected