}
public List<Brick> getBricks() {
return bricks;
}
public void setBricks(List<Brick> bricks) {
this.bricks = bricks;
}
public Arkanoid(int width, int height) {
this.width = width;
this.height = height;
}
public static void main(String [] args) {}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public void checkBricksBump() {
for (int i = 0, bricksSize = bricks.size(); i < bricksSize;) {
Brick currentBrick = bricks.get(i);
if (currentBrick.isIntersec(ball)) {
double angel = Math.random() * 360;
ball.setDirection(angel);
bricks.remove(currentBrick);
break;
}
i++;
}
}
public void checkStandBump () {
if (ball.isIntersec(stand)) {
double angle = 90 + 20 * (Math.random() - 0.5);
ball.setDirection(angle);
}
}
public void checkEndGame () {
if (ball.getY() > height) {
isGameOver = true;
}
}
}
package com.javarush.task.task24.task2413;
import java.util.List;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Iterator;
public class Arkanoid {
private int width, height;
private Ball ball;
private Stand stand;
private List<Brick> bricks;
private boolean isGameOver;
public static Arkanoid game;
public void run() {}
public void move () {
stand.move();
ball.move();
}
public void draw(Canvas canvas) {
stand.draw(canvas);
ball.draw(canvas);
for (Brick brk: bricks) {
brk.draw(canvas);
}
}
public Ball getBall() {
return ball;
}
public void setBall(Ball ball) {
this.ball = ball;
}
public Stand getStand() {
return stand;
}
public void setStand(Stand stand) {
this.stand = stand;
}
public List<Brick> getBricks() {
return bricks;
}
public void setBricks(List<Brick> bricks) {
this.bricks = bricks;
}
public Arkanoid(int width, int height) {
this.width = width;
this.height = height;
}
public static void main(String [] args) {}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public void checkBricksBump() {
for (int i = 0, bricksSize = bricks.size(); i < bricksSize;) {
Brick currentBrick = bricks.get(i);
if (currentBrick.isIntersec(ball)) {
double angel = Math.random() * 360;
ball.setDirection(angel);
bricks.remove(currentBrick);
break;
}
i++;
}
}
public void checkStandBump () {
if (ball.isIntersec(stand)) {
double angle = 90 + 20 * (Math.random() - 0.5);
ball.setDirection(angle);
}
}
public void checkEndGame () {
if (ball.getY() > height) {
isGameOver = true;
}
}
}