Hey udviklere.
Er ret ny til java og følger lidt en ufærdig tutorial men ville høre om der var forskel på en om boolean står med stort forbogstav eller ej? "boolean" "Boolean"
I eclipse ændrer den farve, og har et problem med et loop den skal lave, så har en tiltro det måske var det der var galt.
game.java
- public Boolean makeGameMove() {
- int [][] fieldData = parseField();
- try {
- Move move = moveFinder.findBestMove(fieldData);
-
- int[][] moveCoordinates = move.getMoveCoordinates();
- moveCoordinates[0][0] += fieldY;
- moveCoordinates[1][0] += fieldY;
- moveCoordinates[0][1] += fieldX;
- moveCoordinates[1][1] += fieldX;
-
- Point mousePoint = MouseInfo.getPointerInfo().getLocation();
-
- robot.mouseMove(moveCoordinates[0][1], moveCoordinates[0][0]);
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-
- robot.mouseMove(moveCoordinates[1][1], moveCoordinates[1][0]);
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-
- robot.mouseMove((int)mousePoint.getX(), (int)mousePoint.getY());
-
- } catch (NoMoveFoundException e) {
- return false;
- }
-
- return true;
- }
-
- public boolean isGameOver() {
- int[][] fieldData = parseField();
- for (int y=0;y<8;y++) {
- for (int x=0;x<8;x++) {
- if (fieldData[y][x] != Gem.NONE) return false;
-
- }
- }
- return true;
- }
-
- public void restartGame() {
- Point mousePoint = MouseInfo.getPointerInfo().getLocation();
-
- robot.mouseMove(rootX+startButtonDistanceFromRootX, rootY+startButtonDistanceFromRootY);
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-
- robot.mouseMove((int)mousePoint.getX(), (int)mousePoint.getY());
- }
- }
og min restart function
- public void actionPerformed(ActionEvent e) {
- imagePanel.image = game.getField(true);
- imagePanel.repaint();
- while (!game.isGameOver()) {
- while (game.makeGameMove());
- }
- game.restartGame();
- System.out.println("Kunne ikke finde et move");
- }
- });
- playButton.setEnabled(false);
- playButton.setBounds(170, 11, 112, 23);
- frame.getContentPane().add(playButton);
- }
- }