From d228415e41c48d1dfd00ce833b3ebc688eb11d8a Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 13:28:42 +0200 Subject: [PATCH 01/10] ImagePanel.java added to display images --- cicaprojekt/ImagePanel.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cicaprojekt/ImagePanel.java diff --git a/cicaprojekt/ImagePanel.java b/cicaprojekt/ImagePanel.java new file mode 100644 index 0000000..2085226 --- /dev/null +++ b/cicaprojekt/ImagePanel.java @@ -0,0 +1,28 @@ +package cicaprojekt; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JPanel; + +public class ImagePanel extends JPanel{ + + private BufferedImage image; + + public ImagePanel(String path) { + try { + image = ImageIO.read(new File(path)); + } catch (IOException ex) { + } + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters + } + +} \ No newline at end of file From f728bd4667988b5d88ba2351cc47133c789628e3 Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 13:34:26 +0200 Subject: [PATCH 02/10] Drawer interface added --- cicaprojekt/Drawer.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 cicaprojekt/Drawer.java diff --git a/cicaprojekt/Drawer.java b/cicaprojekt/Drawer.java new file mode 100644 index 0000000..561cc7b --- /dev/null +++ b/cicaprojekt/Drawer.java @@ -0,0 +1,7 @@ +package cicaprojekt; + +public interface Drawer { + + public void draw(); + +} From 446b2b57f363765a3bb175814762e42c5c8ec657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 13:35:20 +0200 Subject: [PATCH 03/10] implemented all the good stuff in FlowOfTime.java --- cicaprojekt/FlowOfTime.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cicaprojekt/FlowOfTime.java b/cicaprojekt/FlowOfTime.java index 496a372..c6c1d9c 100644 --- a/cicaprojekt/FlowOfTime.java +++ b/cicaprojekt/FlowOfTime.java @@ -6,8 +6,18 @@ import java.util.TimerTask; public class FlowOfTime extends Timer { private TimerTask timeup; private long gametime; + private Game game; - public void start() { + private class GameOver extends TimerTask { + + @Override + public void run() { + game.stopGame(); + } + } + + public void start(long delay) { + schedule(new GameOver(), delay); } } From e4e7367a825e338ece80124c39f87175c3e7df68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 13:36:38 +0200 Subject: [PATCH 04/10] added GameoverCause.java -- enum to indicate cause of Game's ending --- cicaprojekt/GameoverCause.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cicaprojekt/GameoverCause.java diff --git a/cicaprojekt/GameoverCause.java b/cicaprojekt/GameoverCause.java new file mode 100644 index 0000000..acb49e5 --- /dev/null +++ b/cicaprojekt/GameoverCause.java @@ -0,0 +1,5 @@ +package cicaprojekt; + +public enum GameoverCause { + TIMEOUT, ONEILLWON, JAFFAWON; +} From e3d720f611f8aa4f63db642e2906ac865dae88ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 13:38:34 +0200 Subject: [PATCH 05/10] added Test.java to .gitignore -- use this for quick&dirty local tests --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 396c617..e9a50f8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ local.properties .cproject .buildpath .idea -out/* \ No newline at end of file +out/* +Test.java \ No newline at end of file From 7c3cbee3cccb71e6c71a4f738b2772960ed46888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 13:43:26 +0200 Subject: [PATCH 06/10] added GameoverCause to function sigtanures in Game --- cicaprojekt/Game.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 43acf95..6243aed 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -9,13 +9,13 @@ public class Game { public static void main(String[] args) { } - public void allZPMsCollected() { - this.stopGame(); + public void allZPMsCollected(GameoverCause cause) { + this.stopGame(cause); } public void startGame() { } - public void stopGame() { + public void stopGame(GameoverCause cause) { } } From 3ef7bdd4115a2eddadb2c42d4a6ba3e7b1ee4aff Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 13:46:03 +0200 Subject: [PATCH 07/10] Display.java added to store visual elements --- cicaprojekt/Display.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cicaprojekt/Display.java diff --git a/cicaprojekt/Display.java b/cicaprojekt/Display.java new file mode 100644 index 0000000..16ed820 --- /dev/null +++ b/cicaprojekt/Display.java @@ -0,0 +1,21 @@ +package cicaprojekt; + +import java.util.ArrayList; +import java.util.List; + +public class Display { + private List visuals; + + public Display() { + visuals = new ArrayList<>(); + } + + public void addVisual(Drawer visual) { + visuals.add(visual); + } + + public void drawVisuals() { + for(Drawer visual : visuals) + visual.draw(); + } +} From 27de97aaad6b41885832bea1f620e0204e686999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 13:51:05 +0200 Subject: [PATCH 08/10] added GameoverCause.TIMEOUT to FlowOfTime's timeout call --- cicaprojekt/FlowOfTime.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicaprojekt/FlowOfTime.java b/cicaprojekt/FlowOfTime.java index c6c1d9c..aadbcaa 100644 --- a/cicaprojekt/FlowOfTime.java +++ b/cicaprojekt/FlowOfTime.java @@ -13,7 +13,7 @@ public class FlowOfTime extends Timer { @Override public void run() { - game.stopGame(); + game.stopGame(GameoverCause.TIMEOUT); } } From 098f0cba62fcd4710806c83e7a42dd335c19b5ea Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 14:04:05 +0200 Subject: [PATCH 09/10] Clients now can call getX and getY for objects which implement Drawer. GapDrawer.java added --- cicaprojekt/Drawer.java | 3 ++- cicaprojekt/GapDrawer.java | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cicaprojekt/GapDrawer.java diff --git a/cicaprojekt/Drawer.java b/cicaprojekt/Drawer.java index 561cc7b..c275898 100644 --- a/cicaprojekt/Drawer.java +++ b/cicaprojekt/Drawer.java @@ -3,5 +3,6 @@ package cicaprojekt; public interface Drawer { public void draw(); - + public int getX(); + public int getY(); } diff --git a/cicaprojekt/GapDrawer.java b/cicaprojekt/GapDrawer.java new file mode 100644 index 0000000..9a7e370 --- /dev/null +++ b/cicaprojekt/GapDrawer.java @@ -0,0 +1,28 @@ +package cicaprojekt; + +public class GapDrawer extends ImagePanel implements Drawer{ + + private Gap gap; + + public GapDrawer(Gap g) { + super("Gap.png"); + gap = g; + setVisible(false); + } + + @Override + public void draw() { + setVisible(true); + } + + @Override + public int getX() { + return gap.getX(); + } + + @Override + public int getY() { + return gap.getY(); + } + +} From 9e93cf89289a052d14c9343a31ee4f3bdd240f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 14:09:39 +0200 Subject: [PATCH 10/10] added ApplicationFrame.java -- to be implemented --- cicaprojekt/ApplicationFrame.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cicaprojekt/ApplicationFrame.java diff --git a/cicaprojekt/ApplicationFrame.java b/cicaprojekt/ApplicationFrame.java new file mode 100644 index 0000000..27a8017 --- /dev/null +++ b/cicaprojekt/ApplicationFrame.java @@ -0,0 +1,19 @@ +package cicaprojekt; + +import javax.swing.*; + +public class ApplicationFrame implements Runnable +{ + private JFrame jframe; + + + public ApplicationFrame(){ + jframe = new JFrame(); + } + + @Override + public void run() + { + + } +}