官术网_书友最值得收藏!

Chapter 2. Drawing 2D Sprites

Some newer independent games make use of only audio or other feedback systems to convey the game state to he player; however, most games still use the tried and true method of showing the game to the user through a graphical representation. To really get started, we need to be able to put something onto the screen for the player. In this chapter we will do just that. We'll look at how to load the images from files on disk, and then display them on the screen, in 2D through a 3D API.

One of the best things you can do to make your life easier when writing code is rely on the efforts of others before you. Many thousands of people have written 2D rendering algorithms before this book was even written, and their learnings and efforts should not be wasted by scrapping all of that information and starting from scratch. Microsoft provides an open source library that tries to collect this information and give you a head start in developing your game. DirectXTK is a small library designed to do all of these common tasks for you. We'll be using this to simplify the task of loading textures from disk, rendering them onto the screen, and working with fonts to display some text on the screen.

Through the course of this chapter we will add the ability to draw images and text. We'll start by learning how to load in textures and draw them to the screen using DirectXTK. After that, we will look at text rendering and how to add that functionality to the game for future use. By the end of the chapter, you should have some images and text on screen, ready for gameplay.

In this chapter you will:

  • Download and build DirectXTK
  • Learn about sprites and textures
  • Understand co-ordinate spaces and projections
  • Learn about texture formats
  • Discover how to load textures
  • Draw some sprites to the screen
  • Learn about text rendering
  • Render some text to the screen
主站蜘蛛池模板: 游戏| 惠安县| 珠海市| 镇原县| 丰台区| 万年县| 祁东县| 盐边县| 南江县| 白玉县| 永平县| 长沙市| 宝应县| 米泉市| 耒阳市| 贵南县| 山阳县| 乌拉特中旗| 梧州市| 乌拉特后旗| 海丰县| 曲周县| 元朗区| 夏津县| 鄂托克前旗| 海原县| 巴林右旗| 疏勒县| 天门市| 临夏市| 黄大仙区| 万安县| 河池市| 浦北县| 泌阳县| 忻城县| 开封市| 阿克陶县| 腾冲县| 尼木县| 略阳县|