PDA

Click to See Complete Forum and Search --> : game of 15/ simple question


pnj
Feb 28th, 2001, 10:23 AM
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

kedaman
Feb 28th, 2001, 10:34 AM
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

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

pnj
Mar 1st, 2001, 10:45 AM
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

kedaman
Mar 1st, 2001, 12:33 PM
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.