コード例 #1
0
ファイル: Player.java プロジェクト: propra13-orga/gruppe72
  /**
   * Creates an instace of the player from an actorDescription.
   *
   * @param game instance of the game running
   * @param desc the ActorDescription
   * @param position the position in screenspace
   * @param controllerActive indicates if the player should be controlled by the keyboard
   * @param actID the actorID to be given. This is only done in network-games
   */
  public Player(
      Game game, ActorDescription desc, Vector2 position, boolean controllerActive, int actID) {
    super(game, desc, position);

    this.actorID = actID;

    this.state = DynamicObjectState.Idle;
    this.velocity = new Vector2(0, 0);
    this.game = game;

    controller = game.getController();
    statsMenu = new StatsMenu(stats, controller, this);
    statusbar = new StatusBar(this, game);
    inventory.setGold(25);

    // TEST
    spellManager = new SpellManager(this);
    spellManager.addShields();

    initAnimations();

    // DEBUG
    skillTree = new SkillTree(this, controller, collision);
    buildSpell();
    this.controllerActive = controllerActive;
    controlled = controllerActive;
    isInNetwork = game.isInNetwork();
    posState = new PositionState(this);
  }
コード例 #2
0
ファイル: MiniMax.java プロジェクト: QuinnMcHugh/Checkers
  public static List<Move> getJumps(Game game, Point start, List<Point> previousJumps) {
    List<Move> allJumps = new ArrayList<Move>();

    Point[] jumps = {new Point(-2, -2), new Point(2, -2), new Point(2, 2), new Point(-2, 2)};
    for (int i = 0; i < jumps.length; i++) {
      Move move = new Move();
      move.turnColor = game.getTurn();
      move.startPoint = start;
      move.jumps = new ArrayList<Point>();
      move.jumps.addAll(previousJumps);

      Point lastSpot;
      if (previousJumps.size() == 0) {
        lastSpot = start;
      } else {
        lastSpot = previousJumps.get(previousJumps.size() - 1);
      }

      move.jumps.add(new Point(lastSpot.x + jumps[i].x, lastSpot.y + jumps[i].y));

      if (game.canMakeMove(move.getCopy())) {
        allJumps.add(move.getCopy());

        // Add the latest spot to jump to
        previousJumps.add(new Point(start.x + jumps[i].x, start.y + jumps[i].y));
        List<Move> furtherJumps = getJumps(game, start, previousJumps);
        // remove the latest spot to jump to
        previousJumps.remove(previousJumps.size() - 1);

        allJumps.addAll(furtherJumps);
      }
    }

    return allJumps;
  }
コード例 #3
0
  public GUILogi5Board(Game game) {

    this.game = game;
    dim = game.getDimensions()[0];

    setLayout(new GridLayout(dim, dim));
    spaces = new JButton[dim][dim];

    for (int i = 0; i < spaces.length; i++) {
      for (int j = 0; j < spaces[i].length; j++) {

        Space otherSpace = game.getSpaceAt(i, j);

        GUILogi5Space spacey = new GUILogi5Space(i, j, spaceSize);
        int[] loc = spacey.getDims();
        spacey.setSpace(game.getSpaceAt(loc[0], loc[1]));
        spaces[i][j] = spacey;
        add(spacey);
      }
    }
    setBorder(BorderFactory.createLineBorder(Color.black));
    setPreferredSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length));
    setMaximumSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length));

    int num = 255;
    Color[] colors = new Color[6];
    for (int i = 0; i < colors.length; i++) {
      colors[i] = new Color(num, num, num, 220);
      num -= 30;
    }

    possibleColors = colors;
  }
コード例 #4
0
ファイル: BoardPanel.java プロジェクト: Toshu/RoBoardGames
 public BoardPanel(
     final JFrame frame,
     Game game,
     UnitTypeConfiguration unitTypeConfiguration,
     TileTypeConfiguration tileTypeConfiguration,
     TileStateConfiguration tileStateConfiguration,
     ChessMovementStrategy movementStrategy,
     UnitSelectorMode unitSelectorMode,
     BattleStrategyConfiguration battleStrategyConfiguration) {
   this.frame = frame;
   this.battleStrategyConfiguration = battleStrategyConfiguration;
   thisPanel = this;
   this.game = game;
   game.addGameObserver(this);
   this.board = game.getBoard();
   this.movementStrategy = movementStrategy;
   int rows = board.getDimension().getHeight();
   int columns = board.getDimension().getWidth();
   setLayout(new GridLayout(rows, columns));
   for (Tile tile : board.getTiles()) {
     final TilePanel tilePanel =
         new TilePanel(tileTypeConfiguration, unitTypeConfiguration, tileStateConfiguration, tile);
     if (UnitSelectorMode.MULTIPLE.equals(unitSelectorMode)) {
       tilePanel.addMouseListener(
           new MultipleUnitSelectorMouseListener(tilePanel, frame, thisPanel));
     }
     if (UnitSelectorMode.SINGLE.equals(unitSelectorMode)) {
       tilePanel.addMouseListener(
           new SingleUnitSelectorMouseListener(tilePanel, frame, thisPanel));
     }
     map.put(tile, tilePanel);
     add(tilePanel);
   }
   resetPositions();
 }
コード例 #5
0
ファイル: DesktopLauncher.java プロジェクト: celentanos/games
 public static void main(String[] args) {
   int screenWidth = WORLD_WIDTH * CELL_SIZE;
   int screenHeight = WORLD_HEIGHT * CELL_SIZE;
   Dimension screenSize = new Dimension(screenWidth, screenHeight);
   Game game = DesktopGameBuilder.build(screenSize);
   game.setScene(new SceneStart(game));
   game.start();
 }
コード例 #6
0
 private void paintMenu(Graphics2D g2d) {
   if (showMenu == true) {
     if (c.getPoints() > c.getHighscore().getLowestPointsInTable() && c.getLifes() == 0) {
       menu.setState(4);
     }
     menu.draw(g2d);
   }
 }
コード例 #7
0
ファイル: MiniMax.java プロジェクト: QuinnMcHugh/Checkers
  public static int evaluate(Game game, char player) {
    if (game.isGameOver()) {
      for (int i = 0; i < Board.ROWS; i++) {
        for (int j = 0; j < Board.COLUMNS; j++) {
          if (game.getBoard().matrix[i][j] != Board.EMPTY) {
            int piece = game.getBoard().matrix[i][j];
            if (piece == Board.BLACK_SOLDIER || piece == Board.BLACK_KING) {
              if (player == Move.BLACK) {
                return 100;
              } else {
                return -100;
              }
            } else if (piece == Board.RED_SOLDIER || piece == Board.RED_KING) {
              if (player == Move.RED) {
                return 100;
              } else {
                return -100;
              }
            }
          }
        }
      }
    } else {
      int numBlackKings = 0, numRedKings = 0;
      int numBlackPieces = 0, numRedPieces = 0;

      for (int i = 0; i < Board.ROWS; i++) {
        for (int j = 0; j < Board.COLUMNS; j++) {
          int piece = game.getBoard().matrix[i][j];
          if (piece != Board.EMPTY) {
            if (piece == Board.BLACK_KING) {
              numBlackKings++;
              numBlackPieces++;
            } else if (piece == Board.RED_KING) {
              numRedKings++;
              numRedPieces++;
            } else if (piece == Board.BLACK_SOLDIER) {
              numBlackPieces++;
            } else if (piece == Board.RED_SOLDIER) {
              numRedPieces++;
            }
          }
        }
      }

      int score = 0;
      score += 6 * (numBlackPieces - numRedPieces);
      score += (28f / 12f) * (numBlackKings - numRedKings);

      if (player == Move.RED) {
        score *= -1;
      }

      return score;
    }
    return 0;
  }
コード例 #8
0
ファイル: Player.java プロジェクト: propra13-orga/gruppe72
 @Override
 public void terminate() {
   if (!isInNetwork) {
     System.out.println("Player is dead!");
     state = DynamicObjectState.Terminated;
     game.playerDead();
   } else {
     game.playerDeadInNetwork(actorID);
   }
 }
コード例 #9
0
ファイル: Game.java プロジェクト: Genki91/collapsing-puzzle
  /* Create and show the graphical user interface. */
  private static void createAndShowGUI() {
    JFrame frame = new JFrame("My Collapsing Puzzle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Game game = new Game();
    frame.setJMenuBar(game.createMenuBar());
    frame.setContentPane(game.createContentPane());
    frame.setSize(game.getGameSize());

    frame.setVisible(true);
  }
コード例 #10
0
ファイル: MapDisplay.java プロジェクト: jufey/AoA
  public MapDisplay(
      String level, String picpath, String shadowpath, int col, int row, GamePanel p) {
    tiles = new Vector<Tile>();

    parent = (Game) p;

    loadLevelData(level);

    control = ImageControl.getInstance();
    control.setSourceImage(picpath, col, row);
    control.setShadowImage(shadowpath, col, row);
    display = new Rectangle2D.Double(0, 0, parent.getWidth(), parent.getHeight());
  }
コード例 #11
0
ファイル: Robots.java プロジェクト: yuan51/CS180
  public void play(int lv) {
    jl.setText("Level " + level);
    Game game = new Game(lv); // An object representing the game
    View view = new View(game); // An object representing the view of the game
    game.newGame();
    view.print();
    gameBoardPanel = view.mainPanel;
    ButtonPanel buttonPanel = new ButtonPanel(game);
    container.add(buttonPanel, BorderLayout.EAST);
    container.add(gameBoardPanel, BorderLayout.WEST);
    mainFrame.pack();

    // Main game loop
    while (true) {

      view.print();
      gameBoardPanel = view.mainPanel;

      // Win/lose conditions
      if (game.isWin()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice = JOptionPane.showConfirmDialog(null, "You win!", "", JOptionPane.OK_OPTION);
        if (choice == JOptionPane.OK_OPTION) {
          level++;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        }
      }
      if (game.isLose()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice =
            JOptionPane.showConfirmDialog(
                null, "You lose!", "Would you like to play again?", JOptionPane.YES_NO_OPTION);
        if (choice == JOptionPane.YES_OPTION) {
          level = 1;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        } else {
          System.exit(0);
        }
      }
    }
  }
コード例 #12
0
ファイル: Game.java プロジェクト: cpetosky/o2d-lib
 // --------------------------------createAndShowGUI-----------------------------
 public static void createAndShowGUI() {
   Game thisGame = new Game();
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   JFrame.setDefaultLookAndFeelDecorated(true);
   thisGame.frame = new JFrame("Tactics");
   thisGame.oConn = new SocketManager();
   thisGame.scrBounds = thisGame.frame.getGraphicsConfiguration().getBounds();
   thisGame.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
   thisGame.frame.setDefaultLookAndFeelDecorated(true);
   thisGame.frame.addWindowListener(thisGame);
   thisGame.frame.setVisible(true);
 }
コード例 #13
0
  public void setUpGroups() {

    this.groups = game.getGroups();
    Color[] groupToColor = new Color[groups.length];
    for (int i = 0; i < groupToColor.length; i++) {
      groupToColor[i] = possibleColors[i % possibleColors.length];
    }

    for (int i = 0; i < groupToColor.length; i++) {
      Group[] conflictingGroups;
      conflictingGroups = conflicting(i, groupToColor);

      int noOfTimes = 0;

      while (conflictingGroups.length != 0) {
        int offset;
        if (noOfTimes > 5) offset = 3;
        else offset = 2;

        groupToColor[conflictingGroups[0].groupIDX] =
            possibleColors[(conflictingGroups[0].groupIDX + offset) % possibleColors.length];
        conflictingGroups = conflicting(i, groupToColor);
        noOfTimes++;
      }
    }

    for (int i = 0; i < groups.length; i++) {
      Space[] groupSpaces = groups[i].getSpaces();
      for (int j = 0; j < groupSpaces.length; j++) {
        Space current = groupSpaces[j];
        GUILogi5Space currentSpace = (GUILogi5Space) (spaces[current.getX()][current.getY()]);
        currentSpace.setColor(groupToColor[i]);
      }
    }
  }
コード例 #14
0
ファイル: StartMenu.java プロジェクト: klmDF14J/DuskFire
  public boolean action(Event evt, Object arg) {
    if (evt.target instanceof Button) {
      String selectedButton = arg.toString();
      if (selectedButton == "Play") {
        String x[] = {"A", "B"};
        Game.main(x);
      }
      if (selectedButton == "Map Editor") {
        String x[] = {"A", "B"};
        MapEditor.main(x);
      }
      if (selectedButton == "Exit DuskFire") {
        System.out.println("Exiting Game");
        if (JOptionPane.showConfirmDialog(
                null,
                "Are you sure you want to exit DuskFire",
                "Exiting DuskFire",
                JOptionPane.YES_NO_OPTION)
            == 0) {
          dispose();
        }
      }
    }

    return true;
  }
コード例 #15
0
ファイル: Game.java プロジェクト: klongtran/comp124Hw
  public static void main(String[] args) {
    Game game = new Game();
    game.setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
    game.setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
    game.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

    JFrame frame = new JFrame("Tiles.Tile RPG");
    frame.setSize(WIDTH * SCALE, HEIGHT * SCALE);

    /** Important line to prevent memory leak! */
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.add(game);
    frame.setVisible(true);

    game.start();
  }
コード例 #16
0
ファイル: Racquet.java プロジェクト: KamilBest/PongGame
 public void moveCpuRacquet() {
   if (racquetPositionX > game.ball.ballCoordinatesX && racquetPositionX >= 0) {
     racquetPositionX -= cpuRacquetSpeed;
   } else if (racquetPositionX < game.ball.ballCoordinatesX
       && racquetPositionX + RACQUETS_WIDTH <= game.getWidth()) {
     racquetPositionX += cpuRacquetSpeed;
   }
 }
コード例 #17
0
ファイル: BoardPanel.java プロジェクト: Toshu/RoBoardGames
 private void repaintPanels(Iterable<TilePanel> panels) {
   long start = System.currentTimeMillis();
   for (TilePanel panel : panels) {
     game.notifyGameObservers(panel.getTile().getPosition());
   }
   long stop = System.currentTimeMillis();
   Logger.getLogger(BoardPanel.class).debug("Repaint time: " + (stop - start) / 1000.0);
 }
コード例 #18
0
  public static void main(String[] args) {
    try {
      if (args.length != 2) {
        System.err.println("USAGE: java RenderMap map.txt image.png");
        System.exit(1);
      }
      Game game = new Game(args[0], 100, 0);
      if (game.Init() == 0) {
        System.err.println("Error while loading map " + args[0]);
        System.exit(1);
      }

      ArrayList<Color> colors = new ArrayList<Color>();
      colors.add(new Color(106, 74, 60));
      colors.add(new Color(74, 166, 60));
      colors.add(new Color(204, 51, 63));
      colors.add(new Color(235, 104, 65));
      colors.add(new Color(237, 201, 81));
      Color bgColor = new Color(188, 189, 172);
      Color textColor = Color.BLACK;
      Font planetFont = new Font("Sans Serif", Font.BOLD, 11);
      Font fleetFont = new Font("Sans serif", Font.PLAIN, 7);

      GraphicsConfiguration gc =
          GraphicsEnvironment.getLocalGraphicsEnvironment()
              .getDefaultScreenDevice()
              .getDefaultConfiguration();

      BufferedImage image = gc.createCompatibleImage(640, 480);

      Graphics2D _g = (Graphics2D) image.createGraphics();

      // Turn on AA/Speed
      _g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      _g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
      _g.setRenderingHint(
          RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

      game.Render(640, 480, 0.0, null, colors, bgColor, textColor, planetFont, fleetFont, _g);

      File file = new File(args[1]);
      ImageIO.write(image, "png", file);
    } catch (Exception e) {
      System.err.println(e);
    }
  }
コード例 #19
0
ファイル: Game.java プロジェクト: redomar/JavaGame
 public void setMap(String Map_str) {
   setLevel(new LevelHandler(Map_str));
   if (alternateCols[0]) {
     Game.setShirtCol(240);
   }
   if (!alternateCols[0]) {
     Game.setShirtCol(111);
   }
   if (alternateCols[1]) {
     Game.setFaceCol(310);
   }
   if (!alternateCols[1]) {
     Game.setFaceCol(543);
   }
   setPlayer(new Player(level, 100, 100, input, getJdata_UserName(), shirtCol, faceCol));
   level.addEntity(player);
 }
コード例 #20
0
  /**
   * Create a new board
   *
   * @param c
   */
  public Board(Game c) {
    // add leap motion controller
    leapAdapter = new SensorAdapter(c);
    sensorListener = new SensorListener(leapAdapter);
    shootListener = new ShootListener(leapAdapter);
    leapController = new Controller();
    leapController.addListener(sensorListener);
    leapController.addListener(shootListener);

    addKeyListener(new KeyboardAdapter(c, this));

    this.menu = new Menu(this, c);
    setFocusable(true);
    setDoubleBuffered(true);
    this.c = c;
    c.setPlayer(ItemFactory.createPlayer());
    c.setBackground(ItemFactory.createBackground());
  }
コード例 #21
0
 private void paintItems(Graphics2D g2d) {
   for (Item item : c.getAllStuff()) {
     if (item != null) {
       if (item.flicker()) {
         g2d.drawImage(
             item.getImage(), item.getPosition().getX(), item.getPosition().getY(), this);
       }
     }
   }
 }
コード例 #22
0
  public static void main(final String[] args) {

    game = new Game();
    game.frame.add(game);
    game.frame.setResizable(false);
    game.frame.setTitle(Game.title);
    game.frame.pack();
    game.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    game.frame.setLocationRelativeTo(null);
    game.frame.setVisible(true);
    game.start();
  }
コード例 #23
0
 @Override
 public void mouseClicked(MouseEvent event) {
   Object obj = event.getSource();
   if (obj instanceof JButton) {
     JButton clickedButton = (JButton) obj;
     if (clickedButton.equals(one)) {
       this.clearPanel();
       Game next = new Game(this.frame, 1, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(two)) {
       this.clearPanel();
       Game next = new Game(this.frame, 2, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(three)) {
       this.clearPanel();
       Game next = new Game(this.frame, 3, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(four)) {
       this.clearPanel();
       Game next = new Game(this.frame, 4, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(back)) {
       this.clearPanel();
       HomePanel next = new HomePanel(this.frame, bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
   }
 }
コード例 #24
0
ファイル: MiniMax.java プロジェクト: QuinnMcHugh/Checkers
  public static int MiniMax(Game game, char player, int depth, int maxDepth) {
    if (depth == maxDepth || game.isGameOver()) {
      return evaluate(game, player);
    }

    Move bestMove = null;
    int bestScore;
    if (game.getTurn() == player) {
      bestScore = Integer.MIN_VALUE;
    } else {
      bestScore = Integer.MAX_VALUE;
    }

    List<Move> allMoves = getMoves(game, game.getTurn());
    for (Move move : allMoves) {
      int[][] matrixCopy = game.getBoard().getMatrixCopy();

      game.processMove(move.getCopy());
      game.changeTurn();
      int moveScore = MiniMax(game, player, depth + 1, maxDepth);

      game.changeTurn();
      game.getBoard().setMatrix(matrixCopy);

      if (game.getTurn() == player) {
        if (moveScore > bestScore) {
          bestScore = moveScore;
          bestMove = move.getCopy();
        }
      } else {
        if (moveScore < bestScore) {
          bestScore = moveScore;
          bestMove = move.getCopy();
        }
      }
    }

    if (depth == 0) {
      computedBestMove = bestMove;
    }

    return bestScore;
  }
コード例 #25
0
ファイル: MiniMax.java プロジェクト: QuinnMcHugh/Checkers
  public static List<Move> getMovesForPiece(Game game, Point piece) {
    List<Move> moves = new ArrayList<Move>();

    int[] deltaX = {-1, 1, 1, -1};
    int[] deltaY = {-1, -1, 1, 1};

    for (int i = 0; i < deltaX.length; i++) {
      Move move = new Move();
      move.startPoint = piece;
      move.turnColor = game.getTurn();
      move.jumps = new ArrayList<Point>();
      move.jumps.add(new Point(piece.x + deltaX[i], piece.y + deltaY[i]));

      if (game.canMakeMove(move.getCopy())) {
        moves.add(move.getCopy());
      }
    }

    List<Move> jumps = getJumps(game, piece, new ArrayList<Point>());
    moves.addAll(jumps);

    return moves;
  }
コード例 #26
0
 private void paintLifes(Graphics2D g2d) {
   int lifes = c.getLifes();
   for (int i = 0; i < lifes; i++) {
     ImageIcon imageIcon =
         new ImageIcon(
             ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife()));
     Life life =
         ItemFactory.createLife(
             Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(),
             0,
             imageIcon);
     g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this);
   }
 }
コード例 #27
0
ファイル: Game.java プロジェクト: redomar/JavaGame
  public void run() {
    long lastTime = System.nanoTime();
    double nsPerTick = 1000000000D / 60D;

    int ticks = 0;
    int frames = 0;

    long lastTimer = System.currentTimeMillis();
    double delta = 0;

    init();

    while (Game.isRunning()) {
      long now = System.nanoTime();
      delta += (now - lastTime) / nsPerTick;
      lastTime = now;
      boolean shouldRender = false;

      while (delta >= 1) {
        ticks++;
        tick();
        delta -= 1;
        shouldRender = true;
      }

      try {
        Thread.sleep(2);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      if (shouldRender) {
        frames++;
        render();
      }

      if (System.currentTimeMillis() - lastTimer >= 1000) {
        lastTimer += 1000;
        getFrame()
            .setTitle(
                "JavaGame - Version "
                    + WordUtils.capitalize(game_Version).substring(1, game_Version.length()));
        fps = frames;
        tps = ticks;
        frames = 0;
        ticks = 0;
      }
    }
  }
コード例 #28
0
  /**
   * Request that this alien moved based on time elapsed
   *
   * @param delta The time that has elapsed since last move
   */
  public void move(long delta) {
    // if we have reached the left hand side of the screen and
    // are moving left then request a logic update
    //		if ((dx < 0) && (x < 10)) {
    //			game.updateLogic();
    //		}
    //		// and vice vesa, if we have reached the right hand side of
    //		// the screen and are moving right, request a logic update
    //		if ((dx > 0) && (x > 750)) {
    //			game.updateLogic();
    //		}
    game.updateLogic();

    // proceed with normal move
    super.move(delta);
  }
コード例 #29
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);

    // menu on game over
    if (c.getLifes() < 1) {
      showMenu = true;
    }

    this.paintBackground((Graphics2D) g);
    this.paintItems((Graphics2D) g);
    this.paintLifes((Graphics2D) g);
    this.paintScore((Graphics2D) g);
    this.paintMenu((Graphics2D) g);

    Toolkit.getDefaultToolkit().sync();
    g.dispose();
  }
コード例 #30
0
ファイル: MiniMax.java プロジェクト: QuinnMcHugh/Checkers
  public static List<Move> getMoves(Game game, char player) {
    List<Move> moves = new ArrayList<Move>();

    for (int row = 0; row < Board.ROWS; row++) {
      for (int col = 0; col < Board.COLUMNS; col++) {
        int pieceColor = game.getBoard().matrix[row][col];
        if (player == Move.RED) {
          if (pieceColor == Board.RED_KING || pieceColor == Board.RED_SOLDIER) {
            List<Move> pieceMoves = getMovesForPiece(game, new Point(col, row));
            moves.addAll(pieceMoves);
          }
        } else if (player == Move.BLACK) {
          if (pieceColor == Board.BLACK_KING || pieceColor == Board.BLACK_SOLDIER) {
            List<Move> pieceMoves = getMovesForPiece(game, new Point(col, row));
            moves.addAll(pieceMoves);
          }
        }
      }
    }

    return moves;
  }