hi friends,i want to make a simple chess game and i want to know that how can i show the ways for example king can go in the form? i want to use an icon to show the ways king can go but i dont know how should i do it.thanks
A:
I think your question is a bit vague, and how you should implement it depends on the structure of your code so far.
Since you're not covering a large amount of area (at most 8x8), you could simply add a method to your "King" class that checks the locations for each of the 8 directions to make sure it doesn't touch the edge of the board or another piece. Each square that's available should be saved to a set of coordinates for you to display your icon. (Note: You also would need to check to make sure your potential positions are not causing an illegal move such as a self-check/checkmate)
Hope this helps, if you provide further details, we could probably provide additional assistance.
Jing
2010-10-30 08:54:36
I always thought that kings are only able to move one step?!
JustSid
2010-10-30 08:58:02
@JustSid In plain old boring chess, maybe. Not in SuperChess 2000!
bzlm
2010-10-30 09:00:51
excuse me for my vague question,i mean that how should i paste this icon in king class?and king move just one step
arash
2010-10-30 09:01:54
@JustSid oops =]
Jing
2010-10-30 09:08:44