0
\$\begingroup\$

I'm attempting to create a chess game, for the movement I need to be able to click on a piece with the mouse, and then the square I'd like to move it to. Each piece on the board is a sprite, and I'm struggling to find a way to select a sprite in order to then move it, what would be the best way to do this? I'm programming in c# with XNA framework btw. Thanks in advance :)

\$\endgroup\$
1

1 Answer 1

0
\$\begingroup\$

I think the best way would be to make a rectangle for the position and hitbox of each of your chess pieces. After that make a rectangle for the mouse pointer, and use the Rectangle.Intersects method to check if your mouse hitbox intersects with one of the pieces hitboxes, and of course do your logic there.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .