Skip to content
Snippets Groups Projects
Commit 49c6973b authored by c7h-alb-u1's avatar c7h-alb-u1
Browse files

Update res/walls1.txt, res/walls2.txt, res/walls3.txt, res/walls4.txt,...

Update res/walls1.txt, res/walls2.txt, res/walls3.txt, res/walls4.txt, res/walls5.txt, res/walls6.txt, src/GameFrame.java, src/GamePanel.java, src/Main.java, src/ReadFile.java, src/Walls.java, Built Jars/MazeGame.jar files
Deleted bin/GameFrame.class, bin/GamePanel.class, bin/Main.class, bin/ReadFile.class, bin/Walls.class, bin/walls1.txt, bin/walls2.txt, bin/walls3.txt, bin/walls4.txt, bin/walls5.txt, bin/walls6.txt, .classpath, .project, BuiltArtifacts/MazeGame.jar files
parent b30d2409
Branches
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener { ...@@ -20,7 +20,7 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener {
private Walls walls; private Walls walls;
private boolean running; private boolean running;
private boolean nextMap = false; public boolean nextMap = false;
public GamePanel(int mapN) { public GamePanel(int mapN) {
timer.start(); timer.start();
...@@ -58,13 +58,6 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener { ...@@ -58,13 +58,6 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener {
if (walls.finishWallsCollision(x, y, playerSize, playerSize)) { if (walls.finishWallsCollision(x, y, playerSize, playerSize)) {
running = false; running = false;
} }
if (!running) {
RoundFinishe(g);
}
}
public void RoundFinishe(Graphics g) {
if (!running) { if (!running) {
g.setColor(Color.black); g.setColor(Color.black);
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());
...@@ -73,8 +66,8 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener { ...@@ -73,8 +66,8 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener {
nextMap = true; nextMap = true;
} }
}
}
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
int c = e.getKeyCode(); int c = e.getKeyCode();
...@@ -127,6 +120,7 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener { ...@@ -127,6 +120,7 @@ public class GamePanel extends JPanel implements ActionListener, KeyListener {
y = getHeight() - playerSize; y = getHeight() - playerSize;
} }
x += velX + veldX; x += velX + veldX;
y += velY + veldY; y += velY + veldY;
repaint(); repaint();
......
...@@ -7,46 +7,49 @@ public class ReadFile { ...@@ -7,46 +7,49 @@ public class ReadFile {
String[] map = new String[16]; String[] map = new String[16];
public void openFile(int mapN) { public void openFile(int mapN) {
if (mapN == 1) {
switch(mapN) {
case 1:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls1.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls1.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} else if (mapN == 2) { case 2:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls2.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls2.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} else if (mapN == 3) { case 3:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls3.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls3.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} else if (mapN == 4) { case 4:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls4.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls4.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} else if (mapN == 5) { case 5:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls5.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls5.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} else if (mapN == 6) { case 6:
try { try {
scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls6.txt")); scanner = new Scanner(getClass().getClassLoader().getResourceAsStream("walls6.txt"));
} catch (Exception e) { } catch (Exception e) {
System.out.println("could not find File"); System.out.println("could not find File");}
} break;
} }
} }
public String getTile(int x, int y) { public String getBlock(int x, int y) {
String index = map[y].substring(x, x + 1); String index = map[y].substring(x, x + 1);
return index; return index;
} }
......
...@@ -17,10 +17,10 @@ public class Walls { ...@@ -17,10 +17,10 @@ public class Walls {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
if (r.getTile(x, y).equals("w")) { if (r.getBlock(x, y).equals("w")) {
walls[y][x] = 1; walls[y][x] = 1;
} }
if (r.getTile(x, y).equals("g")) { if (r.getBlock(x, y).equals("g")) {
walls[y][x] = 0; walls[y][x] = 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment