Examples of SetBoard


Examples of com.barrybecker4.game.multiplayer.set.SetBoard

    /**
     * @return  the card that the mouse is currently over (at x, y coordinates)
     */
    public Card findCardOver(IBoard board, int x, int y, int panelWidth, int panelHeight) {
        SetBoard b = (SetBoard)board;

        int numCards = b.getNumCardsShowing();
        int numCols = getNumColumns(panelWidth, panelHeight, numCards);

        Dimension cardDim = calcCardDimension(numCols, panelWidth);
        int cardWidth = (int) cardDim.getWidth();
        int cardHeight = (int) cardDim.getHeight();

        int selectedIndex = -1;
        for (int i = 0; i<numCards; i++ ) {
            int row = i / numCols;
            int col = i % numCols;
            int colPos = col * cardWidth + CardRenderer.LEFT_MARGIN;
            int rowPos = row * cardHeight + CardRenderer.TOP_MARGIN;
            if (   x > colPos && x <= colPos + cardDim.getWidth()
                && y > rowPos && y <= rowPos + cardDim.getHeight()) {
                selectedIndex = i;
                break;
            }
        }
        if (selectedIndex == -1) {
            return null;
        }
        return b.getDeck().get(selectedIndex);
    }
View Full Code Here

Examples of com.barrybecker4.game.multiplayer.set.SetBoard

     */
    @Override
    public void render( Graphics g, Player currentPlayer, PlayerList players,
                        IBoard board, int panelWidth, int panelHeight ) {

        SetBoard b = (SetBoard) board;
        int numCards = b.getNumCardsShowing();

        g.clearRect( 0, 0, panelWidth, panelHeight );
        g.setColor( getBackground() );
        g.fillRect( 0, 0, panelWidth, panelHeight );

        int numCols = getNumColumns(panelWidth, panelHeight, numCards);

        Dimension cardDim = calcCardDimension(numCols, panelWidth);
        int cardWidth = (int) cardDim.getWidth();
        int cardHeight = (int) cardDim.getHeight();

        for (int i = 0; i < numCards; i++ ) {
            int row = i / numCols;
            int col = i % numCols;
            int colPos = col * cardWidth + CardRenderer.LEFT_MARGIN;
            int rowPos = row * cardHeight + CardRenderer.TOP_MARGIN;
            CardRenderer.render((Graphics2D) g, b.getDeck().get(i),
                                new Point2D.Float(colPos, rowPos), cardWidth, cardHeight, false);
        }
    }
View Full Code Here

Examples of com.barrybecker4.game.multiplayer.set.SetBoard

     * This method called whenever something on the board has changed.
     */
    @Override
    public void update(GameController controller) {

        SetBoard b = (SetBoard) controller.getBoard();
        numSetsOnBoardLabel_.setText( b.getNumSetsOnBoard() + " " );

        int cardsInDeck = b.getDeck().size() - b.getNumCardsShowing();
        numCardsRemainingLabel_.setText( cardsInDeck + " " );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.