Stein unten gefangen
This commit is contained in:
parent
8d0ab1bf7b
commit
9194320d79
@ -31,6 +31,7 @@ public class Board extends JPanel implements KeyListener
|
|||||||
private long beginTime;
|
private long beginTime;
|
||||||
private int delayTime = normal;
|
private int delayTime = normal;
|
||||||
private int deltax = 0;
|
private int deltax = 0;
|
||||||
|
private boolean collision = false;
|
||||||
|
|
||||||
|
|
||||||
public Board() {
|
public Board() {
|
||||||
@ -40,6 +41,9 @@ public class Board extends JPanel implements KeyListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if(collision){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!(x + deltax + shape[0].length >11) && !(x + deltax<0))
|
if(!(x + deltax + shape[0].length >11) && !(x + deltax<0))
|
||||||
{
|
{
|
||||||
x +=deltax;
|
x +=deltax;
|
||||||
@ -47,8 +51,12 @@ public class Board extends JPanel implements KeyListener
|
|||||||
|
|
||||||
deltax= 0;
|
deltax= 0;
|
||||||
if(System.currentTimeMillis() -beginTime > delayTime){
|
if(System.currentTimeMillis() -beginTime > delayTime){
|
||||||
|
if(!(y+1+shape.length > BOARD_HEIGHT)){
|
||||||
y++;
|
y++;
|
||||||
|
}else{
|
||||||
|
collision=true;
|
||||||
|
}
|
||||||
|
|
||||||
beginTime=System.currentTimeMillis();
|
beginTime=System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user