Results 1 to 5 of 5
  1. #1
    tzeus is offline Member
    Join Date
    Dec 2013
    Posts
    20
    Rep Power
    0

    Default Puzzle game questions

    Hello,
    I am developing a puzzle game for a project.
    So far i have the following situation:
    Program loads, and lists the pwd image files as thumbnails(JButtons with images) in a JPanel.
    When user clicks an image, that image is broken into 16 pieces and scattered around the Jpanel(i call remove all first, so i can clear the Jpanel).
    ----
    right here i am a little stuck.
    I was planning to use JLabel or JButton for the little pieces, but then i have 2 problems: drag and drop, and snap to edges. So i have 2 questions:
    1. What do you guys think would be the best elements to draw the little pieces in? JLabel, Images, Buttons? I am fairly new in Java, and i have no experience to graphic layouts so far.
    2. What do i do about the drag and drop feature. I plan to use no image recognition or special tricks, for the making of the whole picture i just plan to rely upon small images file name(img0 goes near img1, etc.)

    Thank you in advance!

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,723
    Rep Power
    5

    Default Re: Puzzle game questions

    Its a cool project, but have you done anything like this before? Have you built any other Swing application? I have the idea that you are trying to tackle something quite difficult as your first project.

    If you'd give up free placement in your game but in stead apply a uniformly sized grid (GridLayout comes to mind), you can greatly simplify your problem domain and you wouldn't really need such advanced techniques as drag & drop and edge detection / snapping; all you'd have to implement is clicking on cells within the grid to move stuff around. That could be so simple as a grid of buttons with ImageIcons.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    tzeus is offline Member
    Join Date
    Dec 2013
    Posts
    20
    Rep Power
    0

    Default Re: Puzzle game questions

    It is not that type of puzzle. I saw that kind of puzzle, but it is not what i am trying to achieve. It is my first project in Java, but i am not that afraid to do it. I have used vb.net and c++ before and a little python, plus i think this is the best way to learn. So to answer your questions: I have not done something like this before, first time using swing, but i learn fast, and i have programmed before using other technologies. I am fine with reusing code someone else has written as long as i understand every bit of it.

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,723
    Rep Power
    5

    Default Re: Puzzle game questions

    Then I don't know what you want to achieve, because that's what I extract from your problem description. Regardless: step one is learning the ins and outs of the Swing API.

    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    tzeus is offline Member
    Join Date
    Dec 2013
    Posts
    20
    Rep Power
    0

    Default Re: Puzzle game questions

    There are 2 types of puzzles: slide left/right - up/down type or move by drag/drop elements. I want the second type, and i wanted to know what was the best swing component to make the puzzle pieces. The pieces are obviously graphic images, but what type of element would be the best? Because there is more than one way of element that IS or can CONTAIN a picture. I am still waiting for suggestions, but thanks for the link, i will begin studying it asap.

Similar Threads

  1. Peg Puzzle Solver GUI
    By Harlow777 in forum SWT / JFace
    Replies: 2
    Last Post: 11-11-2013, 03:48 PM
  2. 3D game questions.
    By Disaster in forum New To Java
    Replies: 2
    Last Post: 07-06-2011, 10:05 PM
  3. Tromino puzzle
    By azertyazerty in forum New To Java
    Replies: 0
    Last Post: 03-23-2011, 03:50 PM
  4. Making a puzzle game, need help!
    By Atriamax in forum Advanced Java
    Replies: 1
    Last Post: 12-30-2010, 12:55 AM
  5. N-Puzzle Help!
    By evan42781 in forum New To Java
    Replies: 12
    Last Post: 04-29-2009, 11:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •