1
0
Fork 0

reindent project

This commit is contained in:
rxbn 2019-12-01 17:39:37 +01:00
parent a8982fc940
commit 1f5c6edd03
6 changed files with 181 additions and 181 deletions

View File

@ -10,69 +10,69 @@ import java.awt.Color;
*/ */
public class Constants { public class Constants {
/** /**
* The screen width in pixels * The screen width in pixels
*/ */
public static final Integer SCREEN_WIDTH = 880; public static final Integer SCREEN_WIDTH = 880;
/** /**
* The screen height in pixels * The screen height in pixels
*/ */
public static final Integer SCREEN_HEIGHT = 750; public static final Integer SCREEN_HEIGHT = 750;
/** /**
* the application name * the application name
*/ */
public static final String APP_TITLE = "BreakOut"; public static final String APP_TITLE = "BreakOut";
/** /**
* Debugging flag for special rendering hints * Debugging flag for special rendering hints
*/ */
public static final boolean DEBUG_MODE = false; public static final boolean DEBUG_MODE = false;
/** /**
* The background color for the game menu * The background color for the game menu
*/ */
public static final Color BACKGROUND = new Color(52, 152, 219); public static final Color BACKGROUND = new Color(52, 152, 219);
/** /**
* Amount of columns for blocks * Amount of columns for blocks
*/ */
public static final Integer SQUARES_X = 22; public static final Integer SQUARES_X = 22;
/** /**
* Amount of the rows * Amount of the rows
*/ */
public static final Integer SQUARES_Y = 30; public static final Integer SQUARES_Y = 30;
/** /**
* The paddle width in pixels * The paddle width in pixels
*/ */
public static final Integer PADDLE_WIDTH = 70; public static final Integer PADDLE_WIDTH = 70;
/** /**
* The paddle height in pixels * The paddle height in pixels
*/ */
public static final Integer PADDLE_HEIGHT = 15; public static final Integer PADDLE_HEIGHT = 15;
/** /**
* The distance between paddle and the lower reflection offset. * The distance between paddle and the lower reflection offset.
*/ */
public static final Double REFLECTION_OFFSET = 25.0; public static final Double REFLECTION_OFFSET = 25.0;
/** /**
* The ball diameter in pixels * The ball diameter in pixels
*/ */
public static final Integer BALL_DIAMETER = 15; public static final Integer BALL_DIAMETER = 15;
/** /**
* The paddle speed * The paddle speed
*/ */
public static final Double DX_MOVEMENT = 4.5; public static final Double DX_MOVEMENT = 4.5;
/** /**
* The ball speed * The ball speed
*/ */
public static final Double BALL_SPEED = 1.20; public static final Double BALL_SPEED = 1.20;
} }

View File

@ -2,9 +2,9 @@ package break_out.model;
public interface IBall { public interface IBall {
// Exercise 1 // Exercise 1
public void updatePosition(); public void updatePosition();
public void reactOnBorder(); public void reactOnBorder();
public Position getPosition(); public Position getPosition();
public Vector2D getDirection(); public Vector2D getDirection();
} }

View File

@ -1,8 +1,8 @@
package break_out.model; package break_out.model;
public interface ILevel { public interface ILevel {
// Exercise 1 // Exercise 1
public Ball getBall(); public Ball getBall();
public Paddle getPaddleTop(); public Paddle getPaddleTop();
public Paddle getPaddleBottom(); public Paddle getPaddleBottom();
} }

View File

@ -4,14 +4,14 @@ import java.awt.*;
public interface IPaddle { public interface IPaddle {
// Exercise 2 // Exercise 2
public Position getPosition(); public Position getPosition();
public void setPosition(Position position); public void setPosition(Position position);
public Color getColor(); public Color getColor();
public void setColor(Color color); public void setColor(Color color);
public double getWidth(); public double getWidth();
public void setWidth(double width); public void setWidth(double width);
public double getHeight(); public double getHeight();
public void setHeight(double height); public void setHeight(double height);
} }

View File

@ -2,11 +2,11 @@ package break_out.model;
public interface IVector2D { public interface IVector2D {
// Exercise 1 // Exercise 1
public double getDx(); public double getDx();
public void setDx(double dx); public void setDx(double dx);
public double getDy(); public double getDy();
public void setDy(double dy); public void setDy(double dy);
public void rescale(); public void rescale();
} }

View File

