diff --git a/src/Tetris/Board.java b/src/Tetris/Board.java new file mode 100644 index 0000000..81bc437 --- /dev/null +++ b/src/Tetris/Board.java @@ -0,0 +1,35 @@ +package Tetris; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JPanel; +import javax.swing.Timer; +public class Board extends JPanel +{ + public static final int BOARD_WIDTH=10; + public static final int BOARD_HEIGHT =20; + private Timer loop; + private Color[][] board = new = Color[20][20]; + public Board() { + loop = new Timer(500, new ActionListener() { + int n = 0; + + @Override + public void actionPerformed(ActionEvent e) { + System.out.println(n++); + } + }); + loop.start(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(Color.blue); + g.fillRect(0,0,getWidth(),getHeight()); + g.setColor(Color.black); + g.drawRect(10,10,200,200); + } +} diff --git a/src/Tetris/GameGui.java b/src/Tetris/GameGui.java index f425a35..ac11d01 100644 --- a/src/Tetris/GameGui.java +++ b/src/Tetris/GameGui.java @@ -4,6 +4,7 @@ import javax.swing.JFrame; public class GameGui { public static final int width= 445, height =629; + private Board board; private JFrame window; public GameGui(){ @@ -12,8 +13,11 @@ public class GameGui { window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setResizable(false); window.setVisible(true); + board = new Board(); + window.add(board); } - public static void main(String [] args){ + public static void main(String [] args) + { new GameGui(); } }