Jump to content

  • Log In with Google      Sign In   
  • 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.

  • You cannot reply to this topic
6 replies to this topic

#1 JonathanCCC   Members   -  Reputation: 145

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?

 

 

thanks in advance,

Jonathan



Sponsor:

#2 LennyLen   Crossbones+   -  Reputation: 3436

Like
0Likes
Like

Posted 18 February 2014 - 01:57 PM

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



#3 JonathanCCC   Members   -  Reputation: 145

Like
0Likes
Like

Posted 18 February 2014 - 03:46 PM

thanks LennyLen

 

i've downloaded and installed that module and i'm reading the documentation regarding it now.

 

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?



#4 JonathanCCC   Members   -  Reputation: 145

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.


#5 swiftcoder   Senior Moderators   -  Reputation: 9645

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]


#6 JonathanCCC   Members   -  Reputation: 145

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!



#7 Bacterius   Crossbones+   -  Reputation: 8187

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!


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis





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.



PARTNERS