| | |
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:
Solved Threads: 1
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
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
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Format Number in Sql Query
- Next Thread: VB6 timer use to compute a value for minute
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





