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 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() + { + + } +} 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(); + } +} diff --git a/cicaprojekt/Drawer.java b/cicaprojekt/Drawer.java new file mode 100644 index 0000000..c275898 --- /dev/null +++ b/cicaprojekt/Drawer.java @@ -0,0 +1,8 @@ +package cicaprojekt; + +public interface Drawer { + + public void draw(); + public int getX(); + public int getY(); +} diff --git a/cicaprojekt/FlowOfTime.java b/cicaprojekt/FlowOfTime.java index 496a372..aadbcaa 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(GameoverCause.TIMEOUT); + } + } + + public void start(long delay) { + schedule(new GameOver(), delay); } } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index f4bd744..a8c3737 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -21,8 +21,8 @@ public class Game { flowoftime = new FlowOfTime(); } - public void allZPMsCollected() { - this.stopGame(); + public void allZPMsCollected(GameoverCause cause) { + this.stopGame(cause); } public void startGame(File dungeonFile) throws IOException { @@ -40,6 +40,6 @@ public class Game { return Direction.values()[random.nextInt(Direction.values().length)]; } - public void stopGame() { + public void stopGame(GameoverCause cause) { } } 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; +} 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(); + } + +} 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