I am making a checkers game, (8x8) and I am using a control array of picture boxes as the grid.... the problem is. How do I determine that if they click on picturebox 10, it is the 2nd in the 2nd row? Things like that...
Thanks.
Printable View
I am making a checkers game, (8x8) and I am using a control array of picture boxes as the grid.... the problem is. How do I determine that if they click on picturebox 10, it is the 2nd in the 2nd row? Things like that...
Thanks.
use this(in your case max=8)
PHP Code:X = Index - (Index \ max) * max
Y = Index \ max
You have "index max" is there some operator between them?
Well, this is how you do it (I don't know what Arthur's was doing):VB Code:
X = Index Mod 8 Y = Index \ 8
That won't work... if my control array is 1 - 64....Quote:
Originally posted by Sastraxi
Well, this is how you do it (I don't know what Arthur's was doing):VB Code:
X = Index Mod 8 Y = Index \ 8
64 would be (8,8)... but 64 mod 8 = 0....
one way to do it is to have your control array values "seem" to be 2d you can set them as, this will work in your situation but will not work if your "wana be" 2d control array is more than 99 x 99 controls because the index will not go that hight.
11,12,13,14,15,16,17,18
21,22,23,24,25,26,27,28
.ect
then when every you want to convert them to use in the reg array say something like
y = val(left(str(piccheckersquare.index)),1)
x = val(right(str(piccheckersquare.index)),1)
'the left functoin is a premade (with vb6 at least, not shure about other versions) it gets the chractors starting from the left of the string you speify to the number you specify over
if that didnt make since hers some examples:
get = left("abc",1)
get = "a"
get = left("abc",2)
get = "ab"
get = left("cba",2)
get = "cb"
right does the same but from the right side
Thanks for all your input guys.. I am well on my way!
KandieMan, my code was correct. Controll arrays should be 0 to 63 (for an 8 x 8 grid). Thus:
X = 63 Mod 8
X = 7
Y = 63 \ 8
Y = Int(63 / 8)
Y = Int(7.785)
Y = 7
And as you can see, it returns 7, 7, which is correct.
[EDIT] changed X's to Y's in the 2nd block.
umm yeah this will always return 7Quote:
VB Code:
X = 63 Mod 8 X = 7 X = 63 \ 8 X = Int(63 / 8) X = Int(7.785) X = 7
at the end you set X to 7
also what does the Mod operoator to
is it remander of divsion
Whoops, the 2nd block is meant to be Y = instead of X =. Anyway, that was just a thought process, look at it, 63 mod 8 IS 7. Int(7.785) IS 7. It's not code, if it was I would've put it in code tags.