Aufgabe 2.1 + reindent project
This commit is contained in:
parent
1f5c6edd03
commit
c9f87ace17
|
@ -6,7 +6,6 @@ import java.awt.Color;
|
|||
* A class that contains all constant values to configure the game
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher
|
||||
*
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import break_out.view.View;
|
|||
* are initialized here.
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher
|
||||
*
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@ import break_out.view.View;
|
|||
* The controller takes care of the input events and reacts on those events by
|
||||
* manipulating the view and updates the model.
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher and I. Traupe
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher and I. Traupe, modified by Gruppe 175
|
||||
*/
|
||||
public class Controller implements ActionListener, KeyListener {
|
||||
|
||||
|
@ -32,8 +31,7 @@ public class Controller implements ActionListener, KeyListener {
|
|||
/**
|
||||
* The constructor expects a view to construct itself.
|
||||
*
|
||||
* @param view
|
||||
* The view that is connected to this controller
|
||||
* @param view The view that is connected to this controller
|
||||
*/
|
||||
public Controller(View view) {
|
||||
this.view = view;
|
||||
|
@ -101,6 +99,7 @@ public class Controller implements ActionListener, KeyListener {
|
|||
/**
|
||||
* This method will be called, after a key was typed. This means, that the key
|
||||
* was pressed and released, before this method get called.
|
||||
*
|
||||
* @param e The key event
|
||||
*/
|
||||
@Override
|
||||
|
@ -110,6 +109,7 @@ public class Controller implements ActionListener, KeyListener {
|
|||
|
||||
/**
|
||||
* This method will be called, after a key was pressed down.
|
||||
*
|
||||
* @param e The key event
|
||||
*/
|
||||
@Override
|
||||
|
@ -119,6 +119,7 @@ public class Controller implements ActionListener, KeyListener {
|
|||
|
||||
/**
|
||||
* This method will be called, after a key was released.
|
||||
*
|
||||
* @param e The key event
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -7,9 +7,8 @@ import break_out.Constants;
|
|||
*
|
||||
* @author iSchumacher
|
||||
* @author modified by Gruppe 175: Moritz Henseleit, Ruben Meyer
|
||||
*
|
||||
*/
|
||||
public class Ball implements IBall{
|
||||
public class Ball implements IBall {
|
||||
|
||||
/**
|
||||
* The balls position on the playground
|
||||
|
@ -27,16 +26,17 @@ public class Ball implements IBall{
|
|||
*/
|
||||
public Ball() {
|
||||
this.position = new Position(0, 0);
|
||||
this.direction = new Vector2D(Constants.BALL_SPEED,Constants.BALL_SPEED);
|
||||
this.direction = new Vector2D(Constants.BALL_SPEED, Constants.BALL_SPEED);
|
||||
this.direction.rescale();
|
||||
|
||||
// start at bottom-center
|
||||
this.position.setX((Constants.SCREEN_WIDTH - Constants.BALL_DIAMETER)/2);
|
||||
this.position.setY(Constants.SCREEN_HEIGHT-Constants.BALL_DIAMETER);
|
||||
this.position.setX((Constants.SCREEN_WIDTH - Constants.BALL_DIAMETER) / 2.0);
|
||||
this.position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER - Constants.PADDLE_HEIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the balls position
|
||||
*
|
||||
* @return position The balls current position
|
||||
*/
|
||||
public Position getPosition() {
|
||||
|
@ -45,6 +45,7 @@ public class Ball implements IBall{
|
|||
|
||||
/**
|
||||
* The getter for the balls direction
|
||||
*
|
||||
* @return direction The balls current direction
|
||||
*/
|
||||
public Vector2D getDirection() {
|
||||
|
@ -56,38 +57,38 @@ public class Ball implements IBall{
|
|||
*/
|
||||
public void updatePosition() {
|
||||
// sets X position
|
||||
this.position.setX(this.position.getX()+this.direction.getDx());
|
||||
this.position.setX(this.position.getX() + this.direction.getDx());
|
||||
|
||||
// sets Y position
|
||||
this.position.setY(this.position.getY()+this.direction.getDy());
|
||||
// sets Y position
|
||||
this.position.setY(this.position.getY() + this.direction.getDy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ball reacts to contact with the borders
|
||||
*/
|
||||
public void reactOnBorder() {
|
||||
// reacts on left border
|
||||
if(this.position.getX() <= 0) {
|
||||
this.position.setX(0);
|
||||
this.direction.setDx(-(this.direction.getDx()));
|
||||
// reacts on left border
|
||||
if (this.position.getX() <= 0) {
|
||||
this.position.setX(0);
|
||||
this.direction.setDx(-(this.direction.getDx()));
|
||||
}
|
||||
|
||||
// reacts on right border (-Diameter because of hitbox)
|
||||
if(this.position.getX() >= Constants.SCREEN_WIDTH - Constants.BALL_DIAMETER) {
|
||||
// reacts on right border (-Diameter because of hitbox)
|
||||
if (this.position.getX() >= Constants.SCREEN_WIDTH - Constants.BALL_DIAMETER) {
|
||||
this.position.setX(Constants.SCREEN_WIDTH - Constants.BALL_DIAMETER);
|
||||
this.direction.setDx(-(this.direction.getDx()));
|
||||
}
|
||||
|
||||
// reacts on top border
|
||||
if(this.position.getY() <= 0) {
|
||||
this.position.setY(0);
|
||||
this.direction.setDy(-(this.direction.getDy()));
|
||||
// reacts on top border
|
||||
if (this.position.getY() <= 0) {
|
||||
this.position.setY(0);
|
||||
this.direction.setDy(-(this.direction.getDy()));
|
||||
}
|
||||
|
||||
// reacts on bottom border (+Diameter because of hitbox)
|
||||
if(this.position.getY() >= Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER) {
|
||||
this.position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER);
|
||||
this.direction.setDy(-(this.direction.getDy()));
|
||||
// reacts on bottom border (+Diameter because of hitbox)
|
||||
if (this.position.getY() >= Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER) {
|
||||
this.position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER);
|
||||
this.direction.setDy(-(this.direction.getDy()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ import break_out.view.View;
|
|||
/**
|
||||
* This class contains information about the game (the model in MVC)
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher, modified by Gruppe 175
|
||||
*/
|
||||
public class Game {
|
||||
|
||||
|
@ -47,8 +46,7 @@ public class Game {
|
|||
/**
|
||||
* The constructor creates a new game instance with the given Controller
|
||||
*
|
||||
* @param controller
|
||||
* The controller to manage this instance (MVC-patter)
|
||||
* @param controller The controller to manage this instance (MVC-patter)
|
||||
*/
|
||||
public Game(Controller controller) {
|
||||
this.controller = controller;
|
||||
|
@ -102,10 +100,8 @@ public class Game {
|
|||
* maxLevel. If the current level is higher than maxLevel the view will be
|
||||
* switched to the startScreen.
|
||||
*
|
||||
* @param levelnr
|
||||
* The number for the next level
|
||||
* @param score
|
||||
* The current players score after finishing the previous level.
|
||||
* @param levelnr The number for the next level
|
||||
* @param score The current players score after finishing the previous level.
|
||||
*/
|
||||
public void createLevel(int levelnr, int score) {
|
||||
this.score = score;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package break_out.model;
|
||||
|
||||
|
||||
import break_out.Constants;
|
||||
|
||||
/**
|
||||
* This class contains information about the running game
|
||||
*
|
||||
|
@ -8,117 +10,152 @@ package break_out.model;
|
|||
* @author I. Schumacher
|
||||
* @author modified by Gruppe 175: Moritz Henseleit, Ruben Meyer
|
||||
*/
|
||||
public class Level extends Thread {
|
||||
public class Level extends Thread implements ILevel {
|
||||
|
||||
/**
|
||||
* The game to which the level belongs
|
||||
*/
|
||||
private Game game;
|
||||
/**
|
||||
* The game to which the level belongs
|
||||
*/
|
||||
private Game game;
|
||||
|
||||
/**
|
||||
* The number of the level
|
||||
*/
|
||||
private int levelnr;
|
||||
/**
|
||||
* The number of the level
|
||||
*/
|
||||
private int levelnr;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The score of the level
|
||||
*/
|
||||
private int score;
|
||||
private int score;
|
||||
|
||||
/**
|
||||
* The ball of the level
|
||||
*/
|
||||
private Ball ball;
|
||||
/**
|
||||
* The ball of the level
|
||||
*/
|
||||
private Ball ball;
|
||||
|
||||
/**
|
||||
* Flag that shows if the ball was started
|
||||
*/
|
||||
private boolean ballWasStarted = true;
|
||||
/**
|
||||
* Flag that shows if the ball was started
|
||||
*/
|
||||
private boolean ballWasStarted = true;
|
||||
|
||||
/**
|
||||
* The constructor creates a new level object and needs the current game object,
|
||||
* the number of the level to be created and the current score
|
||||
* @param game The game object
|
||||
* @param levelnr The number of the new level object
|
||||
* @param score The score
|
||||
*/
|
||||
public Level(Game game, int levelnr, int score) {
|
||||
this.game = game;
|
||||
this.levelnr = levelnr;
|
||||
this.score = score;
|
||||
this.ball = new Ball();
|
||||
/**
|
||||
* The paddles of the level
|
||||
*/
|
||||
private Paddle paddleTop, paddleBottom;
|
||||
|
||||
loadLevelData(levelnr);
|
||||
}
|
||||
/**
|
||||
* The constructor creates a new level object and needs the current game object,
|
||||
* the number of the level to be created and the current score
|
||||
*
|
||||
* @param game The game object
|
||||
* @param levelnr The number of the new level object
|
||||
* @param score The score
|
||||
*/
|
||||
public Level(Game game, int levelnr, int score) {
|
||||
this.game = game;
|
||||
this.levelnr = levelnr;
|
||||
this.score = score;
|
||||
this.ball = new Ball();
|
||||
|
||||
/**
|
||||
* The getter for the ball object
|
||||
* @return ball The ball of the level
|
||||
*/
|
||||
public Ball getBall() {
|
||||
return this.ball;
|
||||
}
|
||||
// calc paddle positions
|
||||
Position posPaddleTop = new Position((Constants.SCREEN_WIDTH - Constants.PADDLE_WIDTH) / 2.0, 0);
|
||||
Position posPaddleBottom = new Position((Constants.SCREEN_WIDTH - Constants.PADDLE_WIDTH) / 2.0, Constants.SCREEN_HEIGHT - Constants.PADDLE_HEIGHT);
|
||||
|
||||
/**
|
||||
* Sets ballWasStarted to true, the ball is moving
|
||||
*/
|
||||
public void startBall() {
|
||||
ballWasStarted = true;
|
||||
}
|
||||
// set paddles
|
||||
this.paddleTop = new Paddle(posPaddleTop);
|
||||
this.paddleBottom = new Paddle(posPaddleBottom);
|
||||
|
||||
/**
|
||||
* Sets ballWasStarted to false, the ball is stopped
|
||||
*/
|
||||
public void stopBall() {
|
||||
ballWasStarted = false;
|
||||
}
|
||||
loadLevelData(levelnr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the ball is moving or stopped
|
||||
* @return ballWasStarted True: the ball is moving; false: the ball is stopped
|
||||
*/
|
||||
public boolean ballWasStarted() {
|
||||
return ballWasStarted;
|
||||
}
|
||||
/**
|
||||
* The getter for the ball object
|
||||
*
|
||||
* @return ball The ball of the level
|
||||
*/
|
||||
public Ball getBall() {
|
||||
return this.ball;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method of the level thread
|
||||
*/
|
||||
public void run() {
|
||||
game.notifyObservers();
|
||||
/**
|
||||
* Sets ballWasStarted to true, the ball is moving
|
||||
*/
|
||||
public void startBall() {
|
||||
ballWasStarted = true;
|
||||
}
|
||||
|
||||
// endless loop
|
||||
while (true) {
|
||||
// if ballWasStarted is true, the ball is moving
|
||||
if (ballWasStarted) {
|
||||
/**
|
||||
* Sets ballWasStarted to false, the ball is stopped
|
||||
*/
|
||||
public void stopBall() {
|
||||
ballWasStarted = false;
|
||||
}
|
||||
|
||||
// Call here the balls method for updating his position on the playground
|
||||
this.ball.updatePosition();
|
||||
/**
|
||||
* Returns if the ball is moving or stopped
|
||||
*
|
||||
* @return ballWasStarted True: the ball is moving; false: the ball is stopped
|
||||
*/
|
||||
public boolean ballWasStarted() {
|
||||
return ballWasStarted;
|
||||
}
|
||||
|
||||
// Call here the balls method for reacting on the borders of the playground
|
||||
this.ball.reactOnBorder();
|
||||
/**
|
||||
* The method of the level thread
|
||||
*/
|
||||
public void run() {
|
||||
game.notifyObservers();
|
||||
|
||||
// endless loop
|
||||
while (true) {
|
||||
// if ballWasStarted is true, the ball is moving
|
||||
if (ballWasStarted) {
|
||||
|
||||
// Call here the balls method for updating his position on the playground
|
||||
this.ball.updatePosition();
|
||||
|
||||
// Call here the balls method for reacting on the borders of the playground
|
||||
this.ball.reactOnBorder();
|
||||
|
||||
|
||||
// Tells the observer to repaint the components on the playground
|
||||
game.notifyObservers();
|
||||
// Tells the observer to repaint the components on the playground
|
||||
game.notifyObservers();
|
||||
|
||||
}
|
||||
// The thread pauses for a short time
|
||||
try {
|
||||
Thread.sleep(4);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The thread pauses for a short time
|
||||
try {
|
||||
Thread.sleep(4);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the information for the level from a json-file located in the folder /res of the project
|
||||
* @param levelnr The number X for the LevelX.json file
|
||||
*/
|
||||
private void loadLevelData(int levelnr) {
|
||||
/**
|
||||
* Loads the information for the level from a json-file located in the folder /res of the project
|
||||
*
|
||||
* @param levelnr The number X for the LevelX.json file
|
||||
*/
|
||||
private void loadLevelData(int levelnr) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the top paddle object
|
||||
*
|
||||
* @return paddleTop The top paddle of the level
|
||||
*/
|
||||
public Paddle getPaddleTop() {
|
||||
return paddleTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the bottom paddle object
|
||||
*
|
||||
* @return paddleBottom The bottom paddle of the level
|
||||
*/
|
||||
public Paddle getPaddleBottom() {
|
||||
return paddleBottom;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package break_out.model;
|
||||
|
||||
import break_out.Constants;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* This class contains the information about the paddles characteristics and behavior
|
||||
*
|
||||
* @author Gruppe 175: Moritz Henseleit, Ruben Meyer
|
||||
*/
|
||||
public class Paddle implements IPaddle {
|
||||
|
||||
/**
|
||||
* The paddles position on the playground
|
||||
*/
|
||||
private Position position;
|
||||
|
||||
/**
|
||||
* The paddles sizing
|
||||
*/
|
||||
private double width;
|
||||
private double height;
|
||||
|
||||
/**
|
||||
* The paddles color
|
||||
*/
|
||||
private Color color;
|
||||
|
||||
/**
|
||||
* The constructor of a paddle
|
||||
*/
|
||||
public Paddle(Position position) {
|
||||
this.position = position;
|
||||
|
||||
// set sizing
|
||||
width = Constants.PADDLE_WIDTH;
|
||||
height = Constants.PADDLE_HEIGHT;
|
||||
|
||||
// set color
|
||||
color = Color.CYAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the paddles position
|
||||
*
|
||||
* @return position The paddles current position
|
||||
*/
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* The setter for the paddles position
|
||||
*
|
||||
* @param position The paddles new position
|
||||
*/
|
||||
public void setPosition(Position position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the paddles color
|
||||
*
|
||||
* @return color The paddles current color
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* The setter for the paddles color
|
||||
*
|
||||
* @param color The paddles new color
|
||||
*/
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the paddles width
|
||||
*
|
||||
* @return width The paddles current width
|
||||
*/
|
||||
public double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* The setter for the paddles width
|
||||
*
|
||||
* @param width The paddles new width
|
||||
*/
|
||||
public void setWidth(double width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* The getter for the paddles height
|
||||
*
|
||||
* @return height The paddles current height
|
||||
*/
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* The setter for the paddles height
|
||||
*
|
||||
* @param height The paddles new height
|
||||
*/
|
||||
public void setHeight(double height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ package break_out.model;
|
|||
* This class represents a position within the board in pixel coordinates
|
||||
*
|
||||
* @author dmlux
|
||||
*
|
||||
*/
|
||||
public class Position {
|
||||
|
||||
|
@ -41,6 +40,7 @@ public class Position {
|
|||
|
||||
/**
|
||||
* Setter for the x-coordinate
|
||||
*
|
||||
* @param x The new x-coordinate
|
||||
*/
|
||||
public void setX(double x) {
|
||||
|
@ -58,6 +58,7 @@ public class Position {
|
|||
|
||||
/**
|
||||
* Setter for the y-coordinate
|
||||
*
|
||||
* @param y The new y-coordinate
|
||||
*/
|
||||
public void setY(double y) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Vector2D implements IVector2D {
|
|||
public void rescale() {
|
||||
// calc unit vector and set it
|
||||
double vectorLength = Math.sqrt(Math.pow(getDx(), 2) + Math.pow(getDy(), 2)); //using the square root of x and y
|
||||
setDx((1/vectorLength) * getDx() * Constants.BALL_SPEED);
|
||||
setDy((1/vectorLength) * getDy() * Constants.BALL_SPEED);
|
||||
setDx((1 / vectorLength) * getDx() * Constants.BALL_SPEED);
|
||||
setDy((1 / vectorLength) * getDy() * Constants.BALL_SPEED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class Field extends JPanel {
|
|||
|
||||
/**
|
||||
* Change the background color
|
||||
*
|
||||
* @param color The new color
|
||||
*/
|
||||
public void changeBackground(Color color) {
|
||||
|
@ -70,6 +71,7 @@ public class Field extends JPanel {
|
|||
|
||||
/**
|
||||
* This method is called when painting/repainting the playground
|
||||
*
|
||||
* @param g the graphics object
|
||||
*/
|
||||
@Override
|
||||
|
@ -101,10 +103,17 @@ public class Field extends JPanel {
|
|||
// Calls the method for drawing the grid
|
||||
drawGrid(g2);
|
||||
|
||||
// Calls the method for drawing the bottom paddle
|
||||
drawPaddleBottom(g2);
|
||||
|
||||
// Calls the method for drawing the top paddle
|
||||
drawPaddleTop(g2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the ball
|
||||
*
|
||||
* @param g2 The graphics object
|
||||
*/
|
||||
private void drawBall(Graphics2D g2) {
|
||||
|
@ -116,6 +125,7 @@ public class Field extends JPanel {
|
|||
|
||||
/**
|
||||
* Draws the grid
|
||||
*
|
||||
* @param g2 The graphics object
|
||||
*/
|
||||
private void drawGrid(Graphics2D g2) {
|
||||
|
@ -125,14 +135,44 @@ public class Field extends JPanel {
|
|||
int blockHeight = Constants.SCREEN_HEIGHT / Constants.SQUARES_Y;
|
||||
|
||||
// draw vertical lines
|
||||
for(int i = 1 ; i < Constants.SQUARES_X; i++) {
|
||||
g2.drawLine(i*blockWidth, 0, i*blockWidth, Constants.SCREEN_HEIGHT);
|
||||
for (int i = 1; i < Constants.SQUARES_X; i++) {
|
||||
g2.drawLine(i * blockWidth, 0, i * blockWidth, Constants.SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
// draw horizontal lines
|
||||
for(int i = 1 ; i < Constants.SQUARES_Y; i++) {
|
||||
g2.drawLine(0, i*blockHeight, Constants.SCREEN_WIDTH, i*blockHeight);
|
||||
for (int i = 1; i < Constants.SQUARES_Y; i++) {
|
||||
g2.drawLine(0, i * blockHeight, Constants.SCREEN_WIDTH, i * blockHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the bottom paddle
|
||||
*
|
||||
* @param g2 The graphics object
|
||||
*/
|
||||
private void drawPaddleBottom(Graphics2D g2) {
|
||||
// fillRoundRect(x, y, width, height, arcWidth, arcHeight)
|
||||
g2.fillRoundRect((int) view.getGame().getLevel().getPaddleBottom().getPosition().getX(),
|
||||
(int) view.getGame().getLevel().getPaddleBottom().getPosition().getY(),
|
||||
(int) view.getGame().getLevel().getPaddleBottom().getWidth(),
|
||||
(int) view.getGame().getLevel().getPaddleBottom().getHeight(),
|
||||
10,
|
||||
10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the top paddle
|
||||
*
|
||||
* @param g2 The graphics object
|
||||
*/
|
||||
private void drawPaddleTop(Graphics2D g2) {
|
||||
// fillRoundRect(x, y, width, height, arcWidth, arcHeight)
|
||||
g2.fillRoundRect((int) view.getGame().getLevel().getPaddleTop().getPosition().getX(),
|
||||
(int) view.getGame().getLevel().getPaddleTop().getPosition().getY(),
|
||||
(int) view.getGame().getLevel().getPaddleTop().getWidth(),
|
||||
(int) view.getGame().getLevel().getPaddleTop().getHeight(),
|
||||
10,
|
||||
10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import javax.swing.JPanel;
|
|||
* This panel represents the background for special divisions in this application
|
||||
*
|
||||
* @author dmlux
|
||||
*
|
||||
*/
|
||||
public class SectionPanel extends JPanel {
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import net.miginfocom.swing.MigLayout;
|
|||
* This screen serves the configuration of the game.
|
||||
*
|
||||
* @author dmlux, modified by I. Schumacher
|
||||
*
|
||||
*/
|
||||
public class StartScreen extends JPanel {
|
||||
|
||||
|
@ -142,6 +141,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Adds an action listener to the start button
|
||||
*
|
||||
* @param l The actionListener
|
||||
*/
|
||||
public void addActionListenerToStartButton(ActionListener l) {
|
||||
|
@ -150,6 +150,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Returns the start button
|
||||
*
|
||||
* @return startGame The button for starting the game
|
||||
*/
|
||||
public JButton getStartButton() {
|
||||
|
@ -158,6 +159,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Adds an action listener to the quit button
|
||||
*
|
||||
* @param l The actionListener
|
||||
*/
|
||||
public void addActionListenerToQuitButton(ActionListener l) {
|
||||
|
@ -166,6 +168,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Returns the quit button
|
||||
*
|
||||
* @return quitGame The button for ending the game
|
||||
*/
|
||||
public JButton getQuitButton() {
|
||||
|
@ -174,6 +177,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Returns the players name
|
||||
*
|
||||
* @return The name of the player in the JTextField playersName
|
||||
*/
|
||||
public String getPlayersName() {
|
||||
|
@ -182,6 +186,7 @@ public class StartScreen extends JPanel {
|
|||
|
||||
/**
|
||||
* Shows an error in the menu
|
||||
*
|
||||
* @param message The String to be shown
|
||||
*/
|
||||
public void showError(String message) {
|
||||
|
|
|
@ -13,9 +13,8 @@ import break_out.model.Game;
|
|||
*
|
||||
* @author dmlux
|
||||
* @author modified by Gruppe 175: Moritz Henseleit, Ruben Meyer
|
||||
*
|
||||
*/
|
||||
public class View extends JFrame {
|
||||
public class View extends JFrame {
|
||||
|
||||
/**
|
||||
* Automatic generated serial version UID
|
||||
|
@ -78,6 +77,7 @@ public class View extends JFrame {
|
|||
|
||||
/**
|
||||
* Getter for the start screen
|
||||
*
|
||||
* @return startScreen
|
||||
*/
|
||||
public StartScreen getStartScreen() {
|
||||
|
@ -86,6 +86,7 @@ public class View extends JFrame {
|
|||
|
||||
/**
|
||||
* Getter for the playground
|
||||
*
|
||||
* @return field
|
||||
*/
|
||||
public Field getField() {
|
||||
|
@ -94,6 +95,7 @@ public class View extends JFrame {
|
|||
|
||||
/**
|
||||
* Getter for the game
|
||||
*
|
||||
* @return game
|
||||
*/
|
||||
public Game getGame() {
|
||||
|
@ -102,6 +104,7 @@ public class View extends JFrame {
|
|||
|
||||
/**
|
||||
* Setter for the game
|
||||
*
|
||||
* @param game The current game
|
||||
*/
|
||||
public void setGame(Game game) {
|
||||
|
@ -112,6 +115,7 @@ public class View extends JFrame {
|
|||
|
||||
/**
|
||||
* Shows a given screen if the card layout contains this screen
|
||||
*
|
||||
* @param screenName The screen to be shown
|
||||
*/
|
||||
public void showScreen(String screenName) {
|
||||
|
@ -121,6 +125,7 @@ public class View extends JFrame {
|
|||
/**
|
||||
* Called by game.notifyObservers() in the run()-method of Level class
|
||||
* to repaint the playground
|
||||
*
|
||||
* @param game The game to observe
|
||||
*/
|
||||
public void modelChanged(Game game) {
|
||||
|
|
Loading…
Reference in New Issue