I have made progress on my own, but thought i'd share my results and ask questions in this thread as I go. Somebody might suggest something that'll save me hours of work.... if not i'll just carry on
So... you can now click on any of the pieces and click on another square to move them.
I haven't set limits on the movements yet. That'll be one of my next challenges.
I'm thinking I should build an array that contains all the legal moves for each type of piece. I have 6 types, determined by their animation frame number. Black pieces are frame 0 through 5, the White pieces are frames 6 through 11.
I was thinking of an array something like:
legalMoves
frame (type) maximum moves directions
0 (pawn) 1 y-
1 (castle) 7 x,y,x-,y-
2 (knight) 3 x,y,x-,y-
3 (bishop) 7 x+y,-x+y,x+-y,-x+-y
4 (queen) 7 x,y,x-,y-,x+y,-x+y,x+-y,-x+-y
5 (king) 1 x,y,x-,y-,x+y,-x+y,x+-y,-x+-y
6 (pawn) 1 y
7 (castle) 7 x,y,x-,y-
8 (knight) 3 x,y,x-,y-
9 (bishop) 7 x+y,-x+y,x+-y,-x+-y
10 (queen) 7 x,y,x-,y-,x+y,-x+y,x+-y,-x+-y
11 (king) 1 x,y,x-,y-,x+y,-x+y,x+-y,-x+-y
Of course this doesnt take into account en passant, castling, knights move 1+2 etc. but I was going to build those individually... unless somebody has a better suggestion?
I'd also like to build an array whilst I build my board following standard a-h, 1-8 grid so that i can eventually import/export PGN files. I've tried building an array, but when searching it - all the values are 0, so suggestions on how to quickly populate a grid a-h/1-8 with the UIDs of the tiles as I build the board would be very helpful.
Any offers of help to build these arrays, or even improve the events I have already made would be greatly appreciated.
Latest version of the capx included.
Thanks guys