Compare commits
5 Commits
5a340867ae
...
23c795a2e7
Author | SHA1 | Date | |
---|---|---|---|
|
23c795a2e7 | ||
|
f3b15428e7 | ||
|
936f6670e9 | ||
|
124a4649b0 | ||
|
2d3e3289f9 |
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
GamePanel.java
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,13 +6,21 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
public class Board extends JPanel
|
public class Board extends JPanel
|
||||||
{
|
{
|
||||||
public static final int BOARD_WIDTH=10;
|
public static final int BOARD_WIDTH=10;
|
||||||
public static final int BOARD_HEIGHT=20;
|
public static final int BOARD_HEIGHT=20;
|
||||||
public static final int BLOCK_SIZE=30;
|
public static final int BLOCK_SIZE=30;
|
||||||
|
|
||||||
|
public static final int BOARDRIGHT_WIDTH=15;
|
||||||
|
public static final int BOARDRIGHT_HEIGHT=5;
|
||||||
private Timer loop;
|
private Timer loop;
|
||||||
private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
|
private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
|
||||||
|
private Color[] [] shape ={
|
||||||
|
{Color.YELLOW,Color.YELLOW,Color.YELLOW},
|
||||||
|
{null,Color.YELLOW,null}
|
||||||
|
};
|
||||||
|
|
||||||
public Board() {
|
public Board() {
|
||||||
loop = new Timer(500, new ActionListener() {
|
loop = new Timer(500, new ActionListener() {
|
||||||
@ -32,13 +40,25 @@ public class Board extends JPanel
|
|||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
g.setColor(Color.DARK_GRAY);
|
g.setColor(Color.DARK_GRAY);
|
||||||
|
|
||||||
for(int row= 0; row< BOARD_HEIGHT;row++)
|
//shape mit 2-Forschleife
|
||||||
{
|
for(int i=0;i< shape.length;i++){
|
||||||
|
for(int j = 0;j< shape[0].length;j++){
|
||||||
|
if(shape[i][j] !=null){
|
||||||
|
g.setColor(shape[i][j]);
|
||||||
|
g.fillRect(i*BLOCK_SIZE,j*BLOCK_SIZE,BLOCK_SIZE,BLOCK_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int row = 0; row < BOARD_HEIGHT+1; row++) {
|
||||||
g.drawLine(0, BLOCK_SIZE * row, BLOCK_SIZE * BOARD_WIDTH, BLOCK_SIZE * row);
|
g.drawLine(0, BLOCK_SIZE * row, BLOCK_SIZE * BOARD_WIDTH, BLOCK_SIZE * row);
|
||||||
}
|
}
|
||||||
for(int col= 0; col< BOARD_WIDTH +1; col++)
|
for (int col = 0; col < BOARD_WIDTH+1; col++) {
|
||||||
{
|
|
||||||
g.drawLine(col * BLOCK_SIZE, 0, col * BLOCK_SIZE, BLOCK_SIZE * BOARD_HEIGHT);
|
g.drawLine(col * BLOCK_SIZE, 0, col * BLOCK_SIZE, BLOCK_SIZE * BOARD_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package Tetris;
|
package Tetris;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
public class GameGui {
|
public class GameGui {
|
||||||
public static final int width= 445, height =629;
|
public static final int width= 500, height =650;
|
||||||
private Board board;
|
private Board board;
|
||||||
private JFrame window;
|
private JFrame window;
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ public class GameGui {
|
|||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
board = new Board();
|
board = new Board();
|
||||||
window.add(board);
|
window.add(board);
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void main(String [] args)
|
public static void main(String [] args)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user