Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Chess Game, need help with secondary click
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
william 01




PostPosted: Wed May 11, 2011 1:49 pm   Post subject: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed May 11, 2011 1:53 pm   Post subject: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
william 01




PostPosted: Wed May 11, 2011 2:03 pm   Post subject: 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




PostPosted: Tue May 17, 2011 10:33 am   Post subject: Re: Chess Game, need help with secondary click

does this mean that no one can help me?
Tony




PostPosted: Tue May 17, 2011 12:19 pm   Post subject: 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).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
z_cross_fire




PostPosted: Wed May 18, 2011 3:11 am   Post subject: 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




PostPosted: Wed May 18, 2011 4:43 pm   Post subject: 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




PostPosted: Wed May 18, 2011 6:16 pm   Post subject: RE:Chess Game, need help with secondary click

Turing:

% 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.
Sponsor
Sponsor
Sponsor
sponsor
william 01




PostPosted: Thu Jun 02, 2011 1:56 pm   Post subject: 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:
VisualBASIC:
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




PostPosted: Fri Jun 03, 2011 8:13 am   Post subject: Re: RE:Chess Game, need help with secondary click

Zren @ Wed May 18, 2011 wrote:
Turing:

% 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




PostPosted: Fri Jun 03, 2011 11:41 am   Post subject: Re: RE:Chess Game, need help with secondary click

william 01 @ Fri Jun 03, 2011 8:13 am wrote:
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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: