Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learning Windows 8 Game Development
Learning Windows 8 Game Development

Learning Windows 8 Game Development: Windows 8 brings touchscreens to the tablet and PC. This book will show you how to develop games for both by following clear, hands-on examples. Takes your C++ skills into exciting areas of 3D development.

Arrow left icon
Profile Icon Quandt
Arrow right icon
₱1571.99 ₱2245.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (8 Ratings)
eBook Oct 2013 244 pages 1st Edition
eBook
₱1571.99 ₱2245.99
Paperback
₱2806.99
Subscription
Free Trial
Arrow left icon
Profile Icon Quandt
Arrow right icon
₱1571.99 ₱2245.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (8 Ratings)
eBook Oct 2013 244 pages 1st Edition
eBook
₱1571.99 ₱2245.99
Paperback
₱2806.99
Subscription
Free Trial
eBook
₱1571.99 ₱2245.99
Paperback
₱2806.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Learning Windows 8 Game Development

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. ...

Installing DirectXTK

We will use NuGet, a development package manager that comes with Visual Studio 2012 to install DirectXTK. Before this can happen, we need to ensure it is up-to-date using the Extensions and Updates dialog, found in the Tools menu. (Select Updates on the left side of the dialog.) Once it is up-to-date, we can use NuGet to install C++ packages. Right-click on your game project in Visual Studio and choose Manage NuGet packages. This will bring up the management dialog, where we can search for new packages. Search for DirectXTK and install the DirectX Tool Kit when it appears.

Once it finishes downloading, it will integrate with your project, allowing you to include any of the header files using the #include <file.h> directive.

If you want further information about the toolkit, visit http://directxtk.codeplex.com, which will let you access the source code as well as the feature list for the library. For this project we will only be using the following types:

  • SpriteBatch...

What a sprite is

Sprites and textures are pretty similar, but their differences appear when you look at what they do when the game is running. A texture is quite simply a 2D image that we can generate or load from the disk. In many cases, sprites are the same as textures, and you won't need to worry about them. Technically though, a sprite is a runtime representation of the image within the context of the game scene. This is because we can use parts of the texture (or multiple textures) as a sprite, giving the illusion of a complete image coming from a single texture. The difference really appears when you have sprite sheet-based animations (animations with each frame arrayed on the same texture).

Note

Sprites were originally images that sat on top of the frame buffer, seemingly integrated into the bitmap even though they were just layered on top. These days sprites just refer to individual images displayed to the player.

When you look at an animation, you will see a series of frames...

Textures

Textures store the image data we need to display on the screen. They represent a 2D array of pixels in memory that can be used for many different purposes, as you will see in this book.

Note

The pixels inside a texture are referred to as texels. We use this distinction because through filtering, scaling, and other transformations, we may lose the 1:1 mapping between a texel in the image and a pixel in the output frame buffer.

Textures also take up much of the memory available to a game, making it important that you apply techniques to reduce their size as much as possible when working on memory limited devices such as tablets or phones. Textures are generally stored on the GPU in special memory designed for quick access; however, on some platforms that memory is shared with the system memory, reducing the amount of space you have even further.

Note

GPU refers to Graphics Processing Unit. This is a piece of acceleration hardware that is designed to handle the mathematics required to...

Co-ordinate systems

We're using Direct3D to display our 2D world, which means we need to consider the differences between how we work with 3D and what we need for 2D, and adapt to make everything fit together. For our purposes DirectXTK will take care of most of this; however it's useful to know what's going on, and understand the concepts involved so that you can delve into advanced concepts in future to create some amazing visuals.

In 2D the world is represented as a Cartesian plane, with the X-axis representing the horizontal axis, and the Y-axis representing the vertical. Many 2D systems, including Direct3D and DirectXTK, position the co-ordinate (0, 0), also known as the origin, at the top-left corner of the screen.

Co-ordinate systems

2D and 3D

3D adds a third dimension, Z, to the mix, which represents the axis perpendicular to both X and Y, heading "away" from the viewer if you view the X/Y plane head on. When referring to the camera, this represents the depth of the image, and...

Installing DirectXTK


We will use NuGet, a development package manager that comes with Visual Studio 2012 to install DirectXTK. Before this can happen, we need to ensure it is up-to-date using the Extensions and Updates dialog, found in the Tools menu. (Select Updates on the left side of the dialog.) Once it is up-to-date, we can use NuGet to install C++ packages. Right-click on your game project in Visual Studio and choose Manage NuGet packages. This will bring up the management dialog, where we can search for new packages. Search for DirectXTK and install the DirectX Tool Kit when it appears.

Once it finishes downloading, it will integrate with your project, allowing you to include any of the header files using the #include <file.h> directive.

