Board Game in VB6 - Move Limitation.

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2005
Posts: 7
Reputation: jacobi is an unknown quantity at this point 
Solved Threads: 1
jacobi jacobi is offline Offline
Newbie Poster

Board Game in VB6 - Move Limitation.

 
0
  #1
Jun 16th, 2008
Except for this one problem I have created a board game in VB6. There are four red pieces and one blue, with the board as per chequers, only the white squares in use. The sqaures are in an indexed control array (0 to 63) with only the white squares enabled.
I'm using Mouse_Down with Form_DragDrop to move any piece to any enabled square and I've regulated the sequence of moves (blue, red, blue etc) with a Static counter divided by
Mod 2 and a Source.BackColor test.
I need to limit the extent of any piece to one diagonally adjacent square in any direction. I have allocated the Index of each label in the control array as its Caption. My intention was to use two variables, NewLoc (for the destination square expressed in terms of a label Index) and OldLoc (for the vacated square again to be expressed in terms of a label index).
Newloc is easy to produce from the X and Y of Form_DragDrop, so I tried to create a function (GetOldLoc) to return the Caption of the vacated square, but because I am using Source + attributes the function will not return OldLoc as it needs a better identifier than Source. I would have used the test "If NewLoc - OldLoc is not equal to -9, -7, 7 0r 9 Then Exit Sub Else Source.Move X, Y etc."
I could write some 160 lines (32 squares times 5 pieces) in the function, but this would produce so much spaghetti.
Anybody suggest a function method to produce this OldLoc, please?
jacobi
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Board Game in VB6 - Move Limitation.

 
0
  #2
Jun 17th, 2008
Hi,

Keep 2 FormLevel Variables for OldLoc.
and Save them.. Initally, When the Game starts, assign Default Position to Old Loc, and keep on assigning the variable whenever, the position changes.

Cant help much as I havent seen your code..

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 7
Reputation: jacobi is an unknown quantity at this point 
Solved Threads: 1
jacobi jacobi is offline Offline
Newbie Poster

Re: Board Game in VB6 - Move Limitation.

 
0
  #3
Jun 18th, 2008
Veena
Thanks, it worked exactly as you suggested.
jacobi
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC