• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Game Programming Output

How can i ouput stuff with out refreshing the screen and reouput... (SPACE INVADERS) No Graphics, all text based!!!
0
cdc_sickle
Asked:
cdc_sickle
  • 8
  • 6
1 Solution
 
nietodCommented:
Standard C++ doesn't provide any mechanism for doing this.  Standard C++ doesn't even assume you are outputing to a display.  All it assumes is that standard output is some sort of text-based device, but that device could be a teletype, a text file, a brail reader etc.  

So there is no way in standard C++ to "refresh" the screen.

However there are likely to be ways to do this that are dependant on your hardware or you Operating System.  

For example, in Windows you can use the WriteConsoleOutout() function (and other functions) to do this sort of thing.   In UNIX you can use the curses library to do this.  I DOS you can use the DOS video services to do this etc...

So we need to know what OS and possibly what hardware you are using.
0
 
cdc_sickleAuthor Commented:
Ok, this operating system im working on is Windows 95. its a 486 (yuk) No graphics card, well, no good one... So no support for like directx and stuff... It has dos prompt and stuff. And im working in Turbo C++ 4.5

The other system(s) i can use are my home systems! p3 450 voodoo3
all the good stuff, but im not that good at programming. I want to keep it simple as possible...
0
 
cdc_sickleAuthor Commented:
By the way, my home system has borland builder 1.0, win98
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nietodCommented:
Turbo C++ produces DOS programs, so you can write directly to the video adapter's memory.  Or you can use the non-statnd function GotoXY() which Borland usually supplies with its products.

for Builder you have to create windows console program (not DOS) and use WriteOuput().  

These are two very different techniques, you probably should for decide which platform you want to work with, then we can go from there.  (It is possible to do both platforms, but that is a lot more work.)
0
 
cdc_sickleAuthor Commented:
Turbo C++ Since that is what im supposed to work in :(
0
 
nietodCommented:
Then look for a function called gotoxy().  It moves the cursor to the specified x/y coordinates on the display.  Then you can simply use printf() or cout to output the new information at the location (overwritting the old information)

You can refresh the entire screen by moving to (0,0) and then writting out an entire screenful of information.
0
 
cdc_sickleAuthor Commented:
And this wont work in borland?
0
 
nietodCommented:
Turbo C++ is borland, right?  

Anyways this should work for Turbo C++ (if the function is provided for you, I'm not sure that it is.)

This would also work in Builder, if the function was provided, but I don't think it is.   However, in Builder there are other ways to do it (that don't use this function.)

Can you find the function?   check your docs.  Scan your .h files.
0
 
cdc_sickleAuthor Commented:
Ill look, what else for builder?
0
 
cdc_sickleAuthor Commented:
What do you know, gotoxy exists and works like a charm... But i have to wait to see if it works right in turbo...
0
 
nietodCommented:
So where did you find it?  In Builder?  Its really not needed in builder since there are (better) alternatives in win32
0
 
cdc_sickleAuthor Commented:
Yeah, i dont have turbo at home... What are the better alternatives in builder?
0
 
nietodCommented:
Windows has a a large selection of console functions.  These allow you to position the cursor (like Gotoxy() does (although it is called SetConsoleCursorPosition()), but also to do MANY more things.  There are functions for scrolling the display, functions for ouputing text in various colors, or for change the colors of existing text.  There are functions for controlling the size of the cursor, hiding the cursor.  There are functions for outputing text in various ways, and functions for getting input in various ways.  There are even functions for resizing the consoel so it has a different number of rows or columns.  Basically there is just a wealth of functions to do fance things in Win32.  Many of these things can also be done in DOS, but it is often harder.

Builder probalby has help on these functions, if you look up "consoles" in the help.  (VC does.)

You can also look up some of the functions:

SetConsoleCursorPosition()
SetConsoleCursorInfo()
SetConsoleTitle()
WriteConsole()
WriteConsoleOutput()
WriteConsoleOutputAttribute()
SetConsoleMode()  (Important for games)
SetConsoleTextAttribute()

And about 30 or 40 more....

0
 
cdc_sickleAuthor Commented:
Works perfectly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now