reindent project
This commit is contained in:
parent
a8982fc940
commit
1f5c6edd03
@ -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;
|
||||||
|
|
||||||
}
|
}
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
@ -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();
|
||||||
}
|
}
|
@ -18,128 +18,128 @@ import javax.swing.JPanel;
|
|||||||
*/
|
*/
|
||||||
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
|
* A constructor for the section panel
|
||||||
*/
|
*/
|
||||||
public SectionPanel() {
|
public SectionPanel() {
|
||||||
super();
|
super();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
// set background color
|
// set background color
|
||||||
this.color = new Color(220, 220, 220);
|
this.color = new Color(220, 220, 220);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A constructor that expects a background color for this panel
|
* A constructor that expects a background color for this panel
|
||||||
*
|
*
|
||||||
* @param background The background color
|
* @param background The background color
|
||||||
*/
|
*/
|
||||||
public SectionPanel(Color background) {
|
public SectionPanel(Color background) {
|
||||||
super();
|
super();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
// set background
|
// set background
|
||||||
this.color = background;
|
this.color = background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackground(Color bg) {
|
public void setBackground(Color bg) {
|
||||||
color = bg;
|
color = bg;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
int width = getWidth();
|
int width = getWidth();
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
int shadowGap = this.shadowGap;
|
int shadowGap = this.shadowGap;
|
||||||
|
|
||||||
Color shadowColorA = new Color(shadowColor.getRed(),
|
Color shadowColorA = new Color(shadowColor.getRed(),
|
||||||
shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha);
|
shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha);
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
|
||||||
// Sets antialiasing
|
// Sets antialiasing
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
// Draws shadow borders if any.
|
// Draws shadow borders if any.
|
||||||
if (shady) {
|
if (shady) {
|
||||||
g2.setColor(shadowColorA);
|
g2.setColor(shadowColorA);
|
||||||
g2.fillRoundRect(shadowOffset, // X position
|
g2.fillRoundRect(shadowOffset, // X position
|
||||||
shadowOffset, // Y position
|
shadowOffset, // Y position
|
||||||
width - strokeSize - shadowOffset, // width
|
width - strokeSize - shadowOffset, // width
|
||||||
height - strokeSize - shadowOffset, // height
|
height - strokeSize - shadowOffset, // height
|
||||||
arcs.width, arcs.height); // arc Dimension
|
arcs.width, arcs.height); // arc Dimension
|
||||||
} else
|
} else
|
||||||
shadowGap = 1;
|
shadowGap = 1;
|
||||||
|
|
||||||
// Draws the rounded opaque panel with borders.
|
// Draws the rounded opaque panel with borders.
|
||||||
Color c1 = color;
|
Color c1 = color;
|
||||||
int nr = Math.min((color.getRed() + 40), 255);
|
int nr = Math.min((color.getRed() + 40), 255);
|
||||||
int ng = Math.min((color.getGreen() + 40), 255);
|
int ng = Math.min((color.getGreen() + 40), 255);
|
||||||
int nb = Math.min((color.getBlue() + 40), 255);
|
int nb = Math.min((color.getBlue() + 40), 255);
|
||||||
Color c2 = new Color(nr, ng, nb);
|
Color c2 = new Color(nr, ng, nb);
|
||||||
GradientPaint gradient = new GradientPaint(0, 0, c1, getWidth(),
|
GradientPaint gradient = new GradientPaint(0, 0, c1, getWidth(),
|
||||||
getHeight(), c2, true);
|
getHeight(), c2, true);
|
||||||
g2.setPaint(gradient);
|
g2.setPaint(gradient);
|
||||||
g2.fillRoundRect(0, 0, width - shadowGap, height - shadowGap,
|
g2.fillRoundRect(0, 0, width - shadowGap, height - shadowGap,
|
||||||
arcs.width, arcs.height);
|
arcs.width, arcs.height);
|
||||||
|
|
||||||
g2.setColor(new Color(120, 120, 120));
|
g2.setColor(new Color(120, 120, 120));
|
||||||
g2.setStroke(new BasicStroke(strokeSize));
|
g2.setStroke(new BasicStroke(strokeSize));
|
||||||
g2.drawRoundRect(0, 0, width - shadowGap, height - shadowGap,
|
g2.drawRoundRect(0, 0, width - shadowGap, height - shadowGap,
|
||||||
arcs.width, arcs.height);
|
arcs.width, arcs.height);
|
||||||
|
|
||||||
// Sets strokes to default, is better.
|
// Sets strokes to default, is better.
|
||||||
g2.setStroke(new BasicStroke());
|
g2.setStroke(new BasicStroke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user