Results 1 to 3 of 3
Thread: first game help
- 12-02-2010, 02:50 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
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
-
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!
- 12-02-2010, 05:04 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM -
game code for any game
By deathnote202 in forum Java GamingReplies: 4Last Post: 06-10-2010, 08:06 AM -
Help! Game.
By MIA6 in forum New To JavaReplies: 4Last Post: 11-08-2009, 12:22 AM -
Game 21
By aRTx in forum Advanced JavaReplies: 3Last Post: 04-04-2009, 12:33 AM -
2D strategy game or 2D war game
By led1433 in forum Java 2DReplies: 5Last Post: 02-10-2009, 06:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks