Stein bewegen sich im Rahmen des Spielfelds
This commit is contained in:
parent
11eef601e0
commit
8d0ab1bf7b
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,7 +15,7 @@ public class Board extends JPanel implements KeyListener
|
|||||||
private static int FPS =60;
|
private static int FPS =60;
|
||||||
private static int delay =FPS/1000;
|
private static int delay =FPS/1000;
|
||||||
|
|
||||||
public static final int BOARD_WIDTH=10;
|
public static final int BOARD_WIDTH=11;
|
||||||
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;
|
||||||
|
|
||||||
@ -40,9 +40,14 @@ public class Board extends JPanel implements KeyListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(System.currentTimeMillis() -beginTime > delayTime){
|
if(!(x + deltax + shape[0].length >11) && !(x + deltax<0))
|
||||||
|
{
|
||||||
x +=deltax;
|
x +=deltax;
|
||||||
|
}
|
||||||
|
|
||||||
deltax= 0;
|
deltax= 0;
|
||||||
|
if(System.currentTimeMillis() -beginTime > delayTime){
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
beginTime=System.currentTimeMillis();
|
beginTime=System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class GameGui {
|
public class GameGui {
|
||||||
public static final int width= 500, height =650;
|
public static final int width= 550, height =650;
|
||||||
private Board board;
|
private Board board;
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user