Merge branch 'master' into game

This commit is contained in:
Bokros Bálint 2016-05-07 14:18:43 +02:00
commit bf191678a6
9 changed files with 125 additions and 5 deletions

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ local.properties
.buildpath
.idea
out/*
Test.java

View File

@ -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()
{
}
}

21
cicaprojekt/Display.java Normal file
View File

@ -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();
}
}

8
cicaprojekt/Drawer.java Normal file
View File

@ -0,0 +1,8 @@
package cicaprojekt;
public interface Drawer {
public void draw();
public int getX();
public int getY();
}

View File

@ -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);
}
}

View File

@ -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) {
}
}

View File

@ -0,0 +1,5 @@
package cicaprojekt;
public enum GameoverCause {
TIMEOUT, ONEILLWON, JAFFAWON;
}

View File

@ -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();
}
}

View File

@ -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
}
}