Jump to content

Choose your own adventure game


codenature

Recommended Posts

Hi, I want to make people be able to make their own choose your own adventure game for other people. I want the database to hold each "scene" that the writer makes, then let the user put in a choice. For example here is one scene with a choice.

 

"You are in a forest. You see a castle, a house, and a road before you. Which will you choose?"

 

Then in the text field the user submits the keyword of either "castle", "house", or "road", and it goes to the appropriate next scene.

 

The problem is, when the game writer is typing in his adventure, I have no clue how I should make up the User interface creating the game or linking up the "scenes".

 

It is kind of like a tree format. Like this.

 

Forest

  |

  |

House Road Castle

|          |        |

hermit  fence    dragon

               

           

I know I want the user to type in each scene like "forest" into the text field and submit it to the database, but I have no idea how to link lets say "House" to "Forest" or "Hermit" to House text. Or how I would echo out the next appropriate scene from the Database when the user enters the name of a new scene like "House".  Ideally the page would not reload when the user types a new scene, maybe ajax for that? I have no clue, Thank you in advance for any ideas.

Link to comment
Share on other sites

Each scene should have a unique ID in the database, as well as a list of acceptable keywords to advance the scene. Ideally you would normalize that data into two tables. A crude example might look like:

scenes
--------------------
id | name
1  | forest


keywords
--------------------
scene_id | id | name
1        | 1  | castle
1        | 2  | house
1        | 3  | road

 

So now you know that the scene "forest" will only accept the keywords "castle", "house", and "road". You can grab this data with a quick JOIN:

SELECT s.id AS scene_id, s.name AS scene_name,
       k.id AS keyword_id, k.name AS keyword_name
FROM scenes AS s
LEFT JOIN keywords AS k ON k.scene_id = s.id

 

Is that what you were looking for?

 

Link to comment
Share on other sites

Great! Thank you. Also, do you know how I would have the description for each scene in the database? Like if for Forest, I had " You see a beautiful forest with the sun shining through the trees." Please. Thank you so much for the code. Also, do those aliases in your SQL run like that? like s... for "scene"?

Link to comment
Share on other sites

I am having a database structure problem.

 

If I have scene Forest->options to go to [house] [tree] [road], then each of those 3 needs more links, so that if fI have 2 keywords for new scenes for house, tree and road, that immediately turns into 6 different scenes I have to account for in the database, here is my problem.

 

 

Database

 

ID|Story|Scene| Description|Keyword1|Keyword2| (keywords=actions the user types to display a new scene)

1  Mike | Forest | You see a..| House  |    Road

2  Mike |  House |You see..  | Chair  |    Hermit

 

how to do Road???

 

Now I have a problem. I am able to make the new information for the House keyword, but I cannot make an entry for the Road Keyword.

Link to comment
Share on other sites

Nevermind, I just drew it out, and the growth of the scenes grows to a power of 2 if 2 scenes are added to each subsequent scene. My problem is not the database, the problem is my linear design that would create an insanely large database in just a few rooms.

 

 

room 1

|    |

2    3

4|5|6|7

 

etc etc

first room 2 options

room 2 , 2 options, room 3, 2 options, so that makes four options.

next rooms, are 8 options.

next rooms are 16 options.

 

So unless I am wrong, the problem is the linear way I am doing to story, or something else. I don't know anymore.

Link to comment
Share on other sites

Ok thank you!. I will read it. Also, I decided to ditch the linear "story board" method, to a simpler x,y location method. It is more like the real world, and can be just as descriptive as linear narratives. But the article should be interesting. Thank you. :D

 

By the way I like your signature. LOL. If you don't succeed, or while you are not succeeding, try again(). haha.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.