diff options
author | Pacien TRAN-GIRARD | 2015-11-24 11:11:17 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-24 11:11:17 +0100 |
commit | bc477506342411e9156b3230d847cb92bcb8e5f9 (patch) | |
tree | d952a5d14dccef38bfba3f8e27bfe10ea65d446a /src/ch/epfl/maze/graphics/GraphicComponent.java | |
parent | 903553fe9e03e4af75eb7f8547e08b480bc58ec4 (diff) | |
download | maze-solver-bc477506342411e9156b3230d847cb92bcb8e5f9.tar.gz |
Reformat code
Diffstat (limited to 'src/ch/epfl/maze/graphics/GraphicComponent.java')
-rw-r--r-- | src/ch/epfl/maze/graphics/GraphicComponent.java | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/ch/epfl/maze/graphics/GraphicComponent.java b/src/ch/epfl/maze/graphics/GraphicComponent.java index e49a542..44b4b1f 100644 --- a/src/ch/epfl/maze/graphics/GraphicComponent.java +++ b/src/ch/epfl/maze/graphics/GraphicComponent.java | |||
@@ -13,7 +13,6 @@ import java.awt.image.ImageObserver; | |||
13 | /** | 13 | /** |
14 | * Graphic component of an animal that will be drawn by an {@link Animation}. | 14 | * Graphic component of an animal that will be drawn by an {@link Animation}. |
15 | */ | 15 | */ |
16 | |||
17 | public final class GraphicComponent { | 16 | public final class GraphicComponent { |
18 | 17 | ||
19 | /* constants */ | 18 | /* constants */ |
@@ -35,7 +34,6 @@ public final class GraphicComponent { | |||
35 | * @param position Position at which the image will be drawn | 34 | * @param position Position at which the image will be drawn |
36 | * @param action Action that the component needs to perform | 35 | * @param action Action that the component needs to perform |
37 | */ | 36 | */ |
38 | |||
39 | public GraphicComponent(BufferedImage image, Vector2D position, Action action) { | 37 | public GraphicComponent(BufferedImage image, Vector2D position, Action action) { |
40 | // sanity checks | 38 | // sanity checks |
41 | if (image == null) { | 39 | if (image == null) { |
@@ -58,7 +56,6 @@ public final class GraphicComponent { | |||
58 | /** | 56 | /** |
59 | * Notifies the component that it will die between two squares. | 57 | * Notifies the component that it will die between two squares. |
60 | */ | 58 | */ |
61 | |||
62 | public void willDieMoving() { | 59 | public void willDieMoving() { |
63 | mAction = new Action(mAction.getDirection(), mAction.isSuccessful(), true); | 60 | mAction = new Action(mAction.getDirection(), mAction.isSuccessful(), true); |
64 | } | 61 | } |
@@ -71,7 +68,6 @@ public final class GraphicComponent { | |||
71 | * @param g Graphic environment | 68 | * @param g Graphic environment |
72 | * @param targetWindow Window on which the graphic is being drawn | 69 | * @param targetWindow Window on which the graphic is being drawn |
73 | */ | 70 | */ |
74 | |||
75 | public void paint(float ratio, Graphics2D g, ImageObserver targetWindow) { | 71 | public void paint(float ratio, Graphics2D g, ImageObserver targetWindow) { |
76 | if (mAction.getDirection() == Direction.NONE) { | 72 | if (mAction.getDirection() == Direction.NONE) { |
77 | renderStuck(g, targetWindow); | 73 | renderStuck(g, targetWindow); |
@@ -98,7 +94,6 @@ public final class GraphicComponent { | |||
98 | * @param targetWindow Frame display | 94 | * @param targetWindow Frame display |
99 | * @param buzz Buzzes the animal, used when he has just hit a wall | 95 | * @param buzz Buzzes the animal, used when he has just hit a wall |
100 | */ | 96 | */ |
101 | |||
102 | private void renderMove(float ratio, Graphics2D g, ImageObserver targetWindow, boolean buzz) { | 97 | private void renderMove(float ratio, Graphics2D g, ImageObserver targetWindow, boolean buzz) { |
103 | // transforms direction into vector | 98 | // transforms direction into vector |
104 | Vector2D heading = mAction.getDirection().toVector().mul(SQUARE_SIZE); | 99 | Vector2D heading = mAction.getDirection().toVector().mul(SQUARE_SIZE); |
@@ -142,7 +137,6 @@ public final class GraphicComponent { | |||
142 | * @param g Graphic environment | 137 | * @param g Graphic environment |
143 | * @param targetWindow Frame display | 138 | * @param targetWindow Frame display |
144 | */ | 139 | */ |
145 | |||
146 | private void renderStuck(Graphics2D g, ImageObserver targetWindow) { | 140 | private void renderStuck(Graphics2D g, ImageObserver targetWindow) { |
147 | // loads default frame of image with default direction | 141 | // loads default frame of image with default direction |
148 | BufferedImage img = cropImage(-1, Direction.NONE); | 142 | BufferedImage img = cropImage(-1, Direction.NONE); |
@@ -176,7 +170,6 @@ public final class GraphicComponent { | |||
176 | * @param dir The direction towards which the component faces | 170 | * @param dir The direction towards which the component faces |
177 | * @return The correct frame that faces towards the direction specified | 171 | * @return The correct frame that faces towards the direction specified |
178 | */ | 172 | */ |
179 | |||
180 | private BufferedImage cropImage(float ratio, Direction dir) { | 173 | private BufferedImage cropImage(float ratio, Direction dir) { |
181 | int width = mImage.getWidth(); | 174 | int width = mImage.getWidth(); |
182 | int height = mImage.getHeight(); | 175 | int height = mImage.getHeight(); |
@@ -218,4 +211,5 @@ public final class GraphicComponent { | |||
218 | 211 | ||
219 | return img; | 212 | return img; |
220 | } | 213 | } |
214 | |||
221 | } | 215 | } |