Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Game Programming Output

Posted on 2000-04-12
14
207 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

839 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