Jump to content
  • Advertisement
Sign in to follow this  
Somarl

Changing Fonts

This topic is 3027 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi this is a question regards to changing fonts and font colours etc in C++, i have spent a few days on google and reading through books and have to far only found a few completely different examples of which none seem to make sense or compile for me. I was hoping to be able to do things like this http://www.weiqigao.com/blog/images/turbo-cpp.png formatting wise. I dont believe that it can possibly be as difficult as some of the examples shown seem to be. Can anyone explain it in English for us complete new starters? So how to change the font style, and colour, and how to do all those fancy ascii symbols or lines and boxes etc.

Share this post


Link to post
Share on other sites
Advertisement
C++ itself doesn't deal with fonts at all and it doesn't deal with colors, text output or graphics. What you do is you include different libraries (DirectX/OpenGL for 3d Graphics, the Window System libraries for operating system functions like TCP-IP networking or opening windows to draw 2d or rendering text) and then call those libraries' functions using their C++ interface to do what you want to do.

Could you give some more details on what you actually want to do?

Share this post


Link to post
Share on other sites
Ahh, thanks for the reply first off. What im trying to do at the moment as me and a few friends are learning the basics, is just make a very simple program that asks for inputs, displays outputs, using random numbers etc etc.

Basically its a really simple combat system, just 3 types of attack. 1, 2 and 3 which lower the hitpoints of the program by a random number between x and y depending on what attack was used. We are expanding it so include other bits and bobs as it seems to be helping us at the moment to learn things like if statements, loops, variables and output etc etc. So nothing with 2d or 3d graphics as such.

Just literally want to display a welcome screen which is a bit like the turbo c++ welcome screen when you are installing it, that type of thing (only example i could think of sorry.) Then display things like the HP bar of each character in a coloured ascii block or something like the blocks on this http://en.wikipedia.org/wiki/File:Aa_example3.png so i can do a simple '10 block hp bar'

.....and perhaps colour the different parts of the text so things like "you attacked for" is white then "25 damage" is red or something.

Im sorry if this is vague but i am struggling to define what im after. If i cant change the font style then thats ok but there must be a way to display ascii and change the colour of the text easily of cout <<

Share this post


Link to post
Share on other sites
I don't know how the specific turbo-c++ example was done, but you can use curses for this. The font family is typically set by the terminal however, so there's not much you can do about that.

[Edited by - lightbringer on March 8, 2010 7:08:41 AM]

Share this post


Link to post
Share on other sites
Sorry i should have also said, im at the stage at the moment where i have pretty much just got past the hello world program (started on thursday). So not a lot of this makes sense to me just yet. Im not sure how to apply it i think is what i am saying.

Share this post


Link to post
Share on other sites
Quote:
Original post by Somarl
Sorry i should have also said, im at the stage at the moment where i have pretty much just got past the hello world program (started on thursday). So not a lot of this makes sense to me just yet. Im not sure how to apply it i think is what i am saying.


Maybe we can entice you to drop C++ and pick up a language that you can be immediately productive in, like Python? What are your long-term goals behind learning C++?

Share this post


Link to post
Share on other sites
hmm... so I guess your options are either using the console window (check this out on what you can do with it on windows : http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx )

or delve into GUI (graphical user interface) programming, which is more complicated at first, but for what you want to do you can probably use a library that already provides you with buttons, scrollbars, text-lists and such. My knowledge considering that is not very up-to-date I'm afraid, but if you are on windows, googling for MFC or Windows Programming tutorials (always assuming that windows is the OS you are developing under) will probably get you started

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
Quote:
Original post by Somarl
Sorry i should have also said, im at the stage at the moment where i have pretty much just got past the hello world program (started on Thursday). So not a lot of this makes sense to me just yet. Im not sure how to apply it i think is what i am saying.


Maybe we can entice you to drop C++ and pick up a language that you can be immediately productive in, like Python? What are your long-term goals behind learning C++?


:) i have a view to pretty much go "all the way" with this as far as game programming is concerned, im not talking about making next gen games or breaking new boundaries or even 'god forbid' making an MMO, we just want to make nice simple fun to play games, but not too simple. Standard RPG's, FPS's RTS's etc etc

We want to eventually start up a full blown game development studio (already have 4 coders and 1 guy for graphics and sound.) When the time comes (hopefully within 10 years) we will attract more people to our cause when we are ready to make our own project, for now i just take it one step at a time with the basics and such. So i just wanted to get down and dirty with C++ as once i have a good enough grasp on it you can pretty much make a computer sing and dance with it. If a company we create fails then at least ill have enough C++ experience to do other things with it.

I would also probably like to learn how to modify existing games engines to produce something worthwhile. I did a lot of research before choosing C++ as the language we would all use and it was mostly thanks to the great resources on this site that made me choose.

What im finding difficult at the moment is how many different ways you can do something but how none of them compile. So far i have found no less than 7 different ways of changing colour on the windows console, and yet none of them i understand at the moment nor do any of them seem to work for me as i am obviously not implementing then correctly.

Is there an easy solution to this? I only want to change the font colour a couple of times in a simple program. Oh and display a block which i think is ascii but im not sure how to do it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Somarl
I did a lot of research before choosing C++ as the language we would all use and it was mostly thanks to the great resources on this site that made me choose.

Great! Nothing is better than someone who's done their homework :)

Quote:
Original post by Somarl
Is there an easy solution to this? I only want to change the font colour a couple of times in a simple program. Oh and display a block which i think is ascii but im not sure how to do it.

The two solutions already presented in this thread should work for you. The simple one is what benryves described - not much extra is necessary. Curses is more involved - it's basically a graphics library for doing those "DOS windows".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!