Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Sliding picture puzzle

Author
Message
lmb
9
Years of Service
User Offline
Joined: 3rd Apr 2015
Location:
Posted: 6th Jun 2015 18:26
Hi I am looking to make a sliding picture puzzle app.

similar to...........


Does anyone have any tips? I have some ideas and am able to move the clicked picture but there are constraints as to which images can move etc which I have not yet thought through fully.


Thanks

lmbeeee
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jun 2015 00:36
What you have there is a 4x4 array. Currently it look like this:

dim arrTile[4,4] as integer

X0XX
XXXX
XXXX
XXXX

By checking the array, you can see if the move is a valid one - you can only move:

1. an X adjacent to an O
2. in the direction of the O

Whether it is a picture, letters or numbers, you can still number the tiles in the correct sequence, and give the space a value of 0, -1 or whatever suits you. Then you can check the array for the right sequence to confirm it is complete.

01 00 03 04
06 02 11 10
05 08 07 09
14 12 15 13

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Jun 2015 14:14
That's what I'd do. Remember that you don't have to actually interpret which way a piece should move, because any piece that you select would only ever move to the blank area. So if you select a piece, check for a neighboring blank space and move there.

Also, to ensure that the puzzle is reasonably solvable, just do a load of random moves, after setting the tiles to the solved locations. If find that it's easier to always stick to the game rules... like a card game I'd shuffle the deck by swapping cards randomly, a rubiks cube I'd do random rotations from a solved cube - this way you always know it's possible to solve the puzzle.

To control the movement of tiles/sprites, I'd store the grid X Y values related to the sprites - so when moving a sprite, you'd set the grid position, and have the sprite move there, like a loop that shows the sprite moving when it isn't at the correct location.

JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 15th Jun 2015 23:21
Hey Mr. Imp! I've started a community project for a cool scramble picture puzzle game. I thought you might like to take a look, get some ideas and hopefully help you build your own game.

Check it out

lmb
9
Years of Service
User Offline
Joined: 3rd Apr 2015
Location:
Posted: 20th Jun 2015 11:53
Thanks to all of you for the help with this. I had struggled with the array advice above, so it was nice to see what you have done with your example JLMoondog. I will be asking for some more advice on the board soon so thanks in advance.

lmbeeee

Login to post a reply

Server time is: 2024-11-21 15:26:08
Your offset time is: 2024-11-21 15:26:08