Share your repls and programming experiences

← Back to all posts
streamline making text based games!
Nettakrim (391)

comes with various ways of controlling color, the cursor and text in general

set it up like this

import text
from text import colors as c
colors=c()
from text import cursor

colors.<x>

in built colors

black
red
green
yellow
blue
magenta
cyan
bright_black
bright_red
bright_green
bright_yellow
bright_blue
bright_magenta
bright_cyan
bright_white
end (this ends any color)
invert (this swaps foreground an background)

functions

cprint(text)

  • same as print, but if you set colors.use_color to false it doesnt use color

remove(text)

  • removes all color and other modifiers from text

background(color)

  • changes color to be a background color

foreground(color)

  • changes color to be a foreground color

rgb(list)

  • takes (R,G,B) style list and turns it into color

text.<x>

modifiers

bold
dim
italics
underline
reset

clearing

osclear()

  • clears screen using os.system("clear")

clear()

  • uses a different form of clear to stop flicker, not always usable

cleardown

  • sometimes fixes issues with clear() and cursor moving
#use of cleardown
x=""
while not x.isdigit():
  x=input(f"input: {text.cleardown}")
  cursor.control(cursor.up(1))

other functions

spacing(length,a,b)

  • evenly spaces text

randomsprinkle()

  • see main.py for explaination

cursor.<x>

all of these can be used with either

print(cursor.<x>+"text")
cursor.control(cursor.<x>)

hide
show

  • self explanatory

up(x)
left(x)
right(x)
down(x)

  • moves cursor in direction x amount

save

  • saves cursor position

unsave

  • moves cursor to saved position

move(x,y)

  • moves cursor to x y position

control(text)

  • same as print(text,end="")

to see some of these used in an actual game look at
max donalds
text.py is bassically a refinement of what i used in that