Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Attempting to make Java text-based game


  • Please log in to reply
2 replies to this topic

#1 b2jsai

b2jsai

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:09:18 PM

Posted 01 August 2010 - 01:24 PM

Hi,

Well we just got started on learning Java and using BlueJ this semester.

I practice by condensing all I learn for the week into games.

What I want to do is make a JAR file that when executed displays a terminal window which
is required for a text-based game.

1. Is there any way to "export" BlueJ's terminal along with a Jar file? So that whenever I run the JAR file, the BlueJ terminal pops up?

2. I've tried downloading JarStdioTerminal 0.8. It actually works fine EXCEPT that you cannot scroll up and down while
something like JOptionPane.showMessageDialog or showInputDialog is displayed. My game requires regular input from
the JOptionPane. This is why I'd like to get BlueJ's, since you can scroll even if JOptionPane is open.

Is there any way to edit this to make it scrollable? JarStdio is available for free download. It is google searchable.

Details of the game:

The game runs on the while() command for infinite loops of showInputDialogs for actions to be performed.

P.S.:
I found out that the command prompt works well too. But how to make it so that when you double click the JAR file, the command prompt opens with it?

Edited by b2jsai, 01 August 2010 - 01:28 PM.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:18 AM

Posted 01 August 2010 - 06:47 PM

1. Yes and no. If you merely want some text displayed, you can run it from the command line. Amy text that would be dumped to the output in your IDE would also be displayed on a command line. However if you want some sort of popup/window with buttons and such, you are going to have to code that yourself. I am not sure how the BueJ ide works, but in Netbeans it is really simple to drag and drop components.

2. Everything in java is an object, and all objects can be manipulated and extended to do what you want. However that is up to you to research and figure out.

3. If you want a command prompt to open when you run a jar file, then you need to research how to do that. The easier option would probably be to create a batch file that opens a command terminal and executes the program.

Learning how to program requires some patience. While you may want to do things that you have not yet learned, you are either going to have to wait until you have learned some of the basics, or are going to have to do extensive research. One of the biggest parts of learning how to program is having the ability to do research.

#3 b2jsai

b2jsai
  • Topic Starter

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:09:18 PM

Posted 01 August 2010 - 10:13 PM

If you want a command prompt to open when you run a jar file, then you need to research how to do that. The easier option would probably be to create a batch file that opens a command terminal and executes the program.

This worked great for me. Thanks! Used a batch file that I put into the same folder as my Game.jar. Works like a charm.

Learning how to program requires some patience. While you may want to do things that you have not yet learned, you are either going to have to wait until you have learned some of the basics, or are going to have to do extensive research. One of the biggest parts of learning how to program is having the ability to do research.


Well said, sir. I do tend to get ahead of myself. Our professor's been teaching us the very basic stuff like the 'if else' statments.
But that just doesn't do it for me, since I want to get really good at a much more rapid pace.

I've learned a lot of the coding I know from self-study of our book (Java Concepts by Car Horstmann) and of java websites, such as the documentation.

A big thanks for your help. This forum has been very helpful. I'll be posting more technical/better questions as I get proficient in the language.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users