Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java text based game tutorials  (Read 5094 times)
0 Members and 1 Guest are viewing this topic.
Offline calebj

Junior Newbie





« Posted 2010-01-09 03:03:29 »

Hello people of this forum. I am more experienced in web based languages such as PHP, RoR and a couple system languages however I need to learn Java for one of my university classes. I figured the best way to learn the language would be to have a little fun doing so.

I would like to create a text based rpg style game linking multiple classes and dealing with strings as user inputs which act as triggers.

Does anyone have any recommendation, tutorials or advice for someone like myself?

Caleb.
Offline i30817

Junior Devvie





« Reply #1 - Posted 2010-01-09 04:02:47 »

You're going to need to interact with native code if you're going to get fancy (colors, "movies" things like that).

I know of two resources (that i've never used) using ncurses:


http://www.pitman.co.za/projects/charva/ (swing on the console)

http://sourceforge.net/projects/javacurses/ (ncurses binding)
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2010-01-09 04:05:31 »

I would just pretend it's the console and fashion a big JTextArea to look like it. You'll get a lot more control a lot more easily.

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline i30817

Junior Devvie





« Reply #3 - Posted 2010-01-09 04:07:23 »

There is also
libcaca (for color on the console too). I'm not aware of any java binding.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #4 - Posted 2010-01-09 07:23:27 »

If by text RPG, you mean something like the old console adventure games like Zork, then I'd suggest using the console and keeping things simple.  Writing text is easy using print.out.println(..);  However input takes a bit more work.  I'd look at wrapping the console input stream System.in, within a java.io.BufferedReader class.  This will allow you to grab one line at a time, rather than just a stream of characters.  This could be wrapped in a java.io.StreamTokenizer to split the stream into words.  You will need to set it to return eoln as a token, after which you can call it repeatedly for each line until you get the eoln token.  At this point you would need to parse the tokens.  Probably best to keep it simple <verb> <object>.  You will also need arrays of room objects, including data fields for description, exit destinations (NSEW) etc.  Also a collection of game objects that can be located in rooms or on the player.  It might be easiest to make the player a sub-class of room.  Objects will need fields defining their description and various attributes.

Commands
N,S,E & W:  Look up appropriate destination room number in current room and set player location.  Print room description
Get <object>: Search collection of objects for one with this name.  Check it is in the same room as player; Set object location to player.
Drop <object>: Search collection of objects for one with this name: Check it is on player; Set location to player's current location

Write code to support other verbs as needed by the game's puzzles.  These normally check conditions (e.g. is player carrying a key; is player in the room with a locked door; is the door locked => unlock door - write success text, modify room description, modify room exits.

If however you want RPG style character classes and battle system, then console i/o will probably be too limiting and you will need to write a GUI application.  At this point it is best to use an IDE with a form editor (e.g. Netbeans), as this will make life easier.  Having said that, the degree of difficulty has increased a level if you haven't used java before, and it might be too much for a time-limited project.

For the RPG version, the main difference is that each action has a success probabilty based on players stats.  You also need to keep the player constantly informed of their health points, ailments etc. and this is where a pure console approach tends to be inadequate

Time flies like a bird. Fruit flies like a banana.
Offline calebj

Junior Newbie





« Reply #5 - Posted 2010-01-09 17:59:43 »

Thank you everyone for your replies! When I get home from work I will start working on it.
I think I will go with a big java console style text box to run something like Zork. If I want to get all fancy later I can add some objects. I'm really glade about the quality of posts and feedback I received back.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2010-01-09 22:17:01 »

When I was first learning Java I used a package called TerminalIO for console input. I found this after a quick Google search, but I'm not sure if it's the same. I never looked at TerminalIO's source, I only used its functions.

Actually, it's likely that this is probably it.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (15 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02

SHC (97 views)
2014-12-03 16:27:13
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!