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

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
主站蜘蛛池模板: 阜平县| 时尚| 齐河县| 轮台县| 石台县| 余干县| 贺州市| 翁源县| 陆良县| 河间市| 东城区| 滦平县| 疏勒县| 祁阳县| 衢州市| 七台河市| 岢岚县| 江山市| 手游| 邻水| 河间市| 雷州市| 桐梓县| 叙永县| 蛟河市| 武功县| 奉节县| 牙克石市| 子长县| 宣恩县| 贵南县| 潼南县| 花莲县| 湖北省| 平谷区| 扶沟县| 治多县| 泸州市| 花莲市| 浦城县| 大埔县|