Results 1 to 3 of 3

Thread: first game help

  1. #1
    relith is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Smile first game help

    hey guys I have an idea for a game and so far I have making it all to be played using commands in terminal or cmdprompt.

    I have been trying to make it in windows using the JOptionPane commands.

    but i dont know how to do what I want to do.

    here is a screen shot of what my goal is.
    and my code that I have so far.




    Java Code:
    import javax.swing.*;
    import java.lang.*;
    import java.io.*;
    import java.awt.*;
    
    
    
    
    public class RPG extends JFrame {
    
    
    
      public static void main(String[] args) {
      
    
      
    	Icon icon = new ImageIcon("http://www.java-forums.org/images/Icon.png");
    	Icon warrior = new ImageIcon("http://www.java-forums.org/images/Warrior.png");
    	Icon ranger = new ImageIcon("http://www.java-forums.org/images/Ranger.png");
    	Icon magician = new ImageIcon("http://www.java-forums.org/images/Magician.png");
    	Icon character = new ImageIcon();
    
       String name = (String)JOptionPane.showInputDialog(null, "What is your name?", "RPG Game by --------",  JOptionPane.PLAIN_MESSAGE, icon, null, null);
       
        Object[] selectionRaces = {"Human", "Elf", "Dwarf" };
        String initialRace = "Human";
        Object race = JOptionPane.showInputDialog(null, "What race are you?",
            "RPG Game by -------", JOptionPane.PLAIN_MESSAGE, icon, selectionRaces, initialRace);
    
        Object[] selectionType = { "Warrior", "Ranger", "Magician" };
        String initialType = "Warrior";
        Object type = JOptionPane.showInputDialog(null, "What class are you?",
            "RPG Game by --------", JOptionPane.PLAIN_MESSAGE, icon, selectionType, initialType);
            
        Object[] selectionSide = { "Neutral", "Good", "Evil" };
        String initialSide = "Neutral";
        Object side = JOptionPane.showInputDialog(null, "What side are you on?",
            "RPG Game by -------", JOptionPane.PLAIN_MESSAGE, icon, selectionSide, initialSide);    
         
         if (type == "Warrior") {
         	character = warrior;
         }
         if (type == "Ranger") {
         		character = ranger;
         }
         if (type == "Magician") {
         	character = magician;
         }
         if (type == null) {
         	character = icon;
         }
         
        JOptionPane.showMessageDialog(null, "Name:  " + name + "\n" + 
        									"Race:    " + race + "\n" +
        									"Type:    " + type + "\n" + 
        									"Side:     " + side + "\n" , "RPG Game by --------", JOptionPane.PLAIN_MESSAGE, character);
           
    System.exit(0);
      }
    }

    thanks for any help. :)

    relith

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    My suggestion is not to do a bunch of JOptionPane dialogs, but rather to study Swing and then build a Swing GUI app from the ground up. To learn how to do this, start here: Using Swing Components

    Best of luck!

  3. #3
    relith is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default wow

    that looks like exactly what I was looking for.

    I have looked at swing before but i guess the sites i was using sucked.

    ever thought a site through oracle could be so thorough and newbie friendly.

    thanks a bunch! :)

    ps - dig the name fubarable. :P

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 05:49 AM
  2. game code for any game
    By deathnote202 in forum Java Gaming
    Replies: 4
    Last Post: 06-10-2010, 09:06 AM
  3. Help! Game.
    By MIA6 in forum New To Java
    Replies: 4
    Last Post: 11-08-2009, 01:22 AM
  4. Game 21
    By aRTx in forum Advanced Java
    Replies: 3
    Last Post: 04-04-2009, 01:33 AM
  5. 2D strategy game or 2D war game
    By led1433 in forum Java 2D
    Replies: 5
    Last Post: 02-10-2009, 07:00 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
  •