Results 1 to 4 of 4

Thread: game of 15/ simple question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    Has anyone made one of those 'game of 15' games. You know the kind where there are 15 buttons lined up three across, and you have to move the buttons to get them in order? usually there is a picture on the buttons but it is scrambled until you put the buttons in the correct order.

    if you know what I'm talking 'bout, this is my question.

    How can I tell if the button I want to move has the blank button next to it?

    *****************************
    [1] [2] [3]
    [4] [ ] [6]
    [7] [8] [9]
    [10][11][12]
    [13][14] [ 5]

    **************************
    ubove is a poor representation of what i am reffering to.
    you can see that square number [5] is at the lower right and the blank square is where it should be.
    only by moving one square at atime can you get number [5] to the correct area.

    I know i am not explaining this well so let me know if you need more info....

    thank you
    pnj

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Supposing you have a 2d array of 15 elements with upperbounds 2 and 4 containing the number:

    x and y is the selecteds coordinates
    a is the array
    and fail is a boolean that determines no empty (5) around
    Code:
    Do
        If x Then If a(x - 1, y) = 5 Then Exit Do
        If x < 2 Then If a(x + 1, y) = 5 Then Exit Do
        If y Then If a(y - 1, y) = 5 Then Exit Do
        If y < 4 Then If a(y + 1, y) = 5 Then Exit Do
        fail = True
    Loop until true
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    huh......thanks Kedaman

    I don't really know what you meen.
    I will try and explain myself better.
    the game is made up of picture box's, or buttons.
    there are 16 buttons, but one is empty, so they are numbered 1 to 15. when the game starts, the numbers are not in order. the player clicks a button next to the empty button to move it into the empty space.

    the buttons themselves have to move, not the caption.
    the buttons can only move up,down,left,right.


    does this make more sense?
    I am sure your code would work great, but I don't quiete get it.

    thank you
    pnj

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How can I tell if the button I want to move has the blank button next to it?
    well i thought i was answering to this qwestion.
    Yes i know what youre trying to do even if you didn't explain it too well, you have 14 buttons numbered from 1 to 15 of which nr nr5 is missing. doesn't really matter you could have the last one missing too or nr0, as long as you change the recognision part in my code to find that "blank" number.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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