You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Project LotG

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

0
b/PC, Mac & Vintage Computers publicado por u/Woodrow January 21, 2019, 04:53:45 PM
So, I'm making a text adventure game for a competition. i want the game (which you just lost) to
- take player choices as input and store them
- depending on player choices, move throughout the story
- have unique responses to certain inputs for comic effect, including a catch-all for unrecognized inputs ("what does [input] even mean?")

heres a basic example using my (incomplete)!game path so far. (etc means thats the farthest ive programmed in that path)

start > look > look > look > death for annoying the narrator
start > look > look > west > death for annoying the narrator
start > east > death by boredom
start > west > pet the goat > etc
start > west > attack the goat > death by goat attack
start > west > feed the goat > death by goat bite

basically, there is only one correct path through the game. all other paths inevitably lead to death and end the program.

my question is, how can i do this without drowning in if/else if/else/while loops? is there a library that could make my life easier? im using c++, but i can switch to java if that means more efficiency.

i have about a month for the competition.
Inicia sesión o crea una cuenta para dejar un comentario
u/Jean-Baptiste Boric January 22, 2019, 06:47:27 PM
You can model your game as a (set of) finite state machine(s), where each state (vertex) has a number of valid transitions (directed graph) to progress the story depending on both the game's state and the player's input. Most adventure games have at least one FSM modelling the current player's location, but you can have more than one to handle things like puzzles, timers, NPCs and so on, depending on how complex your game will be.

Understanding the player's input is historically one of the hardest things to get right. There's no miracle solution, but generally you'll have to identify at least the verb (= action) and optionally one or more objects to act on. Tokenize the input and try to make sense of it. I recommend handling a fair amount of synonyms too, unless you want to frustrate users.

You can study some classic adventure games like battlestar (https://github.com/NetBSD/src/tree/trunk/games/battlestar), though code quality has come a long way since the early 80s. I'd also recommend studying adventure (https://github.com/NetBSD/src/blob/trunk/games/adventure) as an example on how NOT to write an adventure game.
u/Yuki January 25, 2019, 01:54:53 AM
I'd suggest a language made for IF and text adventures like Inform 7 I think it's going to be the best. Nice learning curve, easy to do whatever needed in a standard IF game and it mostly looks like English.
Start a Discussion

b/PC, Mac & Vintage Computers

Computer programming discussion and project showcase

132
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal