Solved

Game Programming Output

Posted on 2000-04-12
14
208 Views
Last Modified: 2010-04-02
How can i ouput stuff with out refreshing the screen and reouput... (SPACE INVADERS) No Graphics, all text based!!!
0
Comment
Question by:cdc_sickle
  • 8
  • 6
14 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 2708564
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
 

Author Comment

by:cdc_sickle
ID: 2709449
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
 

Author Comment

by:cdc_sickle
ID: 2709453
By the way, my home system has borland builder 1.0, win98
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 2709494
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
 

Author Comment

by:cdc_sickle
ID: 2709516
Turbo C++ Since that is what im supposed to work in :(
0
 
LVL 22

Expert Comment

by:nietod
ID: 2709668
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
 

Author Comment

by:cdc_sickle
ID: 2709679
And this wont work in borland?
0
 
LVL 22

Expert Comment

by:nietod
ID: 2709707
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
 

Author Comment

by:cdc_sickle
ID: 2709719
Ill look, what else for builder?
0
 

Author Comment

by:cdc_sickle
ID: 2709945
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
 
LVL 22

Expert Comment

by:nietod
ID: 2710101
So where did you find it?  In Builder?  Its really not needed in builder since there are (better) alternatives in win32
0
 

Author Comment

by:cdc_sickle
ID: 2710108
Yeah, i dont have turbo at home... What are the better alternatives in builder?
0
 
LVL 22

Expert Comment

by:nietod
ID: 2710149
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
 

Author Comment

by:cdc_sickle
ID: 2713500
Works perfectly
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question