Example #1
0
  void drawMazeMan(boolean open) {
    Graphics g = parent.getGraphics();
    g.setColor(Color.yellow);

    if (open) g.fillArc(x, y, width, height, startangle, 270);
    else {
      g.fillOval(x, y, width, height);
      g.setColor(Color.black);
      switch (direction) {
        case 1:
          g.drawLine(x + 9, y + 9, x + 18, y + 9);
          break;
        case 2:
          g.drawLine(x + 9, y + 9, x + 9, y + 18);
          break;
        case 3:
          g.drawLine(x + 9, y + 9, x, y + 9);
          break;
        case 4:
          g.drawLine(x + 9, y + 9, x + 9, y);
          break;
      }
    }
    g.setColor(Color.black);
    g.fillOval(x + eyeX, y + eyeY, 3, 3);

    if ((parent.focussed) & (!parent.reportscore)) {
      g.setColor(new Color(0, 0, 0)); // change the bg color
      g.fillRect(0, 330, 400, 350);
      g.setColor(Color.yellow);
      parent.totaltime = (int) ((System.currentTimeMillis() - parent.starttime) / 1000);
      g.drawString("" + parent.totaltime + " seconds", 10, 360);
    }

    parent.done = true;
    for (parent.b = 0; parent.b < 20; parent.b++) {
      for (parent.a = 0; parent.a < 16; parent.a++) {
        if ((parent.matrix[parent.a][parent.b] == 2) | (parent.matrix[parent.a][parent.b] == 3))
          parent.done = false;
      }
    }
    if ((parent.done) & (!parent.reportscore)) {
      g.setColor(Color.yellow);

      // g.drawString("You complete the maze in " + parent.totaltime + " seconds.",10,380);
      parent.reportscore = true;
      InsertData s = new InsertData(g, parent.totaltime);
    }
  }
Example #2
0
  void drawMaze() {
    Graphics g = parent.getGraphics();
    for (int i = 0; i < 20; i++)
      for (int j = 0; j < 16; j++) {
        switch (parent.matrix[j][i]) {
          case -1:
            g.setColor(Color.gray);
            g.fillRect(i * 20, j * 20, 20, 20);
            break;
          case 1:
            g.setColor(Color.black);
            g.fillRect(i * 20, j * 20, 20, 20);
            break;
          case 0:
            g.setColor(Color.white);
            g.fillRect(i * 20, j * 20, 20, 20);
            break;
          case 2:
            g.setColor(Color.black);
            g.fillRect(i * 20, j * 20, 20, 20);
            g.setColor(Color.white);
            g.fillOval(i * 20 + 8, j * 20 + 8, 4, 4);
            break;
          case 3:
            g.setColor(Color.black);
            g.fillRect(i * 20, j * 20, 20, 20);
            g.setColor(Color.white);
            g.fillOval(i * 20 + 4, j * 20 + 4, 12, 12);
            break;
        }
      }

    g.setColor(Color.yellow); // change the bg color
    g.drawString("Click to activate", 10, 340);
    g.setColor(Color.red); // change the bg color
    g.drawString("Click to activate", 11, 341);
  }
Example #3
0
 void eraseMazeMan() {
   Graphics g = parent.getGraphics();
   g.setColor(Color.black);
   g.fillRect(x - 1, y - 1, width + 2, height + 2);
 }