Board erstellt
This commit is contained in:
parent
5241d3f900
commit
74d8c1e6d4
35
src/Tetris/Board.java
Normal file
35
src/Tetris/Board.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import javax.swing.JFrame;
|
|||||||
|
|
||||||
public class GameGui {
|
public class GameGui {
|
||||||
public static final int width= 445, height =629;
|
public static final int width= 445, height =629;
|
||||||
|
private Board board;
|
||||||
private JFrame window;
|
private JFrame window;
|
||||||
|
|
||||||
public GameGui(){
|
public GameGui(){
|
||||||
@ -12,8 +13,11 @@ public class GameGui {
|
|||||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
window.setResizable(false);
|
window.setResizable(false);
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
|
board = new Board();
|
||||||
|
window.add(board);
|
||||||
}
|
}
|
||||||
public static void main(String [] args){
|
public static void main(String [] args)
|
||||||
|
{
|
||||||
new GameGui();
|
new GameGui();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user