Last active
August 29, 2015 13:57
-
-
Save nddrylliog/9403338 to your computer and use it in GitHub Desktop.
Revisions
-
nddrylliog revised this gist
Mar 7, 2014 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ There's an IS_DEV global variable that'll give you access to Game. Don't use it. Read canvas pixels instead, it's much funnier! This gist should contain all you need. Keyboard shortcuts are blocked on the page, use right click -> instead to open the inspector. -
nddrylliog revised this gist
Mar 7, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ There's an IS_DEV global variable that'll give you access to Game. Don't use it. Read canvas pixels instead, it's much funnier! This gist should contain all you need. -
nddrylliog renamed this gist
Mar 7, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nddrylliog revised this gist
Mar 7, 2014 . 4 changed files with 11 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ $('canvas').keydown() // apparently 'click' doesn't work, but keydown works fine. // might want to cache $('canvas') into $canvas or similar for performance. File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,10 @@ var data = $('canvas')[0].getContext("2d").getImageData(0, 0, 800, 512) // data.width and data.height are 800 and 512 // data.data is a native RGBA uint8 array, origin is top-left // getting pixel at x, y could be done with: var r = data.data[(x + y * data.width) * 4 + 0]; var g = data.data[(x + y * data.width) * 4 + 1]; var b = data.data[(x + y * data.width) * 4 + 2]; var a = data.data[(x + y * data.width) * 4 + 3]; -
nddrylliog created this gist
Mar 7, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ // the color of a pipe boundary is (84, 56, 72) // apparently red = 84 is unique anywhere else on canvas for (var x = 0; x < data.width; x++) { var red = data.data[x * 4]; if (red != 84) { continue } console.log("pipe x = ", x); for (var y = 0; y < data.height; y++) { var red2 = data.data[(x + y * data.width) * 4]; if (red2 == 84) { console.log("pipe y = ", y); continue } break } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ $('canvas').keydown() // apparently 'click' doesn't work. 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ var data = $('canvas')[0].getContext("2d").getImageData(0, 0, 800, 512) // data.width and data.height are 800 and 512 // data.data is a native RGBA uint8 array, origin is top-left