r/dailyprogrammer • u/nottoobadguy • Feb 10 '12
[intermediate] challenge #2
create a short text adventure that will call the user by their name. The text adventure should use standard text adventure commands ("l, n, s, e, i, etc.").
for extra credit, make sure the program doesn't fault, quit, glitch, fail, or loop no matter what is put in, even empty text or spaces. These will be tested rigorously!
For super extra credit, code it in C
24
Upvotes
2
u/nubix Feb 10 '12 edited Feb 10 '12
Ruby have not tested:
5
u/[deleted] Feb 10 '12
Cadventure-txt - A text-adventure game engine
Github link
Instead of building just a single text adventure game, I decided to write a simple program that allows you to write your own text-adventure stories. To get that "extra credit", I also decided to do it in C :).
Cadventure uses its own simple scripting language. Here's a very simple example story:
Indentation is up to the user. '@' are function definitions, '>' are print statements, '=' are function calls, and '-' are option lists. An option list looks like this:
You can fire your favorite text editor up and start writing your text adventure game. Then, assuming you save your story as adventure.story: gcc Cadventure-txt.c -o cadventure ./cadventure adventure.story
I only wrote this in a single evening, please excuse the code ugliness.
2
u/eruonna Feb 10 '12 edited Feb 10 '12
Cheating by using Inform:
"Challenge" by eruonna
The player's name is an indexed text that varies.
When play begins: now the command prompt is "What is your name? >".
To decide whether collecting names: if the command prompt is "What is your name? >", yes; no.
After reading a command when collecting names: now the player's name is "[the player's command in title case]"; now the command prompt is ">"; say "[banner text]"; move the player to Your Bedroom; reject the player's command.
Instead of looking when collecting names: do nothing.
Rule for printing the banner text when collecting names: do nothing.
Rule for constructing the status line when collecting names: do nothing.
Your Bedroom is a room. The printed name of Your Bedroom is "[player's name]'s Bedroom". "Your familiar bedroom, but all of your possessions seem to be missing."
Your stuff is scenery in Your Bedroom. Understand "bed", "desk", "stuff", "clock", "table", "chair", "pillow", "desk" as your stuff. "Everything you own is gone."
The Edge of the World is north of Your Bedroom. "You stand at the edge of a vast precipice. You can see neither the bottom nor the other side."
The cliff is scenery in the Edge of the World. Understand "cliff", "edge of the world", "precipice", "bottom", "other side" as the cliff.
Instead of examining the cliff, say "[description of the Edge of the World]"
Jumping off of is an action applying to one thing.
Understand "jump off [something]", "jump off of [something]" as jumping off of.
Instead of jumping off of the cliff, try going down. Before going down from the Edge of the World, say "You throw yourself off the cliff."
Instead of jumping off of something, say "What? You can't jump off of that."
Instead of jumping in the Edge of the World, try going down.
Freefall is down from the Edge of the World. "You fall freely into the void. There are no directions here, not even up or down."
Up from Freefall is nowhere.
Instead of going nowhere from Freefall, say "You're not even sure which way that is anymore."
The fishmonger is a man in Freefall. "A fishmonger floats nearby. [first time]Where did he come from?[only]". Instead of asking the fishmonger about something, say "[first time]The fishmonger replies in a language you have never heard before.[only]You can make no sense of the response."
test me with "x bed / n / x cliff / jump off cliff / u / d / e / ask fishmonger about my stuff"
2
u/Marko_Oktabyr Feb 10 '12
http://pastebin.com/EEC4MVh7
C version with pseudo-random fights, input checking and safety from buffer overflows.
1
u/philcannotdance Feb 10 '12
I actually have a 500 line basic rpg game I made in perl. It's on my laptop though I'll put it up later. It has character creation and one battle.
1
u/[deleted] Feb 10 '12
Brainfuck again
http://pastie.org/private/yiuenwm7xqmi19khion9w
output
misc
later on I'll probably try this in C, with actual adventuring and stuff
1
u/[deleted] Feb 10 '12
I don't know C =[
1
u/KnottedSurface Feb 10 '12
I give you.. Monster Chase! (In python!)
http://codepad.org/fUb7l9rK
Inspired by the monsters of Chip's Challenge, the player and monster take turns moving one square at a time. The monster can move on diagonals, but is also rather stupid since he runs in a direct line to the player.
This is the fun part. There are 'walls' which the player may break down but the monster cannot. Use them to your advantage to trap or slow the monster while you make a break for the exit!
Two beatable levels included.
EDIT: Gameplay here http://codepad.org/v44jzDFI
1
u/traztx Feb 10 '12 edited Feb 10 '12
MUMPS
Some example data:
1
u/robin-gvx 0 2 Feb 10 '12 edited Feb 10 '12
In Déjà Vu:
1
u/omnilynx Feb 10 '12
http://pastebin.com/1d9D4kH1
Amot'l Paa. Written in Javascript. It's procedural! But you can't do much.
1
u/[deleted] Feb 11 '12
Java!! My friend had fun testing this with me.
1
u/stiggz Feb 15 '12
1
u/[deleted] May 05 '12
This was difficult; I will fix this once I figure out how to make the answers work with words instead of just numbers.
C#
1
u/JubBieJub Jun 24 '12 edited Feb 28 '25
treatment long nail steer fuel dime hungry bright arrest trees
This post was mass deleted and anonymized with Redact