Posts: 121
Threads: 21
Joined: Oct 2005
I am trying to use what i have learned so far
and make some cheesy TEXT games
making opps functions and stuff
just to drill the basics in to my head!
but looking through both my books
and the net i cant find any info
on basic text manipulation on the screen!
like:
Locating text on the screen
clearing screen
coloring text
i was wondering is there a
built in C++ library to do all that
or do i have to make my own!
I'm sure i can make it my self
but coloring I haven't the foggiest how to change.
and i am surprised my books don't show me!
t is better to error on the side of caution
than the side of haste!!!
Posts: 677
Threads: 57
Joined: Jan 2005
system("CLS") will clear the screen (std:
ystem if you don't put using namespace std; at the start of the code
Code:
void text(string txt, unsigned short int x,unsigned short int y)
{
/////////////////////////////////////////////////////////////////////
// --Locate Text Function-- //
// Authors: gamehawk (gamehawk@myway.com) //
// Last Modified: 1-09-05 //
// http://s9.invisionfree.com/CPPgamedev/ //
///////////////////////////////////////////////////////////////////
int i;
for (i=1;i<y;i+=1){cout<<endl;}
string str="";
for (i=1;i<x;i+=1){str+=" ";}
txt=str+txt;
cout<<txt<<endl;
}
this will SORT OF locate a area on the screen.
Colouring text is quite similar to in FB/QB
Color 15 in Qb is the same as
std:
ystem("COLOR 15") in C++
I believe system and cout and stuff are in iostream ( #include <iostream )
url=http://www.sloganizer.net/en/]
[/url]
Posts: 121
Threads: 21
Joined: Oct 2005
thank you!
much appersiated
Just a nother small question!
dou you know of a REFRENCE for system!
in case there are other useful functions
or methods in system i could use?
t is better to error on the side of caution
than the side of haste!!!
Posts: 320
Threads: 9
Joined: Dec 2004
system( const char* ) just runs a command in the shell. There is no reference.
Also, text formatting and text positioning functions are not standard in C++ because they are device dependent; it's impossible to tell what the width/height of the device you're writing to is (if it has one at all) and it's not possible to tell the colouring mechanism used (e.g. ANSI colour codes in Linux).
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Posts: 602
Threads: 27
Joined: Oct 2004
see ncurses or pcurses for mingw.
quote="NecrosIhsan"]
[/quote]
Posts: 121
Threads: 21
Joined: Oct 2005
a test program:
that i found out, it is just using dos/batch file comands!
t is better to error on the side of caution
than the side of haste!!!
Posts: 320
Threads: 9
Joined: Dec 2004
By the way, is your name supposed to be spelt like that? It's not supposed to be 'psychowelder'?
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Posts: 121
Threads: 21
Joined: Oct 2005
yes Phyco(F-i-k-o) Welder!
t is better to error on the side of caution
than the side of haste!!!
why not try FB for simple text manipulation? >.> *spam..*
*spamspam..*
Posts: 677
Threads: 57
Joined: Jan 2005
Quote:why not try FB for simple text manipulation? >.> *spam..*
*spamspam..*
Because C++ is like a virus. Once it get's in your system you can't even look at FreeBASIC again...
url=http://www.sloganizer.net/en/]
[/url]