Board erstellt

This commit is contained in:
Ewen Kerbs 2021-11-11 14:23:58 +01:00
parent 5241d3f900
commit 74d8c1e6d4
2 changed files with 40 additions and 1 deletions

35
src/Tetris/Board.java Normal file
View File

@ -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);
}
}

View File

@ -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();
}
}