I am trying to make a tetris game in java. I have made the functions to move the shapes in the matrix. But I don't know how to access those functions when a key is pressed from keyboard on runtime.
public class tetris
{
public static void main(String args[])throws InterruptedException
{
int score=0;
int height=30;
int width=30;
board obj=new board(height,width);
SquareShape sq=new SquareShape(height,width);
while(true)
{
System.out.println("\t Score: "+score);
obj.createboard();
board.update(sq);
obj.dispboard();
sq.movedown();
Thread.sleep(1000);
System.out.print("\033[H\033[2J");
}
}
}