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

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

Veena
Thanks, it worked exactly as you suggested.
jacobi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.