Live data from Hacker News

How to program a text adventure in C (2016)

home.hccnet.nl

11–20 of 36 posts

Re: How to program a text adventure in C (2016)

#11
post #3

Ask HN: what's a good JS (browser focused) text adventure engine? I see me making a text adventure (adding one mini chapter) each day as a good lockdown project. Note: I might call it "Everything is better in quarantine." The goal would be to (not) go mad.

> Ask HN: what's a good JS (browser focused) text adventure engine?

Take a look on ISTEAD - Simple Text Adventure Interpreter.[0]

It has JS-based version[1,2] and native versions (SDL-based in pure C) for Android[3,4], Windows and Unix-like platforms (including Linux, macOS/iOS, Maemo/MeeGo, Symbian 9.x, various consoles, etc.).[5]

Text adventures for INSTEAD could include Lua-scripts (text adventure itself & modules) and various media assets (images, sounds, fonts).[6]

There is repo with free games & demos for INSTEAD, which in most cases could be installed directly from INSTEAD clients.[7]

[0] https://github.com/instead-hub

[1] https://github.com/instead-hub/instead-js

[2] http://instead.itch.io/

[3] https://github.com/instead-hub/instead-android-ng

[4] https://apt.izzysoft.de/fdroid/index/apk/org.emunix.insteadl...

[5] https://github.com/instead-hub/instead/releases

[6] https://instead-hub.github.io/en/#doc

[7] http://instead-games.ru

Re: How to program a text adventure in C (2016)

#12
post #6

I suggest to look into https://ifcomp.org/ - the annual interactive fiction competition is running for 25 years now and there are some great games and resources over there.

The greatest text games I have played are Curses! and Anchorhead. Both are immersive and vast. Anchorhead is genuinely scary. There are some pointless puzzles and timed puzzles, but overall, truly worth trying out.

Re: How to program a text adventure in C (2016)

#13

This programmer, Mr. Ruud Helderman, is like Cool McCool, "Danger is my business!". For example, the parser, function matchParam: OBJECT *obj; par->tag = src; par->distance = *src == '\0' ? distNoObjectSpecified : distUnknownObject; forEachObject(obj) ... The initialization of the obj variable received an obliviate spell. Also function parseAndExecute (). The way he deal with invalid input is, epic: static const COMM…

This is C89 style code where you couldn't declare the loop variables in the for loop, as in "for (OBJECT * obj = ... ". There's no problem with this code. The obj variable is initialized in the forEachObject macro which expands to a for loop. (Pretty damn sure - I haven't actually looked up the definition). The array iteration code is also solid. Seems like a pretty good programmer, judging from the code you cite her…

Overall I agree with you, my comment is just pointing out that this kind of tricks are dangerous, Cool McCool style, use at your own risk and so. Things you stop doing after your first million bugs fixed.

Re: How to program a text adventure in C (2016)

#14

Earlier quoted context omitted.

This is C89 style code where you couldn't declare the loop variables in the for loop, as in "for (OBJECT * obj = ... ". There's no problem with this code. The obj variable is initialized in the forEachObject macro which expands to a for loop. (Pretty damn sure - I haven't actually looked up the definition). The array iteration code is also solid. Seems like a pretty good programmer, judging from the code you cite her…

Overall I agree with you, my comment is just pointing out that this kind of tricks are dangerous, Cool McCool style, use at your own risk and so. Things you stop doing after your first million bugs fixed.

Well in fact I've tended more and more to this bare kind of coding as I've aged (and hopefully gained experience). Many of the seatbelts (like assertions) I've actually hit at some point or another (so they turned out to be useful in these situations), but on the other hand they allowed me to be more sloppy in my thinking, writing more complicated code, which I feel could be a net loss in productivity.

Then again this is just some example code on a website, so it's natural that it has to be done a little more straightforwardly than you would write it in actual practice.

Re: How to program a text adventure in C (2016)

#15
post #3

Ask HN: what's a good JS (browser focused) text adventure engine? I see me making a text adventure (adding one mini chapter) each day as a good lockdown project. Note: I might call it "Everything is better in quarantine." The goal would be to (not) go mad.

Single- or multi-player? I'm thinking of figuring out why https://evolvingstory.juliablewis.com/ keeps crashing, cleaning it up and open-sourcing it. Also thinking of rewriting it using a different event system.

Re: How to program a text adventure in C (2016)

#18
post #12
post #6

I suggest to look into https://ifcomp.org/ - the annual interactive fiction competition is running for 25 years now and there are some great games and resources over there.

The greatest text games I have played are Curses! and Anchorhead. Both are immersive and vast. Anchorhead is genuinely scary. There are some pointless puzzles and timed puzzles, but overall, truly worth trying out.

Thanks for the suggestions! I've never heard of IF before - but I'm a long time MUD / roguelike player. This looks really great.

Re: How to program a text adventure in C (2016)

#19

Earlier quoted context omitted.

Overall I agree with you, my comment is just pointing out that this kind of tricks are dangerous, Cool McCool style, use at your own risk and so. Things you stop doing after your first million bugs fixed.

Well in fact I've tended more and more to this bare kind of coding as I've aged (and hopefully gained experience). Many of the seatbelts (like assertions) I've actually hit at some point or another (so they turned out to be useful in these situations), but on the other hand they allowed me to be more sloppy in my thinking, writing more complicated code, which I feel could be a net loss in productivity. Then again thi…

It's natural to show people code as an example, which not write like that in practice? What's the example for then? Is there a disclaimer following, saying thaT the code is not how you would write it and mentioning all the things you would do differently? Enlighten me please.

Re: How to program a text adventure in C (2016)

#20

This programmer, Mr. Ruud Helderman, is like Cool McCool, "Danger is my business!". For example, the parser, function matchParam: OBJECT *obj; par->tag = src; par->distance = *src == '\0' ? distNoObjectSpecified : distUnknownObject; forEachObject(obj) ... The initialization of the obj variable received an obliviate spell. Also function parseAndExecute (). The way he deal with invalid input is, epic: static const COMM…

This is C89 style code where you couldn't declare the loop variables in the for loop, as in "for (OBJECT * obj = ... ". There's no problem with this code. The obj variable is initialized in the forEachObject macro which expands to a for loop. (Pretty damn sure - I haven't actually looked up the definition). The array iteration code is also solid. Seems like a pretty good programmer, judging from the code you cite her…

> The array iteration code is also solid.

Shouldn't there be a NULL at the end of the array and do a null check in the iteration?

Post reply on HN