If you want further information about the toolkit, visit http://directxtk.codeplex.com, which will let you access the source code as well as the feature list for the library. For this project we will only be using the following types:

  • SpriteBatch...

What a sprite is


Sprites and textures are pretty similar, but their differences appear when you look at what they do when the game is running. A texture is quite simply a 2D image that we can generate or load from the disk. In many cases, sprites are the same as textures, and you won't need to worry about them. Technically though, a sprite is a runtime representation of the image within the context of the game scene. This is because we can use parts of the texture (or multiple textures) as a sprite, giving the illusion of a complete image coming from a single texture. The difference really appears when you have sprite sheet-based animations (animations with each frame arrayed on the same texture).

Note

Sprites were originally images that sat on top of the frame buffer, seemingly integrated into the bitmap even though they were just layered on top. These days sprites just refer to individual images displayed to the player.

When you look at an animation, you will see a series of frames displayed...

Textures


Textures store the image data we need to display on the screen. They represent a 2D array of pixels in memory that can be used for many different purposes, as you will see in this book.

Note

The pixels inside a texture are referred to as texels. We use this distinction because through filtering, scaling, and other transformations, we may lose the 1:1 mapping between a texel in the image and a pixel in the output frame buffer.

Textures also take up much of the memory available to a game, making it important that you apply techniques to reduce their size as much as possible when working on memory limited devices such as tablets or phones. Textures are generally stored on the GPU in special memory designed for quick access; however, on some platforms that memory is shared with the system memory, reducing the amount of space you have even further.

Note

GPU refers to Graphics Processing Unit. This is a piece of acceleration hardware that is designed to handle the mathematics required to...

Left arrow icon Right arrow icon

Key benefits

  • Use cutting-edge technologies like DirectX to make awesome games
  • Discover tools that will make game development easier
  • Bring your game to the latest touch-enabled PCs and tablets

Description

With the recent success of a lot of smaller games, game development is quickly becoming a great field to get in to. Mobile and PC games are on the rise, and having a way to create a game for all types of devices without rewriting everything is a huge benefit for the new Windows 8 operating system. In this book, you will learn how to use cutting-edge technologies like DirectX and tools that will make creating a game easy. This book also allows you to make money by selling your games to the world. Learning Windows 8 Game Development teaches you how to create exciting games for tablets and PC on the Windows 8 platform. Make a game, learn the techniques, and use them to make the games you want to play. Learn about graphics, multiplayer options, how to use the Proximity + Socket APIs to add local multiplayer, how to sell the game outright, and In-App Purchases. Learning Windows 8 Game Development guides you from the start of your journey all the way to developing games for Windows by showing you how to develop a game from scratch and sell it in the store.With Learning Windows 8 Game Development, you will learn how to write the code required to set everything up, get some graphics on screen, and then jump into the fun part of adding gameplay to turn a graphics sample into a proper game. From there, you'll look at how to add awesome features to your game like networking, motion controls, and even take advantage of new Windows 8 features like live tiles and sharing to make your players want to challenge their friends and keep playing. This book wraps up by covering the only way a good game can finish development: by shipping the game on the Windows Store. You'll look at the things to remember to make certification painless and some great tips on how to market and sell your game to the public.

Who is this book for?

Learning Windows 8 Game Development is for any developer looking to branch out and make some games. It's assumed that you will have an understanding of C++ and programming. If you want to program a game, this book is for you, as it will provide a great overview of Direct3D and Windows 8 game development and will kick-start your journey into 3D development.

What you will learn

  • Render sprites in 2D
  • Use touch, gamepad, mouse, and keyboard input to control the game
  • Learn the techniques to add multiplayer to your game
  • Add competition with accessible Windows 8 features
  • Use motion sensors and GPS to add unique gameplay
  • Master techniques to maximise your Windows Store effectiveness
  • Learn tips and tricks to pass store certification
  • Kick-start the next stage of gaming with 3D rendering

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 25, 2013
Length: 244 pages
Edition : 1st
Language : English
ISBN-13 : 9781849697453
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Oct 25, 2013
Length: 244 pages
Edition : 1st
Language : English
ISBN-13 : 9781849697453
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 5,613.98
Learning Windows 8 Game Development
₱2806.99
Learning C# by Developing Games with Unity 3D Beginner's Guide
₱2806.99
Total 5,613.98 Stars icon

Table of Contents

11 Chapters
1. Getting Started with Direct3D Chevron down icon Chevron up icon
2. Drawing 2D Sprites Chevron down icon Chevron up icon
3. Adding the Input Chevron down icon Chevron up icon
4. Adding the Play in the Gameplay Chevron down icon Chevron up icon
5. Tilting the World Chevron down icon Chevron up icon
6. Bragging Rights Chevron down icon Chevron up icon
7. Playing Games with Friends Chevron down icon Chevron up icon
8. Getting into the Store Chevron down icon Chevron up icon
9. Monetization Chevron down icon Chevron up icon
A. Adding the Third Dimension Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(8 Ratings)
5 star 37.5%
4 star 50%
3 star 0%
2 star 12.5%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




