Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java Slider Puzzle Help

843789Feb 18 2010 — edited Feb 18 2010
Hi, I am new to programming with Java (started about two-three months ago) and I am learning it in my Programming class at High School. My final project of this term is to make a sliding puzzle applet with 9 pieces like this one:

http://www.ericharshbarger.org/cgi-bin/j.cgi?slidingpuzzle/index.html

except mine needs to be moved around with the arrow keys, needs to have a "solve" button (which will allow someone to attempt to solve the messed up tiles and keep track of their number of moves), a "mess up" button (which will allow the user to mess up the tiles aka place them in random order and it also "removes" one of the 9 tiles) and it has to know when the image is unscrambled and make the user aware of their victory. My teacher has given us a suggested plan on how to tackle this project and it goes something like this:

1. Get an image
2. Cut it into 9 pieces
3. Make a 10th piece that is blank to be the removed space
4. Create two 2d image arrays
-one will store the correct images as reference
-one will store them all mixed up
5. create one Boolean array*
-stores the location of where the empty tile is
6. create on rectangle array*
-stores info for the tiles aka their location on the plane and the width and height
7. display the tiles in the right order
8. make a button to remove a random tile
9. allow the remaining pieces to be moved around to mix up the picture*
-also has to store how many moves you used to screw up the picture
10. create a "solve" button to indicate it is the solvers turn
11. keep track of moves made
12. check if the pieces have been moved into the right locations*
13. if the puzzle is completed, put the right tile back in place*
14. play sounds when the puzzle is completed or when a tile is moved

So far, all I have is steps 1 to 4 and 7 and I'm really not sure on how I should go about completing this project. We are supposed to be using a lot of for and while loops and although I've got for loops pretty much down, I'm not sure I quite understand while loops. I tend to learn better on my own just by playing around with what I'm given instead of reconstructing things (which is essentially how we learn most in class).

Does anyone have any input as to how I should start this project and how I would do the steps I have placed a star beside?

Thanks for any help or comments in advance.
Ransem

Edited by: ransem on Feb 17, 2010 9:32 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2010
Added on Feb 18 2010
8 comments
1,153 views