Im just new to Java and i found this good tutorial for creating a Java Tetris Game.
I dont have a mentor or a tutor to help me with this - Ive been looking for one for ages :( so currently im self learning java and PHP :)
Anyways heres the website i found http://zetcode.com/tutorials/javagamestutorial/tetris/
can someone explain how this method works from the tutorial?
Tetrominoes shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; }
I know it gets called form the Paint() Method
for (int i = 0; i < BoardHeight; ++i) {
for (int j = 0; j < BoardWidth; ++j) {
Tetrominoes shape = shapeAt(j, BoardHeight - i - 1);
if (shape != Tetrominoes.NoShape)
drawSquare(g, 0 + j * squareWidth(),
boardTop + i * squareHeight(), shape);
}
}
From what i understand - it loops at each square of the board and determines if there is a shape (Enum) stored on the board[] array.
I just need someone to explain to me how this portion paints all shapes, or remains of the shapes, that have been dropped to the bottom of the board?
And how All the squares are rememberd in the board[] array?
Thank you