Results 1 to 10 of 10

Thread: [RESOLVED] 2d grid with 1d control array?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    259

    [RESOLVED] 2d grid with 1d control array?

    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.
    Last edited by kandieman101; Nov 10th, 2002 at 10:00 PM.
    SonicMailer Pro
    The best mailing list manager has just gotten better!
    Click here for a full list of features!

  2. #2
    Addicted Member
    Join Date
    Apr 2002
    Location
    Israel
    Posts
    152
    use this(in your case max=8)
    PHP Code:
    Index - (Index max) * max
    Index max 

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    259
    You have "index max" is there some operator between them?
    SonicMailer Pro
    The best mailing list manager has just gotten better!
    Click here for a full list of features!

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well, this is how you do it (I don't know what Arthur's was doing):
    VB Code:
    1. X = Index Mod 8
    2. Y = Index \ 8
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    259
    Originally posted by Sastraxi
    Well, this is how you do it (I don't know what Arthur's was doing):
    VB Code:
    1. X = Index Mod 8
    2. Y = Index \ 8
    That won't work... if my control array is 1 - 64....

    64 would be (8,8)... but 64 mod 8 = 0....
    SonicMailer Pro
    The best mailing list manager has just gotten better!
    Click here for a full list of features!

  6. #6
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    259
    Thanks for all your input guys.. I am well on my way!
    SonicMailer Pro
    The best mailing list manager has just gotten better!
    Click here for a full list of features!

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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.
    Last edited by Sastraxi; Nov 11th, 2002 at 12:23 AM.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    VB Code:
    1. X = 63 Mod 8
    2. X = 7
    3.  
    4. X = 63 \ 8
    5. X = Int(63 / 8)
    6. X = Int(7.785)
    7. X = 7
    umm yeah this will always return 7
    at the end you set X to 7

    also what does the Mod operoator to

    is it remander of divsion

  10. #10
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width