Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Interactive Fiction / Text Based Adventure on: 2005-11-10 14:32:16
Hey everyone,

someone I know gave me some advice but I'm not entirely sure what to do

You should have a booksection class. This class can only contain methods and variables related to a booksection so,
 
a booksection can have an int ID, String text, ArrayList or array of choices: int[] choice;
and the methods it can implement are for example:(although there may be more)
 
public String getText(){
 return text;
}
 
public String getchoices(){                               <----- see the difference between this and yours. No parameters
 String response = "choices are";
 for (int i=0; i<choices.length, i++){
 response = response+choice
}
 
So each booksection can now output its text and choices.
In the main section not the booksection class we can (assuming we have created a booksection object called myBookSection) get the choices for a specific booksection by using for example:
 
String choices= myBookSection.getchoices();
 
The important point here is that each booksection object can now return the text and choices that it contains. In the main java file, you have to find the right booksection id from your ArrayList and then use its methods.
 
In the main program you should create around 10 booksection objects (read from file or hard coded) and add these to an ArrayList of type <booksection>.
 
The functionality for operating the book and turning to different booksections should be implemented in the main java file.
 
If the user selects page 10 for example, you should find the booksection with id 10 from your ArrayList of booksections and display the text and the links for this page. This is then a recursive process.
 
Pseudo code for navigating the book:
 
create an empty booksection object
get the first page from your book arraylist and assign it to the booksection object created above
 
While (number of links in booksection is not equal to 0)

{
 Display the booksection id
 Display the booksection text
 Get the user to input the id of the next booksection -(use getchoice method)
 Get the user selected page from your book arraylist and assign it to the booksection object created above
}
2  Game Development / Newbie & Debugging Questions / Re: Interactive Fiction / Text Based Adventure on: 2005-11-10 05:02:08
I think I'd like to go for something like the transitional adventure (though not based on items) just user input (left, right etc)

What I mean by the below

Is I'd like to come up a very basic and simple text based adventure... say have a fixed array of 10 items, each item will contain the description / text of a room then they will link to each other in some way the function of the booksection class (as described below) will be to display the text of the current room and then ask from the users input on where they would like to go next and then put up the next for that new room (looking for something fairly basic) I've posted some bad pseudo-code below but would really like some help expanding it

----------------------------------------------------------------
Thanks, guys much appreciated... I'll definately try some of the code (though it may be a complicated for me)

Just wondering if I could trouble everyone for some more advice. So I'm using an array list to store the text / descriptions for various rooms. and I'm thinking a class called something like BookSection So I think the BookSection class should display the text / description associated with the current room and that it should also have links to 1 or more rooms and depending on user input (left, right etc) it should move the user to that room and change the text

I've come up with the following code and after searching the books I have (Head First Java, Just Java 2 and How to Program Java) and checking online I'm at a loss and was wondering if anyone had any idead how to code this (based on the bad and very limited code I have below)

class booksection{
int index //page number
string text //the story
int[]choices // the pages links
}

to display a page the program would display the string and the choices
and then load the choice the user made

method getchoices(page, thispage){
string text = "choises are"
thispage.choices.length
for (int i=0; i<2, i++){
text = text+thispage.choice
}

return text
}

this would display the story and the appropriate choices

Once thanks for the replies regarding the save system.
3  Game Development / Newbie & Debugging Questions / Re: Interactive Fiction / Text Based Adventure on: 2005-11-10 02:41:01
Thanks, guys much appreciated... I'll definately try some of the code (though it may be a complicated for me)

Just wondering if I could trouble everyone for some more advice. So I'm using an array list to store the text / descriptions for various rooms. and I'm thinking a class called something like BookSection So I think the BookSection class should display the text / description associated with the current room and that it should also have links to 1 or more rooms and depending on user input (left, right etc) it should move the user to that room and change the text

I've come up with the following code and after searching the books I have (Head First Java, Just Java 2 and How to Program Java) and checking online I'm at a loss and was wondering if anyone had any idead how to code this (based on the bad and very limited code I have below)

class booksection{
int index //page number
string text //the story
int[]choices // the pages links
}

to display a page the program would display the string and the choices
and then load the choice the user made

method getchoices(page, thispage){
string text = "choises are"
thispage.choices.length
for (int i=0; i<2, i++){
text = text+thispage.choice
}

return text
}

this would display the story and the appropriate choices

Once thanks for the replies regarding the save system.
4  Game Development / Newbie & Debugging Questions / Interactive Fiction / Text Based Adventure on: 2005-10-25 01:24:08
Hello,

Long time lurker, first time poster. Wondering if I could ask on some advice and help on a group project.

What we'd like  to do is to put together an:

Interactive Fiction / Text Based Adventure games with say
- 10 Story Sections / Rooms
- An Item System
- A Combat System
- A save system
- And perhaps the ability to change the rooms (editing the story)

Now we've had no problems so far with the combat system and are currently upgrading the code to add more complex options, as for the Item system I think we're going to do something simple with say giving each item a true or false state and changing certain things depending on what state each items variable is in (just need to work out how to integrate it)

We have a fairly good idea for the save system also just dump some relevant information to say a txt file on where the user is within the game and what items they have picked up etc

The main problem we are having is coming up with the rooms thinking of using an ArrayList with different rooms / sections then having a class to implement each section of the Array with the text associated with that rooms and then links to different rooms... only problem is we're not sure how to code it...

Anyway I was wondering if anyone had any suggestions or ideas on any part of project particularly how to implement the rooms, if someone could post some code or link to an existing project that would great.

Thanks in advance for any advice given
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (44 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (38 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (87 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!