-
-
Save sscholl/fa1fb5c725fc3563fac7b4cf01ac5adc to your computer and use it in GitHub Desktop.
parse terrain from screeps png
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getPx('https://s3.amazonaws.com/static.screeps.com/map2/'+ roomName+ '.png', function(err, pixels) { | |
if (err) { | |
throw err; | |
} | |
let kyskip = 50 * 3 * 3 * 4; | |
let kxskip = 3 * 4; | |
for (let yy = 0; yy < 50; ++yy) { | |
for (let xx = 0; xx < 50; ++xx) { | |
let px = pixels.data[xx * kxskip + yy * kyskip] * 0x10000 + pixels.data[xx * kxskip + yy * kyskip + 1] * 0x100 + pixels.data[xx * kxskip + yy * kyskip + 2]; | |
switch (px) { | |
case 0: // wall | |
break; | |
case 16773702: // source | |
break; | |
case 5263440: // controller | |
break; | |
case 2829099: | |
case 3289650: | |
// plain | |
break; | |
case 2303251: //swamp | |
case 0x640000: // keeper | |
break; | |
default: | |
throw new Error('px '+ px); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment