
-----------------------------------
william 01
Wed May 11, 2011 1:49 pm

Chess Game, need help with secondary click
-----------------------------------
As the subject states I'm making a chess game and need help with the secondary click. I'm not working on the code yet but, can some one post a template or somthing, so I know how to do it when i come to it.

-----------------------------------
Tony
Wed May 11, 2011 1:53 pm

RE:Chess Game, need help with secondary click
-----------------------------------
What do you mean by "secondary click", and what kind of help do you need with it?

-----------------------------------
william 01
Wed May 11, 2011 2:03 pm

Re: Chess Game, need help with secondary click
-----------------------------------
I mean the click for the square the peice is moving to, I have no idea how to code it, can any one help me with this?

-----------------------------------
william 01
Tue May 17, 2011 10:33 am

Re: Chess Game, need help with secondary click
-----------------------------------
does this mean that no one can help me?

-----------------------------------
Tony
Tue May 17, 2011 12:19 pm

RE:Chess Game, need help with secondary click
-----------------------------------
It's probably just a mix of a vagueness of the question and that very few people here use VB.

A question to you -- how is the second click different from the first click (selecting where the piece is moving from).

-----------------------------------
z_cross_fire
Wed May 18, 2011 3:11 am

RE:Chess Game, need help with secondary click
-----------------------------------
If I am getting your question right;

Try using a boolean? To check if it is the second or the first click...
An alternate way could be to use an integer, with odd/even denoting first/second click....

-----------------------------------
mirhagk
Wed May 18, 2011 4:43 pm

RE:Chess Game, need help with secondary click
-----------------------------------
Is it a 1 person or 2 person game?

Because a 1 person game is a HUGE challenge.

-----------------------------------
Zren
Wed May 18, 2011 6:16 pm

RE:Chess Game, need help with secondary click
-----------------------------------

% You need to take into affect that a player can miss click on an invalid cell,
% or even the fact the player selected an invalid to begin with.
% You shouldn't be calculating the state of the game by counting the clicks, but
% rather the previous state of the game (ie: your selection).

type Cell :
    record
        x, y : int
    end record

var selected : Cell

% When selection has no value (to compare to for if it's a "first click")
selected.x := -1
selected.y := -1

% onMouseDown() -> selectCell() -> check which variable to change.
% If selected isn't null, then it's the second click / selection, and you fire the 
% moveObject function which resets everything afterwards.


That said mirhagk's right. Chess is a massive endevor. Try starting with checkers before trying a game with 6 different movement types (vs checker's 2) (and then there's castling and en passent as well). Both have kinging/queening too, but meh.

-----------------------------------
william 01
Thu Jun 02, 2011 1:56 pm

Re: Chess Game, need help with secondary click
-----------------------------------
Ok. I took your advice and changed to a checkers game. but now I am stuck.
this the code I've got so far to get the peice to move:
Private Sub cmdA2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdA2.Click
        If Colour = 1 Then
            If gameboard(0, 7) = 1 Then
                If Not Firstclick Then
                    Firstclick = True
                    fromRow = 0
                    fromCol = 7
                End If
            ElseIf gameboard(0, 7) = 0 Then

            End If
        ElseIf Colour = 2 Then

        End If
    End Sub
 
colour = 1 is my boolean for the player
gameboard(0,7) = 1 is checking if the square is ocupied and by whom

but I don't know where to go from here. can any one be of assistance?

-----------------------------------
william 01
Fri Jun 03, 2011 8:13 am

Re: RE:Chess Game, need help with secondary click
-----------------------------------

% You need to take into affect that a player can miss click on an invalid cell,
% or even the fact the player selected an invalid to begin with.
% You shouldn't be calculating the state of the game by counting the clicks, but
% rather the previous state of the game (ie: your selection).

type Cell :
    record
        x, y : int
    end record

var selected : Cell

% When selection has no value (to compare to for if it's a "first click")
selected.x := -1
selected.y := -1

% onMouseDown() -> selectCell() -> check which variable to change.
% If selected isn't null, then it's the second click / selection, and you fire the 
% moveObject function which resets everything afterwards.


That said mirhagk's right. Chess is a massive endevor. Try starting with checkers before trying a game with 6 different movement types (vs checker's 2) (and then there's castling and en passent as well). Both have kinging/queening too, but meh.
this is for turring not vb so it wont help me. should have noticed sooner.

-----------------------------------
Tony
Fri Jun 03, 2011 11:41 am

Re: RE:Chess Game, need help with secondary click
-----------------------------------
this is for turring not vb so it wont help me.
The exact syntax/implementation might be different, but ideas are easily transferable between languages.
