Sign in to follow this  
Juls

Making a sliding puzzle

Recommended Posts

Juls    102

Hello guys!

I am trying to create a sliding puzzle, like this for the kinect: http://vimeo.com/22839911

Unfortunately I am learning how to use all of this only now so I am pretty confused.

In order to make this puzzle I decided to start out by just making a sliding puzzle using the XNA framework with some random image I choose and then add the next features.

I divided it in the following tasks:

 

*Open image (or draw the sprite)

*Slash it into various squares and separate it 

*Randomize it

*Mouse controls to put everything back in place

 

I am sad to say I got stuck on my second task. I have no idea how to slash a sprite into various sprites and then move them around. I looked around desperately but so far haven't found anything that helps.

I really really need this done by next week and any help would be great.

 

Thank you very much for your time!

 

 

Share this post


Link to post
Share on other sites
Lil_Lloyd    287
What you need to do is have many quads (tiles or squares in the puzzle) and have the main image as a texture. Then for the coordinates of the quads you also need texture coordinates between 0.0 and 1.0. As an example if I had four squares the texture coordinates of the top left square would be

(0.0,0.0)---------(0.25,0.0)
| |
| |
| |
(0.0,0.25)--------(0.25,0.25)

As the square moves around its screen coordinates will change but its texture coordinates will remain constant. I also made a sliding puzzle some time ago, you can see it under my projects here: http://www.lloydcrawley.com/projects/ at the bottom of the screen

There is a github repo link there too if you want to look at the source code. Good luck!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this