A. Tang Dec 11, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
For a book with a rather unassuming title, this book does a great job giving an in-depth technical dive into developing 2D games using DirectX 11.1 for the Windows 8 Metro/Modern interface.Throughout the book, the author presents comprehensive technical information and lessons in a coherent manner, and provides good explanation of the well-formatted code examples. I was pleased to find a good introduction for game loops, graphics, swap chains and the graphics pipeline.The author also uses to good effect, the DirectX Tool Kit that helps with writing DirectX 11 code in C++. Those experienced with developing games using XNA will find some familiar classes and patterns used throughout the book as well.The rest of the technical coverage on input, gameplay, sensors (accelerometer, gyroscope, inclinometer, GPS, light) are more than ample to help you include all the features you need in your own Windows 8 game. I also liked the more Windows 8-centric sections, such as Live tiles and sharing on new media.The book rounds off with good coverage on how to get your Win8 app on the Windows Store and other ways of monetizing (vs selling).Some gotcha's to watch out for: Microsoft has released Windows 8.1 and Visual Studio 2013 since the book was published, so you may find the templates described in the first chapters do not really match those you find in Visual Studio 2013. The good news though, is that the code samples from the website will open in Visual Studio 2013, and will compile and run. It would be nice if the author could update the website by providing a list of differences in working with VS2013 (the code and samples were built with Visual Studio 2012), so that folks can work through the examples using VS2013.In all, a good book that provides good, sound technical coverage into building a Windows 8 DirectX 11.1 game.
Amazon Verified review Amazon
John R Dec 11, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Obviously the gaming market has turned into all the craze over the passed few years. This has allowed for anyone who is interested read book like this one with the hopes of profits and success. In the book, Learning Windows 8 Game Development, you will learn how to extend your C++ skills to the game development world. This means you'll need some form of C++/programming skill beforehand to easily use this book.You'll learn how to use DirectX 11 to build a 2D space game throughout the entire book. Once you're on your way to completing your game development, the book also has a section on getting the game into the windows store and the way of selling successfully.My background is in iOS development and when I found this book, I was looking for a book with clear examples and sample code to help port my current game to the windows platform. I found that this book was useful for this accomplishment and I constantly reference it when I run into road blocks that relate the the examples they provide.If you are an applications developer but also want to get your hands dirty with game development on windows 8 platform, this is a good book to start off with!
Amazon Verified review Amazon
Gianandrea Terzi Jan 12, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm usually a bit skeptical toward books trying to explain such a broad argument from scratch : they all end up being too slow on unimportant details or too fast, overlooking some important steps that leave the reader lost from one chapter to another.Learning Windows 8 Game Development has been instead a great surprise. The reader is accompanied page after page by clear writing and examples and while the topics are far from easy (we're talking C++ here) I've seldom found myself asking for a better explanation.Of course some knowledge is required as no time will be spent explaining the language or the architecture but I would definitely recommend this book to anyone willing to undertake the rewarding (although bumpy at times) path of writing games on Windows 8.
Amazon Verified review Amazon
Rupert Hollom Jan 31, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Learning Windows 8 Game Development provides the reader with the knowledge to be able to start writing DirectX games for Windows RT, the code samples throughout the book are in C++. If you are coming from a C# background there will be some additional work involved in understanding the code.Starting with an introduction to the fundamentals of DirectX the book builds on this giving the reader the tools to start creating 2D games; 3D topics are briefly covered in an appendix. There are also sections detailing how to allow users to interact with popular social media sites and the different approaches to making money from your game.Overall a good starting point to learn about game development for the WinRT platform using DirectX and C++.
Amazon Verified review Amazon
Magnus Jan 17, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
After reading this book, overall I would say that I enjoyed it and found it useful. There is a lot of very good information on using the DirectX APIs and creating games from. Also, a plethora of info on the pipeline and the behind-the-scenes behavior of game rendering and display. I would say that this is a great read for anyone looking to get into making games and perhaps they don’t know where to start.That being said, that are a few things that readers should know; This book is based in C++ and you should have a very good handle on using C++ in windows development if you and going to attempt to use this book. Also, this book starts with 2d and sprites with limited 3d content.There is an entire section of the book aimed at the windows store marketplace; Submission, and purchase structures; this is highly valuable for even a veteran Game maker.Overall, I would recommend this book freely. It is worth it if you are interested in building Windows 8 store-styled games.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.