• Re: simple sheme for paragraph game in c

    From Richard Damon@Richard@Damon-Family.org to comp.lang.c on Fri Aug 15 14:53:45 2025
    From Newsgroup: comp.lang.c

    On 8/11/25 3:16 AM, Mikko wrote:
    On 2025-08-10 18:25:45 +0000, Richard Damon said:

    On 8/9/25 6:05 PM, fir wrote:


    i might already asked that question (but then i abandoned this
    and today get back to it)

    i need extremally simple schem for coding paragraphs

    in main game part i got two callbacks one is in

    OnDraw()
    {
      draw_current_screen();  //<-- its callback pointer
    }

    OnKeyPressed(int key)
    {
     last_key=key;
     current_key_handler(); //<-- thios is callback for keys
    }

    so in game i need to provide a lot of routines for drawing text
    and a lot for handling keypresses

    it currently look like that


    start()
    {
      text("youre in the middle of the woods, chose what to do:");
      text("1) go north");
      text("2) go south");
    }

    start_()
    {
      key('1', go_north, go_north_); //this function just set callbacks
    to new state
      key('2', go_south, go_south_);
    }

    and so on i could produce hundred paragraphs of this way and it will
    make a net of connected parragraphs


    But it somewhat annoys me as it still seem to moe to be
    to complicated and i needed to be as simple as its possible


    how i could sipmplify it?  note i could replace function key
    by some makro to write  KEY(1, go_north) probbaly
    (i write probably as i dont use macros in c at all and even dont
    remember how to define them, but still its maybe annoying to have 2
    routines for each paragraph

    isnt it possible to write this something like


    start()
    {
      text("youre in the middle of the woods, chose what to do:");
      text("1) go north"); KEY(1, go_north);
      text("2) go south"); KEY(2, go_south);
    }

    ????

    as i could writhe a tons of this paragraphs (thinking about writing big
    paragraph game) it would simplyfy a hours of typing


    This sounds very much like would be solved with the Adventure
    Construction Set. That wasn't in C, but should be able to be
    translated to it. Note, the "map" wasn't done in code, but data.

    https://en.wikipedia.org/wiki/Adventure_Construction_Set

    For a text only game making one's own engine is as easy as to find
    a good enough one (unless one already has one).


    The point is that rather that writting a lot of code for all the
    routines, and repeating yourself over and over with boiler plate.

    You write one simple engine, and "program" the game with data-structure.

    My understanding is that the ACS wasn't written in his prefered
    language, and so he might want to recode it. but its program structure
    solves the problem he was having of need a lot of code which does
    basically the same thing.
    --- Synchronet 3.21a-Linux NewsLink 1.2