Results 1 to 2 of 2
  1. #1
    alpdog14 is offline Member
    Join Date
    Mar 2009
    Posts
    57
    Rep Power
    0

    Default Trying to create a map for a Zuul game using JFrame

    I am new to java and need some help. I have a Zuul game and want to add a map class so that I can the map open in a Jframe while my game plays in the terminal window. I am trying to change the label of this JFrame but it is turning out to be very difficult and was wondering if anyone new of a better solution or could help me with this. Here is the map class code:

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    
    public class map
    {
        private JFrame frame;
        
        /**
         * Create an ImageViewer show it on screen.
         */
        public map()
        {
            makeFrame();
        }
        
        // ---- swing stuff to build the frame and all its components ----
        
        /**
         * Create the Swing frame and its content.
         */
        private void makeFrame()
        {
            frame = new JFrame("ImageViewer");        
            Container contentPane = frame.getContentPane();
            
            JLabel label = new JLabel("This is a label");
    
            contentPane.add(label);
    
            frame.pack();
            frame.setVisible(true);
        }
    }
    I tried to add this map text to where it said "This is a label":

    Java Code:
    *                      zoolab              preproom
         *                         |                   |     \
         *                         |                   |      \
         *       pub------------outside -------------theatre   \
         *           \             |                            \
         *            \            |                             basement3     
         *             \           |                                       \
         *              \         lab--------------office                   \
         *               \       /                                           \
         *            steamtunnel -- basement1 ----basement2--basementlab     \
         *                 |                                          \        \
         *                 |                                           \        \
         *                 |                                       valveroom     \
         *              "X" Room                                         \        \
         *                                                                \        \    
         *                                                           bottomroom--rocktunnel
         *                                                                         |
         *                                                                       darkroom
         *                                                                         |
         *                                                                       gem room--DragonRoom--DungeonRoom
    I tried to use "\n" to separate out each row but nothing is helping. Let me know the best process for making a map using a jFrame or if there are better tools for this.

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Don't use ASCII art. See a Java2D tutorial and actually draw the map.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  2. Game 21
    By aRTx in forum Advanced Java
    Replies: 3
    Last Post: 04-04-2009, 12:33 AM
  3. 2D strategy game or 2D war game
    By led1433 in forum Java 2D
    Replies: 5
    Last Post: 02-10-2009, 06:00 AM
  4. Tic Tac Game
    By loggen in forum New To Java
    Replies: 1
    Last Post: 12-12-2008, 07:36 AM
  5. Create the game Hangman
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 06:16 AM

Posting Permissions

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