diff --git a/src/break_out/Constants.java b/src/break_out/Constants.java index f1a3747..f045ada 100644 --- a/src/break_out/Constants.java +++ b/src/break_out/Constants.java @@ -10,69 +10,69 @@ import java.awt.Color; */ public class Constants { - /** - * The screen width in pixels - */ - public static final Integer SCREEN_WIDTH = 880; + /** + * The screen width in pixels + */ + public static final Integer SCREEN_WIDTH = 880; - /** - * The screen height in pixels - */ - public static final Integer SCREEN_HEIGHT = 750; + /** + * The screen height in pixels + */ + public static final Integer SCREEN_HEIGHT = 750; - /** - * the application name - */ - public static final String APP_TITLE = "BreakOut"; + /** + * the application name + */ + public static final String APP_TITLE = "BreakOut"; - /** - * Debugging flag for special rendering hints - */ - public static final boolean DEBUG_MODE = false; + /** + * Debugging flag for special rendering hints + */ + public static final boolean DEBUG_MODE = false; - /** - * The background color for the game menu - */ - public static final Color BACKGROUND = new Color(52, 152, 219); + /** + * The background color for the game menu + */ + public static final Color BACKGROUND = new Color(52, 152, 219); - /** - * Amount of columns for blocks - */ - public static final Integer SQUARES_X = 22; + /** + * Amount of columns for blocks + */ + public static final Integer SQUARES_X = 22; - /** - * Amount of the rows - */ - public static final Integer SQUARES_Y = 30; + /** + * Amount of the rows + */ + public static final Integer SQUARES_Y = 30; - /** - * The paddle width in pixels - */ - public static final Integer PADDLE_WIDTH = 70; + /** + * The paddle width in pixels + */ + public static final Integer PADDLE_WIDTH = 70; - /** - * The paddle height in pixels - */ - public static final Integer PADDLE_HEIGHT = 15; + /** + * The paddle height in pixels + */ + public static final Integer PADDLE_HEIGHT = 15; - /** - * The distance between paddle and the lower reflection offset. - */ - public static final Double REFLECTION_OFFSET = 25.0; + /** + * The distance between paddle and the lower reflection offset. + */ + public static final Double REFLECTION_OFFSET = 25.0; - /** - * The ball diameter in pixels - */ - public static final Integer BALL_DIAMETER = 15; + /** + * The ball diameter in pixels + */ + public static final Integer BALL_DIAMETER = 15; - /** - * The paddle speed - */ - public static final Double DX_MOVEMENT = 4.5; + /** + * The paddle speed + */ + public static final Double DX_MOVEMENT = 4.5; - /** - * The ball speed - */ - public static final Double BALL_SPEED = 1.20; + /** + * The ball speed + */ + public static final Double BALL_SPEED = 1.20; } \ No newline at end of file diff --git a/src/break_out/model/IBall.java b/src/break_out/model/IBall.java index fd5c227..a2ce223 100644 --- a/src/break_out/model/IBall.java +++ b/src/break_out/model/IBall.java @@ -2,9 +2,9 @@ package break_out.model; public interface IBall { - // Exercise 1 - public void updatePosition(); - public void reactOnBorder(); - public Position getPosition(); - public Vector2D getDirection(); + // Exercise 1 + public void updatePosition(); + public void reactOnBorder(); + public Position getPosition(); + public Vector2D getDirection(); } diff --git a/src/break_out/model/ILevel.java b/src/break_out/model/ILevel.java index 2142b2b..af8777e 100644 --- a/src/break_out/model/ILevel.java +++ b/src/break_out/model/ILevel.java @@ -1,8 +1,8 @@ package break_out.model; public interface ILevel { - // Exercise 1 - public Ball getBall(); - public Paddle getPaddleTop(); - public Paddle getPaddleBottom(); + // Exercise 1 + public Ball getBall(); + public Paddle getPaddleTop(); + public Paddle getPaddleBottom(); } \ No newline at end of file diff --git a/src/break_out/model/IPaddle.java b/src/break_out/model/IPaddle.java index de0cae9..f3a7e1d 100644 --- a/src/break_out/model/IPaddle.java +++ b/src/break_out/model/IPaddle.java @@ -4,14 +4,14 @@ import java.awt.*; public interface IPaddle { - // Exercise 2 - public Position getPosition(); - public void setPosition(Position position); - public Color getColor(); - public void setColor(Color color); - public double getWidth(); - public void setWidth(double width); - public double getHeight(); - public void setHeight(double height); + // Exercise 2 + public Position getPosition(); + public void setPosition(Position position); + public Color getColor(); + public void setColor(Color color); + public double getWidth(); + public void setWidth(double width); + public double getHeight(); + public void setHeight(double height); } \ No newline at end of file diff --git a/src/break_out/model/IVector2D.java b/src/break_out/model/IVector2D.java index 0353f3c..8e2e5f7 100644 --- a/src/break_out/model/IVector2D.java +++ b/src/break_out/model/IVector2D.java @@ -2,11 +2,11 @@ package break_out.model; public interface IVector2D { - // Exercise 1 - public double getDx(); - public void setDx(double dx); - public double getDy(); - public void setDy(double dy); + // Exercise 1 + public double getDx(); + public void setDx(double dx); + public double getDy(); + public void setDy(double dy); - public void rescale(); + public void rescale(); } \ No newline at end of file diff --git a/src/break_out/view/SectionPanel.java b/src/break_out/view/SectionPanel.java index 0ea1f0c..216073f 100644 --- a/src/break_out/view/SectionPanel.java +++ b/src/break_out/view/SectionPanel.java @@ -12,134 +12,134 @@ import javax.swing.JPanel; /** * This panel represents the background for special divisions in this application - * + * * @author dmlux - * + * */ public class SectionPanel extends JPanel { - /** - * Automatic generated serial version UID - */ - private static final long serialVersionUID = -7773487090869704154L; + /** + * Automatic generated serial version UID + */ + private static final long serialVersionUID = -7773487090869704154L; - /** - * Color of the panel - */ - private Color color; + /** + * Color of the panel + */ + private Color color; - /** - * Thickness of the border - */ - protected int strokeSize = 1; + /** + * Thickness of the border + */ + protected int strokeSize = 1; - /** - * Color of the shadow - */ - protected Color shadowColor = new Color(50, 50, 50); + /** + * Color of the shadow + */ + protected Color shadowColor = new Color(50, 50, 50); - /** - * Shadow flag - */ - protected boolean shady = true; + /** + * Shadow flag + */ + protected boolean shady = true; - /** - * Double value for the vertical curvature - */ - protected Dimension arcs = new Dimension(10, 10); + /** + * Double value for the vertical curvature + */ + protected Dimension arcs = new Dimension(10, 10); - /** - * Distance of shadow to the panel border - */ - protected int shadowGap = 3; + /** + * Distance of shadow to the panel border + */ + protected int shadowGap = 3; - /** - * Shadow offset - */ - protected int shadowOffset = 3; + /** + * Shadow offset + */ + protected int shadowOffset = 3; - /** - * Shadow transparency - */ - protected int shadowAlpha = 200; + /** + * Shadow transparency + */ + 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); - /** - * A constructor that expects a background color for this panel - * - * @param background The background color - */ - public SectionPanel(Color background) { - super(); - setOpaque(false); + // set background color + this.color = new Color(220, 220, 220); + } - // 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); - - @Override - public void setBackground(Color bg) { - color = bg; - repaint(); - } + // set background + this.color = background; + } - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - int width = getWidth(); - int height = getHeight(); - int shadowGap = this.shadowGap; + @Override + public void setBackground(Color bg) { + color = bg; + repaint(); + } - Color shadowColorA = new Color(shadowColor.getRed(), - shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha); - Graphics2D g2 = (Graphics2D) g; + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); - // Sets antialiasing - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + int width = getWidth(); + int height = getHeight(); + int shadowGap = this.shadowGap; - // Draws shadow borders if any. - if (shady) { - g2.setColor(shadowColorA); - 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; + Color shadowColorA = new Color(shadowColor.getRed(), + shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha); + Graphics2D g2 = (Graphics2D) g; - // Draws the rounded opaque panel with borders. - 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); + // Sets antialiasing + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - g2.setColor(new Color(120, 120, 120)); - g2.setStroke(new BasicStroke(strokeSize)); - g2.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, - arcs.width, arcs.height); + // Draws shadow borders if any. + if (shady) { + g2.setColor(shadowColorA); + 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. - g2.setStroke(new BasicStroke()); - } + // Draws the rounded opaque panel with borders. + 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()); + } }