I am remaking Tetris because I am still learning JavaScript and I am doing projects to learn. I am using a grid on a canvas and have already made all of the shapes and made a function that redraws them on one interval and another function that moves the blocks down on another interval. I want to know if I am able to find the pixel color data of the grid spaces around the piece on every frame.
Asked
Active
Viewed 12 times
0
-
Welcome to SO! You can do this, but it doesn't seem like a smart design choice. The game internals should maintain state in data structures, not in pixel colors in the canvas. I'm voting to close as a dupe here and good luck with your project. – ggorlen Jan 10 '20 at 18:02
-
Does this answer your question? [Get pixel color from canvas, on mouseover](https://stackoverflow.com/questions/6735470/get-pixel-color-from-canvas-on-mouseover) (you can adapt mouseover to whatever grid logic you're using--the important part is the pixel color acquisition) – ggorlen Jan 10 '20 at 18:02