Completly newbie question

N

Narf the Mouse

Within the past several weeks, I've been learning c++. To help me do
this, I'm porting a mostly-finished mini-roguelike.

What I'm wondering is if there's any way to tell the program to only
output characters at a certain point in the program.

Basically, the basic I was using had a 'Sync On' command and then
drawing operations would only happen on the 'Sync' command - Which
greatly sped things up.

I'm using window.h's console commands. Thanks.
 
M

Mike Wahler

Narf the Mouse said:
Within the past several weeks, I've been learning c++. To help me do
this, I'm porting a mostly-finished mini-roguelike.

What I'm wondering is if there's any way to tell the program to only
output characters at a certain point in the program.

Yes. Write your output statement(s) at that point.
Basically, the basic I was using had a 'Sync On' command and then
drawing operations would only happen on the 'Sync' command - Which
greatly sped things up.

I'm using window.h's console commands. Thanks.

None of that has anything to do with C++.

-Mike
 
A

Alan Johnson

Narf said:
So c++ has no way to syncronize drawing operations?

C++ doesn't even have drawing operations, so having a way to synchronize
drawing operations would be somewhat strange.
What I'm wondering is if there's any way to tell the program to only
output characters at a certain point in the program.

I'm not sure exactly what your goal is, but it seems like maybe what you
are trying to do could be accomplished by writing all your "output" to a
stringstream, and then dumping the stringstream to stdout at the last
second. Example:

#include <sstream>
#include <iostream>

int main()
{
std::eek:stringstream str ;

str << "Here is some output." << std::endl ;

// Do some stuff.

str << "Here is some more output." << std::endl ;

// Do some more stuff.

std::cout << str.str() ;

return 0 ;
}
 
N

Narf the Mouse

C++ doesn't even have drawing operations, so having a way to synchronize
drawing operations would be somewhat strange.

....So something like std::cout just dumps characters into whatever
version of windows you have? I'm really not sure what's going on, then.
I'm not sure exactly what your goal is, but it seems like maybe what you
are trying to do could be accomplished by writing all your "output" to a
stringstream, and then dumping the stringstream to stdout at the last
second. Example:

#include <sstream>
#include <iostream>

int main()
{
std::eek:stringstream str ;

str << "Here is some output." << std::endl ;

// Do some stuff.

str << "Here is some more output." << std::endl ;

// Do some more stuff.

std::cout << str.str() ;

return 0 ;

}

Thanks, that looks like it'll help speed things up.

To perhaps clarify a bit more, here's what the help files for
DarkBasicPro say about the 'sync' command: 'SYNC
This command is used to improve the performance of demanding programs
that require a consistent frame rate. This is especially true of games.
By default, sync is set to off which allows the system to automatically
handle screen refreshing. When SYNC ON is used, your program is
responsible for handling screen refreshing. You can refresh the screen
using the SYNC command. When you want the system to automatically
handle screen refreshing again, you can use the SYNC OFF command. By
placing the SYNC
command at the end of your main program loop, all drawing and refresh
tasks can occur in a single call. This dramatically increases the speed
and smoothness of graphical operations, allowing your programs to run
at their best. It is important to note the very first SYNC will only
render the back buffer and reveal the contents of that buffer on the
second SYNC command, as the system is based on a double buffered
refresh.'
 
N

Narf the Mouse

Alan said:
C++ doesn't even have drawing operations, so having a way to synchronize
drawing operations would be somewhat strange.


I'm not sure exactly what your goal is, but it seems like maybe what you
are trying to do could be accomplished by writing all your "output" to a
stringstream, and then dumping the stringstream to stdout at the last
second. Example:

#include <sstream>
#include <iostream>

int main()
{
std::eek:stringstream str ;

str << "Here is some output." << std::endl ;

// Do some stuff.

str << "Here is some more output." << std::endl ;

// Do some more stuff.

std::cout << str.str() ;

return 0 ;
}

One other question: How would I convert a char into a string? My map is
stored in a class array that contains a char. Thanks.
 
N

Neelesh Bodas

[[excessive quoting removed]
Please donot quote portions unrelated to your current post.
One other question: How would I convert a char into a string? My map is
stored in a class array that contains a char. Thanks.


char x = 'a';
string y (1,'a') // string y has 1 copy of character x.
assert(y == "a");
 
N

Narf the Mouse

Thanks for all the help, everybody - But cout'ing everything all at
once actually slowed it down.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top