• Create Account

## static 'banner' for zork like game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1JonathanCCC  Members

160
Like
0Likes
Like

Posted 18 February 2014 - 01:52 PM

hello,

i'm currently making a text based game like zork using python 3 with pycharm IDE.

I am wondering how I can make a static banner at the top of the console that always remains while the user enters commands etc at the bottom.

if you don't know what I mean, here is the zork game:

I want to make what they have at the very top, with location, score and moves. Also, how can I highlight the text in grey like that?

Jonathan

### #2LennyLen  Members

5405
Like
0Likes
Like

Posted 18 February 2014 - 01:57 PM

You should be able to do all that with Curses for Python.

### #3JonathanCCC  Members

160
Like
0Likes
Like

Posted 18 February 2014 - 03:46 PM

thanks LennyLen

However i've come up against an unusual error already, the tutorial states that

curses.initscr() must be called first.

So I do this with

stdscr = curses.initscr()

but my pyCharm compile output gives this error "Redirection is not supported."

i've googled this problem but there seems to be only 1 result, for which that person also didn't get an answer... I don't suppose you know at all?

### #4JonathanCCC  Members

160
Like
0Likes
Like

Posted 18 February 2014 - 03:54 PM

hmm after checking google further it seems curses in general doesn't support windows and errors can occur often and that I should download a windows designed curses module instead.

i'll guess i'll look into that!

EDIT: although it seems they are all outdated and not workable for python 3.

Looks like curses is a luxury for Linux users and the like. Is there no other way such a thing as at the top of the Zork game can be done without it?

Edited by JonathanCCC, 18 February 2014 - 03:59 PM.

### #5swiftcoder  Senior Moderators

17806
Like
0Likes
Like

Posted 18 February 2014 - 05:43 PM

Looks like curses is a luxury for Linux users and the like. Is there no other way such a thing as at the top of the Zork game can be done without it?

You can do manually all the stuff curses would do for you - but it's not for the faint of heart.

You can get most of the way there by learning the escape codes for your terminal (for Windows, you'll need something like ansicon).

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #6JonathanCCC  Members

160
Like
0Likes
Like

Posted 18 February 2014 - 06:20 PM

thanks swiftcoder

actually so far I don't need a module for the simple thing I wanted to do, which was create something "static" at the top of the console.

i've so far achieved it by simply clearing the screen in python, writing the "banner" then printing several blank new lines before any input or output example:

os.system('cls')

print("Whatever banner you want")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
input("enter a command: ")

of course this is a very crude way of doing it and who knows how many blank lines need to be used for all users (probably impossible to know) - as an ultra beginner I know of no other way though

but at least you get a simple static line above any commands or output. I thought my request was too simplistic to warrant any modules!

### #7Bacterius  Members

13100
Like
0Likes
Like

Posted 18 February 2014 - 06:30 PM

There's also PDCurses as an ncurses implementation for Windows. It sucks that it doesn't have the same name (which means your build process needs to deal with it) but the code is the same. system("cls") is somewhat system-dependent, and not very efficient. It's probably not a problem yet but when it becomes one, do consider using ncurses!

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.