Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (652)
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 5839 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?

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: (swing on the console) (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, within a 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 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.

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.

SHC (17 views)
2015-08-01 03:58:20

Jesse (17 views)
2015-07-29 04:35:27

Riven (38 views)
2015-07-27 16:38:00

Riven (20 views)
2015-07-27 15:35:20

Riven (22 views)
2015-07-27 12:26:13

Riven (13 views)
2015-07-27 12:23:39

BurntPizza (32 views)
2015-07-25 00:14:37

BurntPizza (44 views)
2015-07-24 22:06:39

BurntPizza (25 views)
2015-07-24 06:06:53

NoxInc (33 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!