Page 1 of 2 12 LastLast
Results 1 to 20 of 31
  1. #1
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default I really need your help with my Chess game @school

    Hi there, I am new here, thanks for the welcome

    I have a project at school where I am programming a chess game. I have come really far and I am really close at getting a top grade, but now I need your help...
    The only thing I need for getting a top grade is a highlight of where the piece(for example pawn) can move.. Like in this example the pawn can move two forward at start.
    The main point is that it follows patterns and is OOP(object oriainted).


    I am attaching my project here, and I really hope you can help!
    Attached Files Attached Files

  2. #2
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    By the way, the teacher gave me a note,I am adding this one tooI really need your help with my Chess game @school-20111213_173115.jpg

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    Do you have any specific questions about your code? If so post them and the code.

  4. #4
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Ye the specific question is to get a function that looks like this: I really need your help with my Chess game @school-chess.png

    The fields that the "piece" can be moved onto shuld be highlighted

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    fields that the "piece" can be moved onto shuld be highlighted
    Which part of that is a problem?
    Detecting the squares the piece can move to?
    highlighting the the detected squares.

  6. #6
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I am sorry, but I just aint that good in programming(thats why I am going to school).

    My problem is how I should do it..I have thinked out that when I click on a piece, it arms the piece, I have created a static field so there can only be one armed piece at a time..

    I guess I should put a method in there(on the mouseclick) that allso highlights the squares, but how does the method work

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    how I should do it.
    When you have detected the squares that are valid moves,
    You need to set some flags for the painting method to use so it knows which squares to hi-light.

  8. #8
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I am sorry, but I really didnt understand that. The squares that are valid move can for example be row+1, because it is the upper row?

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    There are 63 squares that a piece could potentially move to. How do you tell one square from another?
    Are they numbered from 1 to 64 or do you use row and column or ???

    When you detect which squares are valid squares to be moved to, how do you record/remember those squares?

    When you have the list of squares, you could save that list somewhere so the painting method could use that list to hi-light those squares when it draws the board.

  10. #10
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I use ROW and COL. I use a INT for setting out 64 squares. the INT stops at the number 64(63 cause 0 is 1).

    I have not yet made any "valid squares" the only thing I want is to highlight "valid squares", just for one piece, for example for PAWN since there is so many pawns.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    If you do not have a list of the valid moves for the selected piece, you will have to start there.
    Given the square number(0-63) of the piece, you need to look at the surrounding squares and see which ones the piece can move to. Save the square numbers that can be moved to in a list.
    For debugging just print out the list of valid moves (square numbers).
    When that works (your list has good square numbers in it), then you can work on having the printing methods use that list of valid moves to hi-light those squares.

  12. #12
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    So first I create a method that says what squares that are "valid"... In pawns sceneraio it is the row+1 or row -1, right?

    And after that I just use a method that HIGHLIGHTS row+1 on mouseclick?

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    I don't think you know how a pawn moves?
    The ones on the near side move towards the far side and the ones on the far side move towards the near side.
    Where is row number 1? Are the rows numbered from top to bottom or bottom to top?

  14. #14
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I meant a col, sorry..say COL 0 is the first one..the pawn can move from hes SAME row(like 1) but two col aheds...So he can move from 0,1 to 0,3 where the last number is col

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    Can you explain what your coding problem is now?

  16. #16
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Yeah, my coding problem is that I don't know how I locate the col's, after that my problem is how I tell the col's to be painted, but I think I got that one figured out.

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    I don't know how I locate the col's,
    How do you know which piece is to be moved? That piece's position would have the col it is in.

  18. #18
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    I have created a static field so there is ONLY one piece that can be "armed".. By arm I mean clicked on and ready for movement. So when you click a piece, that piece becomes the "armedpiece"

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: I really need your help with my Chess game @school

    Where is that piece's location stored?

  20. #20
    znerken is offline Member
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: I really need your help with my Chess game @school

    Then you have to use the parent, the square,then we have to ask the square where it is located on the board?

Page 1 of 2 12 LastLast

Similar Threads

  1. chess game! plz help!
    By mofaghih in forum AWT / Swing
    Replies: 2
    Last Post: 07-11-2011, 07:46 AM
  2. Chess Game - Movement
    By danborgir in forum Advanced Java
    Replies: 1
    Last Post: 03-14-2011, 11:45 AM
  3. chess game
    By michail in forum New To Java
    Replies: 13
    Last Post: 01-12-2010, 07:24 AM
  4. Chess game
    By michail in forum New To Java
    Replies: 4
    Last Post: 12-23-2009, 06:51 PM
  5. New Chess-Like game
    By jSarK0Y in forum Reviews / Advertising
    Replies: 3
    Last Post: 06-10-2009, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •