» Programming » Code and Snippets
Register
 •  FAQ  •  Search  •  •  Login    
It is currently Fri Sep 10, 2010 4:13 am




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Text Adventure Engine - Messy
PostPosted: Sun Oct 18, 2009 8:18 pm 
User avatar
Offline
Rampage!
Rampage!

Posts: 74
I started working on an engine to make some text adventure goodness sometime last year but moved on to
something shiny five minutes later. Randomly got the urge to finish it this weekend and figured no reason
not to share the result, if anyone feels like offering crit or improvement suggestions too that'd be just super.

Some of the code is adapted from this tutorial: (Exit.java and Location.java)
http://www.javacoffeebreak.com/text-adv ... index.html
Everything else is mine.

I've included the source code as well as a sample game I got to working on this afternoon.

I am aware of some issues with the text formatting, and portions of the code are very messy :P i'm aware
I need to relegate the code for printing out available exits to a new method, just havn't gotten around to
doing it yet. But if you find any other bugs, shout me.

Also, I can't see to get it to continue reading after a space. For example, with an item name
if the name is "Iron Bar" and I try "pickup Iron Bar" it reads "Iron" and tries to process that,
then does the same with "Bar" instead of taking "Iron Bar" as one input. I've tried scanner.nextLine()
too and that doesnt seem to help.

If anyone wants to use the code, go right ahead, just credit me (Adrian Gordon)

Edit:
Does anyone have a good tutorial on java file i/o? I'd be interested to see if I can make
it read a list of items, locations and worldObjects from a text file instead of instantiating them all
in the Game.java

RE-EDIT:

List of commands:

QUIT, EXPLODE: These quit the game.

COMMANDS, HELP, HOWTOPLAY: These display the available commands.

LOOK, SEE, EXAMINE: These display the current room and available exits.

USE "itemName": Attempts to use the item at the current location (currently, item names are one word only)

PICKUP "itemName": attempts to pick up an item. (i'll add GET too soon, forgot to add it in)

INVENTORY, INV: Displays your inventory

In addition to these, you can type in some other stuff depending on the location, try typing the names of some objects
or details in the scene.

There's a couple more, but they aren't essential to gameplay.


Attachments:
MarsCalling.zip [15.22 KiB]
Downloaded 44 times
TextAdventureCode.zip [7.33 KiB]
Downloaded 41 times

_________________
I'm a coder! A really bad one!


Last edited by The_A_Drain on Mon Oct 19, 2009 3:48 pm, edited 4 times in total.
 Profile  
 Post subject: Re: Text Adventure Engine - Messy
PostPosted: Sun Oct 18, 2009 9:28 pm 
User avatar
Offline
Moderator

Posts: 3015
Location: pl_badwater
Is there any more after taking off?

_________________
YOU WILL BE SERVANTS OF THE SATAN
Image


 Profile  
 Post subject: Re: Text Adventure Engine - Messy
PostPosted: Sun Oct 18, 2009 9:30 pm 
User avatar
Offline
Rampage!
Rampage!

Posts: 74
Ahh sorry, that's totally my fault.

It's not obvious but certain keywords can be used, when you're sat at the shuttle console type "mars"
and the game will warp you to the Mars shuttle station.

Once you step outside of the Mars terminal though (after another little gameplay segment) that's all there
is for now.

_________________
I'm a coder! A really bad one!


 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
phpBB skin developed by: Gaz and Dave
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group