Solved

Game Programming Output

Posted on 2000-04-12
14
210 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
[X]
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
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

617 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