Stein unten gefangen

This commit is contained in:
zhe 2021-11-24 20:44:43 +01:00
parent 8d0ab1bf7b
commit 9194320d79

View File

@ -31,6 +31,7 @@ public class Board extends JPanel implements KeyListener
private long beginTime;
private int delayTime = normal;
private int deltax = 0;
private boolean collision = false;
public Board() {
@ -40,6 +41,9 @@ public class Board extends JPanel implements KeyListener
@Override
public void actionPerformed(ActionEvent e) {
if(collision){
return;
}
if(!(x + deltax + shape[0].length >11) && !(x + deltax<0))
{
x +=deltax;
@ -47,8 +51,12 @@ public class Board extends JPanel implements KeyListener
deltax= 0;
if(System.currentTimeMillis() -beginTime > delayTime){
if(!(y+1+shape.length > BOARD_HEIGHT)){
y++;
}else{
collision=true;
}
beginTime=System.currentTimeMillis();
}