I’ve seen this in a code of tetris game and I’m wondering how these values are able to draw the line, T-shape, S-shape, Z-shape, L-shape, inverted-L and a sqaure.
I get the four parametes maybe because of the four blocks needed per piece. But how did they come up with values like that? Have those something to do with the color too?
int blocks[][] = {
{0x0f00, 0x4444, 0x0f00, 0x4444}, // LINE
{0x04e0, 0x0464, 0x00e4, 0x04c4}, // T
{0x4620, 0x6c00, 0x4620, 0x6c00}, // S
{0x2640, 0xc600, 0x2640, 0xc600}, // Z
{0x6220, 0x1700, 0x2230, 0x0740}, // 7
{0x6440, 0x0e20, 0x44c0, 0x8e00}, // inverted 7
{0x0660, 0x0660, 0x0660, 0x0660}, // square
}
I’m new in Java and I want to learn to “draw” using those values. Thank you very much!
Each row of the table is one shape. Each column is a different rotation for the shape. The square, for instance, is the same no matter how you rotate it. The line (first row) flips between two patterns. I found this in a web search:
http://codeincomplete.com/posts/2011/10/10/javascript_tetris/