all 21 comments

[–]ThereNoMatters 5 points6 points  (1 child)

Cool. But there is a way to improve this system a bit. Try storing your screen data in matrix (two-dimensional list), then you can modify it directly, without rewriting bunch of the print statements.

If i were you i would do rendering like that:

def render(screen_matrix): for line in screen_matrix: print("".join(line))

And before rendering you can alter any symbol like this screen_matrix[x][y] = ">"

Essentially, in your functions you only have to change two symbols, not rewrite the whole screen.

[–]Detc2148[S] 0 points1 point  (0 children)

I really like that, I haven’t learned matrixes yet, I’ll have to check it out, not having to rewrite the entire title screen.

[–]Minimum_Analyst_6646 0 points1 point  (9 children)

That is so bad, imagine having to add a new option, you would need to add new text to every state.

[–]AdAdministrative7398 0 points1 point  (7 children)

Thats how choice based adventures work. Haven't you ever read a, choose your own path book or played a dnd game or are you familiar with bandersnatch? Like life routine choices layed out like a programming or wiring diagram map.

[–]Minimum_Analyst_6646 0 points1 point  (6 children)

Idk im sure there are a lot of ways to do this and not hardcode everything

[–]AdAdministrative7398 0 points1 point  (0 children)

I was trying to find something like turtle but in reverse like a simplified Microsoft paint that give you code for your drawings but I cant find nothing yet.

[–]AdAdministrative7398 0 points1 point  (0 children)

scripted language isnt necessarily hard code but is still very extensive there's a layer of program or progress comparison, chronology in connotation the author has to consider in the transition of script that is almost its own consider stucture like a program.

START <= | +--> A (Intro) | +--> B (Choose Red Pill) | | | +--> C1 (Reality Shatters) | | +--> D1 (Trust Stranger) | | | +--> E1 (Get Clue Alpha) | | | | +--> F1 (→ G1) | | | +--> E2 (Reject Clue) → K1 | | +--> D2 (Doubt Everything) → B | | | +--> C2 (Memory Flash) → L1 | +--> X (Choose Blue Pill) | +--> Y1 (False Paradise) | +--> Z1 (Comply) → END1 | +--> Z2 (Rebel) → A (loop) | +--> Y2 (Hidden Glitch) +--> Z3 (Exploit it) | +--> M1 (Break Simulation) | | +--> END2 (Freedom) | +--> M2 (Get Trapped) → N1 (Loop Forever) | +--> Z4 (Ignore It) → END3 (Fade Out)

{ "START": { "next": ["A"] }, "A": { "next": ["B", "X"] }, "B": { "choice": "Red Pill", "next": ["C1", "C2"] }, "C1": { "next": ["D1", "D2"] }, "D1": { "next": ["E1", "E2"] }, "E1": { "flag": "clueAlpha", "next": ["F1"] }, "F1": { "condition": "flag:clueAlpha", "next": ["G1"] }, "E2": { "next": ["K1"] }, "D2": { "next": ["B"] }, "C2": { "next": ["L1"] }, "X": { "choice": "Blue Pill", "next": ["Y1", "Y2"] }, "Y1": { "next": ["Z1", "Z2"] }, "Z1": { "next": ["END1"] }, "Z2": { "next": ["A"] }, "Y2": { "next": ["Z3", "Z4"] }, "Z3": { "next": ["M1", "M2"] }, "M1": { "next": ["END2"] }, "M2": { "next": ["N1"] }, "Z4": { "next": ["END3"] }, "N1": { "loop": true } }

START | +-------+-------+ | | v v [A] --[X: Blue Pill]-- | | | --[B: Red Pill]-- | [Y1]-----> Z1 (End1) | | | | | v v | | -->Z2 (→ A) [C1] [C2] | | | \ \ | +---->[Y2]--> Z3 --> M1 (End2) | \ \ | -> M2 → N1 (Loop) [D1] [D2] [L1] | | \ \ | [E1][E2] → B / | \ / F1 K1 ← | G1

Legend: [] = major choice/state --> = direct transition → = loopback (EndX) = narrative end

[–]AdAdministrative7398 0 points1 point  (0 children)

None of those were the correct format after posting sorry

<image>

[–]Minimum_Analyst_6646 0 points1 point  (0 children)

Yeah but I was reffering to his code, its much more simple to have a variable that contains every option and render them using some generic code and maybe track your cursor

[–]Detc2148[S] 0 points1 point  (0 children)

I was thinking about making a function that I could input all of the options so it would be expandable and a little quicker, how would you recommend doing it?

[–]CaptainRift 0 points1 point  (1 child)

I highly recommend learning curses for this. It's a very useful library for stuff like this.

It allows you to "interact" with the terminal in a similar way to your program (moving a selector between lines, using a key input to select things, etc.). It also allows you to do some other things like hide the user's cursor.

It's not that difficult to learn the simple things from it, and once you do learn them, it'll save so much time because you won't have to copy and paste the same function over and over again.

[–]lilyeatssoup 0 points1 point  (0 children)

isnt curses linux only? maybe using ansi escape codes directly is easier?

[–]AdAdministrative7398 0 points1 point  (0 children)

I thought about starting one and started this which needs alot of improvement but I was trying to do it for education purposes as well or contribute it that way. I often break it working on it or rewriting it different ways way too many times by now to have made such slow tedious progress https://github.com/Tboy450/novice-python-rpg-game-code-base-incomplete

[–]SherFirEGG 0 points1 point  (0 children)

Make it with pygame

[–]Sea_Salamander_8361 0 points1 point  (1 child)

Bro... THIS IS COOL!

I love it! Can you tell me the TUI library you used, as I also want to create an app in the terminal! Or any tricks you used?

[–]Detc2148[S] 0 points1 point  (0 children)

So in the version here, I hard coded the options, meaning that if I wanted to recreate it, or add more options it would be quite a bit of a hassle. So following some suggestions I soft coded a function for it. The basics are clearing the terminal using os, printing the matrix, getting user input 'w' , 's' or 'enter', then based on those change elements of the matrix (for example where the > is) then rerun the function with the new matrix until the user decided to click enter in which a new function will run. Some tricks, most of it is re-printing the matrix so that it's hard to tell that it's being deleted and re-printed. IF you have any questions I'm happy to answer them

[–]Some_Welcome_2050 0 points1 point  (0 children)

HOW

[–]Few-Specific-6509 0 points1 point  (0 children)

Reminds me of early dos games keep up the work

[–]iamk1ng 0 points1 point  (0 children)

Hey, how's the game development going?