- Amarelo 4 pontos;
- Verde 8 pontos;
- Laranja 12 pontos;
- Vermelho 16 pontos.
public int update(Ball ball){
int rangeX = 30;
int rangeY = 10;
boolean rangeXBlock = ball.getPosXBall() >= posX - rangeX && ball.getPosXBall() <= posX + rangeX;
boolean rangeYBlock = ball.getPosYBall() >= posY - rangeY && ball.getPosYBall() <= posY + rangeY;
if(rangeXBlock && rangeYBlock && !destroyed){
destroyed = true;
ball.speedY *= -1;
switch (imagetype) {
case "/Sprites/blockred.png":
return 4;
case "/Sprites/blockorange.png":
return 3;
case "/Sprites/blockgreen.png":
return 2;
case "/Sprites/blockyellow.png":
return 1;
}
}
return 0;
}
public void updateScore(int value){
score += value * 4;
}
public void updateLevel(ArrayList<Blocks> blocks, Game game, Ball ball){
if(this.score == level * 960){
level++;
blocks.clear();
game.drawBlocks();
ball.updateSpeed(1.5);
}
public boolean GameOver(Ball ball){
if(ball.getPosYBall() > 650){
lostLife++;
if(lostLife >= 3){return true;}
else{ball.setDefaultValues();}}
return false;
}
- A Move para a esquerda;
- D Move para a direita;
- Espaço Aumenta a velocidade da bola;
- Enter Reinicia o jogo.
public class Keyboard implements KeyListener {
[...]
@Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
if (code == KeyEvent.VK_A){keyLeft = true;}
if (code == KeyEvent.VK_D){keyRight = true;}
if (code == KeyEvent.VK_SPACE){keySpeed = true;}
if (code == KeyEvent.VK_ENTER){keyRestart = true;}
}
@Override
public void keyReleased(KeyEvent e) {
int code = e.getKeyCode();
if (code == KeyEvent.VK_A){keyLeft = false;}
if (code == KeyEvent.VK_D){keyRight = false;}
if (code == KeyEvent.VK_SPACE){keySpeed = false;}
if (code == KeyEvent.VK_ENTER){keyRestart = false;}
}
}
public void update(Keyboard keyboardPlayer){
if (keyboardPlayer.keyRight){x += speed;}
else if (keyboardPlayer.keyLeft){x -= speed;}
public void update(int coordX, int coordY){
getCollision(coordX,coordY);
double speedUp = 0;
if (keyboardBall.keySpeed){speedUp = 1.5;}
this.x -= speedX + speedUp * speedX;
this.y += speedY + speedUp * speedY;
public void restartGame(){
if(keyboard.keyRestart){
if(information.GameOver(ball)){
information.restartGameOver();}
else{
ball.setDefaultValues();
information.setDefaultValues();
blocks.clear();
drawBlocks();}
}
}