Merge branch 'master' into game
This commit is contained in:
commit
bf191678a6
|
@ -27,4 +27,5 @@ local.properties
|
|||
.cproject
|
||||
.buildpath
|
||||
.idea
|
||||
out/*
|
||||
out/*
|
||||
Test.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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package cicaprojekt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Display {
|
||||
private List<Drawer> visuals;
|
||||
|
||||
public Display() {
|
||||
visuals = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addVisual(Drawer visual) {
|
||||
visuals.add(visual);
|
||||
}
|
||||
|
||||
public void drawVisuals() {
|
||||
for(Drawer visual : visuals)
|
||||
visual.draw();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package cicaprojekt;
|
||||
|
||||
public interface Drawer {
|
||||
|
||||
public void draw();
|
||||
public int getX();
|
||||
public int getY();
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package cicaprojekt;
|
||||
|
||||
public enum GameoverCause {
|
||||
TIMEOUT, ONEILLWON, JAFFAWON;
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue