Posted October 23, 2017 I have made a chess game for a two month college project, and it is virtually finished. It seems to be completely functional, except for one thing. In the game when you click a piece, that piece is highlighted, as are the squares it can move to. However, I am having the issue that while a piece is highlighted and your mouse moves into a king's square, and ONLY a king's square, the highlight is cancelled. I can live with it being there but its annoying and I'd rather not, yet try as I might I can't find the cause of it. If someone has time on their hands, and it WILL take a lot of time, I'd like some fresh eyes to look at my code to find the cause. Part of the problem is there is so much code I've forgotten even writing half of it. You'll have to try to learn the program yourself if you want to help because I honestly can't explain it. The applet can be run in eclipse Java-Oxygen in a new class called Chess Thank you! chess.txt Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted October 23, 2017 Can you upload it to Github? Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted October 23, 2017 Author The file is attached to the post, but yes I can. https://gist.github.com/jjohnn91/03a3ad86926fa8ff5222f4ed4ecd7e51 Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted October 23, 2017 When you hover over anything, it calls safeForKing, which at the bottom (at the else from a check for when the tile is not a king) calls refreshsp, refreshsp then calls normaliseColor, which resets all the colors. The code is quite a bit of a mess, so this was a tough one, I thank you for the challenge. Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted October 23, 2017 2 minutes ago, fuj1n said: When you hover over anything, it calls safeForKing, which at the bottom (at the else from a check for when the tile is not a king) calls refreshsp, refreshsp then calls normaliseColor, which resets all the colors. The code is quite a bit of a mess, so this was a tough one, I thank you for the challenge. Damn beat me to it. Yeah, maybe try implement more modular code to make it cleaner. Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted October 23, 2017 Author The reason my code uses so many methods is so that they can be called and used in a variety of scenarios, for example highlight doesn't just light squares, it also gets called within refreshsp and refreshkbp as an updater for 4 different booleans on each square. etc... Thank you both for your help, I should be able to stop it calling safeForKing in the wrong scenarios now. Can't believe I got my answer through the LTT forums Link to comment Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now