@ -12,134 +12,134 @@ import javax.swing.JPanel;
/** /**
* This panel represents the background for special divisions in this application * This panel represents the background for special divisions in this application
* *
* @author dmlux * @author dmlux
* *
*/ */
public class SectionPanel extends JPanel { public class SectionPanel extends JPanel {
/** /**
* Automatic generated serial version UID * Automatic generated serial version UID
*/ */
private static final long serialVersionUID = -7773487090869704154L; private static final long serialVersionUID = -7773487090869704154L;
/** /**
* Color of the panel * Color of the panel
*/ */
private Color color; private Color color;
/** /**
* Thickness of the border * Thickness of the border
*/ */
protected int strokeSize = 1; protected int strokeSize = 1;
/** /**
* Color of the shadow * Color of the shadow
*/ */
protected Color shadowColor = new Color(50, 50, 50); protected Color shadowColor = new Color(50, 50, 50);
/** /**
* Shadow flag * Shadow flag
*/ */
protected boolean shady = true; protected boolean shady = true;
/** /**
* Double value for the vertical curvature * Double value for the vertical curvature
*/ */
protected Dimension arcs = new Dimension(10, 10); protected Dimension arcs = new Dimension(10, 10);
/** /**
* Distance of shadow to the panel border * Distance of shadow to the panel border
*/ */
protected int shadowGap = 3; protected int shadowGap = 3;
/** /**
* Shadow offset * Shadow offset
*/ */
protected int shadowOffset = 3; protected int shadowOffset = 3;
/** /**
* Shadow transparency * Shadow transparency
*/ */
protected int shadowAlpha = 200; protected int shadowAlpha = 200;
/**
* A constructor for the section panel
*/
public SectionPanel() {
super();
setOpaque(false);
// set background color /**
this.color = new Color(220, 220, 220); * A constructor for the section panel
} */
public SectionPanel() {
super();
setOpaque(false);
/** // set background color
* A constructor that expects a background color for this panel this.color = new Color(220, 220, 220);
* }
* @param background The background color
*/
public SectionPanel(Color background) {
super();
setOpaque(false);
// set background /**
this.color = background; * A constructor that expects a background color for this panel
} *
* @param background The background color
*/
public SectionPanel(Color background) {
super();
setOpaque(false);
// set background
@Override this.color = background;
public void setBackground(Color bg) { }
color = bg;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth(); @Override
int height = getHeight(); public void setBackground(Color bg) {
int shadowGap = this.shadowGap; color = bg;
repaint();
}
Color shadowColorA = new Color(shadowColor.getRed(), @Override
shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha); protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g; super.paintComponent(g);
// Sets antialiasing int width = getWidth();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, int height = getHeight();
RenderingHints.VALUE_ANTIALIAS_ON); int shadowGap = this.shadowGap;
// Draws shadow borders if any. Color shadowColorA = new Color(shadowColor.getRed(),
if (shady) { shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha);
g2.setColor(shadowColorA); Graphics2D g2 = (Graphics2D) g;
g2.fillRoundRect(shadowOffset, // X position
shadowOffset, // Y position
width - strokeSize - shadowOffset, // width
height - strokeSize - shadowOffset, // height
arcs.width, arcs.height); // arc Dimension
} else
shadowGap = 1;
// Draws the rounded opaque panel with borders. // Sets antialiasing
Color c1 = color; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
int nr = Math.min((color.getRed() + 40), 255); RenderingHints.VALUE_ANTIALIAS_ON);
int ng = Math.min((color.getGreen() + 40), 255);
int nb = Math.min((color.getBlue() + 40), 255);
Color c2 = new Color(nr, ng, nb);
GradientPaint gradient = new GradientPaint(0, 0, c1, getWidth(),
getHeight(), c2, true);
g2.setPaint(gradient);
g2.fillRoundRect(0, 0, width - shadowGap, height - shadowGap,
arcs.width, arcs.height);
g2.setColor(new Color(120, 120, 120)); // Draws shadow borders if any.
g2.setStroke(new BasicStroke(strokeSize)); if (shady) {
g2.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, g2.setColor(shadowColorA);
arcs.width, arcs.height); g2.fillRoundRect(shadowOffset, // X position
shadowOffset, // Y position
width - strokeSize - shadowOffset, // width
height - strokeSize - shadowOffset, // height
arcs.width, arcs.height); // arc Dimension
} else
shadowGap = 1;
// Sets strokes to default, is better. // Draws the rounded opaque panel with borders.
g2.setStroke(new BasicStroke()); Color c1 = color;
} int nr = Math.min((color.getRed() + 40), 255);
int ng = Math.min((color.getGreen() + 40), 255);
int nb = Math.min((color.getBlue() + 40), 255);
Color c2 = new Color(nr, ng, nb);
GradientPaint gradient = new GradientPaint(0, 0, c1, getWidth(),
getHeight(), c2, true);
g2.setPaint(gradient);
g2.fillRoundRect(0, 0, width - shadowGap, height - shadowGap,
arcs.width, arcs.height);
g2.setColor(new Color(120, 120, 120));
g2.setStroke(new BasicStroke(strokeSize));
g2.drawRoundRect(0, 0, width - shadowGap, height - shadowGap,
arcs.width, arcs.height);
// Sets strokes to default, is better.
g2.setStroke(new BasicStroke());
}
} }