Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExerciseFour;
- import java.awt.*;
- import java.io.FileNotFoundException;
- import javax.swing.*;
- class Board extends JPanel {
- Boolean[][] maze = getMaze();
- int row = maze.length;
- private Ball b = new Ball();
- public Boolean[][] getMaze() throws FileNotFoundException {
- Boolean[][] maze = Exercise4.getMaze();
- return maze;
- }
- public Board() throws FileNotFoundException {
- add(b);
- }
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- for (int y = 0; y < row; y++) {
- for (int x = 0; x < row; x++) {
- if (maze[y][x].equals(false)) {
- g.setColor(Color.BLACK);
- g.fillRect(x * 25, y * 25, 120, 120);
- } else {
- g.setColor(Color.WHITE);
- g.fillRect(x * 25, y * 25, 120, 120);
- }
- }
- }
- g.setColor(Color.RED);
- g.fillOval((row - 1) * 24 - 5, (row - 1) * 24 - 5, 20, 20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement