Jump to content

Recommended Posts

Posted

I am trying to move an object from 1 location in a 2D array to another, but I seem to be referencing the object itself and making it equal to another :S

This a code snippet of what I've been doing, any pointers would be appreciated

ChessPiece currentLocation = objBoard.board[curX][curY];    //current coordinates of piece
ChessPiece destination = objBoard.board[desX][desY];    //intended destination

if((desX == curX) && (desY == (curY + 1)))
    {
      destination = currentLocation;    //copy contents of current location to destination square
      currentLocation = null;    //remove contents of the old location to complete the piece move
    }

Thanks :)

Posted
You aren't moving the chess piece to any where, you are taking it off the board.

yeah thanks, I worked it out after posting that :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...