IntroductionThis article is just going to show you how to implement fonts into your game. The target is mostly for beginners. I will show you the easiest way(in my opinion) to do it. This tutorial will be in 16-bit Direct X and assumes that you have everything set up. It will use lpddsback as the back buffer. Setting it upFirst you want to make a new HFONT variable like so:
Then you want to fill in the with the CreateFont Function:
What that does is tell windows to use Arial with all the default values. The next step is creating a function to use this information Drawing TextMaking the function to draw text using GDI is straight forward enough so I will just show you the function:
Using all of thisNow I will show you an example of how to use all this to use fonts:
And that's all there is to it. You can change the font size by changing the 14 in the above example, and you can change the font face by changing the text in parentheses. For more information look in your compilers on-line documentation(assuming MSVC) for CreateFont. That will tell you what every parameter does.
Click here for a printable version of this article.
|