Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Microsoft XNA 4.0 Game Development Cookbook
Microsoft XNA 4.0 Game Development Cookbook
Microsoft XNA 4.0 Game Development Cookbook
Ebook690 pages3 hours

Microsoft XNA 4.0 Game Development Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

“Microsoft XNA 4.0 Game Development Cookbook” is a fast-paced cookbook for taking your knowledge of the framework further with advanced game development tasks. Packed with step-by-step instructions and screenshots, the book will solve an experienced developer’s everyday coding problems. If you are an XNA developer who has already successfully mastered simple 2D and 3D XNA tasks, dive into “Microsoft XNA 4.0 Game Development Cookbook” for something more challenging. You should be comfortable with the basics of the XNA framework, and have experience with C#.
LanguageEnglish
Release dateJun 25, 2012
ISBN9781849691994
Microsoft XNA 4.0 Game Development Cookbook

Related to Microsoft XNA 4.0 Game Development Cookbook

Related ebooks

Information Technology For You

View More

Related articles

Reviews for Microsoft XNA 4.0 Game Development Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Microsoft XNA 4.0 Game Development Cookbook - Luke Drumm

    Table of Contents

    Microsoft XNA 4.0 Game Development Cookbook

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why Subscribe?

    Free Access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Errata

    Piracy

    Questions

    1. Applying Special Effects

    Introduction

    Creating shadows within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating shadows within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Implementing lens flare within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Implementing lens flare within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    Implementing smoke within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating explosions within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating explosions within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also...

    2. Building 2D and 3D Terrain

    Introduction

    Displaying hexagonal maps

    Getting ready

    How to do it...

    How it works...

    There's more...

    Displaying 2D isometric maps

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Importing and displaying 3D isometric maps

    Getting ready

    How to do it...

    How it works...

    Generating 3D height maps

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating block worlds within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Textures

    Creating block worlds within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    3. Procedural Modeling

    Introduction

    Modeling triangles

    Getting ready

    How to do it...

    How it works...

    There's more...

    Dynamic vertex buffers

    See also

    Modeling discs

    Getting ready

    How to do it...

    How it works...

    See also...

    Modeling spheres

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Modeling tori

    Getting ready

    How to do it...

    How it works...

    See also

    Modeling trees

    Getting ready

    How to do it...

    How it works...

    There's more...

    4. Creating Water and Sky

    Introduction

    Creating water within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Shallow water

    Deep water

    Building skyboxes within the Reach profile

    Getting ready

    How to do it...

    How it works...

    Building skyboxes within the HiDef profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Cloud generation within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    Billboarding

    See also

    5. Non-Player Characters

    Introduction

    A* pathfinding

    Getting ready

    How to do it...

    How it works...

    There's more...

    Distance estimation

    See also

    Character state machines

    Getting ready

    How to do it...

    How it works...

    There's more...

    Scripting

    Animation

    See also

    Constructing dialogue

    Getting ready

    How to do it...

    How it works...

    There's more...

    Scripting

    See also

    Decentralizing behavior

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    6. Playing with Animation

    Introduction

    Applying animation with SkinnedEffect

    Getting ready

    How to do it...

    How it works...

    Motion capture with Kinect

    Getting ready

    How to do it...

    How it works...

    There's more...

    Under voice command

    Integrating rag doll physics

    Getting ready

    How to do it...

    How it works...

    There's more...

    Part time action

    Rendering crowds

    Getting ready

    How to do it...

    How it works...

    There's more...

    7. Creating Vehicles

    Introduction

    Applying simple car physics

    Getting ready

    How to do it...

    How it works...

    There's more...

    Getting more physical

    See also

    Implementing simple plane controls

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Rendering reflective materials within the Reach profile

    Getting ready

    How to do it...

    How it works...

    There's more...

    The cost of reflecting

    See also

    8. Receiving Player Input

    Introduction

    Adding text fields

    Getting ready

    How to do it...

    How it works...

    There's more...

    On the phone

    Creating dialog wheels

    Getting ready

    How to do it...

    How it works...

    There's more...

    Dragging, dropping, and sliding

    Getting ready

    How to do it...

    How it works...

    There's more...

    9. Networking

    Introduction

    Connecting across a LAN

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Connecting across the Web

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Synchronizing client states

    Getting ready

    How to do it...

    How it works...

    There's more...

    Index

    Microsoft XNA 4.0 Game Development Cookbook


    Microsoft XNA 4.0 Game Development Cookbook

    Copyright © 2012 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: June 2012

    Production Reference: 1130612

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-84969-198-7

    www.packtpub.com

    Cover Image by Sandeep Babu ( <sandyjb@gmail.com> )

    Credits

    Author

    Luke Drumm

    Reviewers

    Jason Mitchell

    Kenneth Dahl Pedersen

    Acquisition Editor

    Stephanie Moss

    Lead Technical Editor

    Kedar Bhat

    Technical Editors

    Rati Pillai

    Ankita Shashi

    Copy Editor

    Insiya Morbiwala

    Project Coordinator

    Michelle Quadros

    Proofreader

    Joel T. Johnson

    Indexer

    Rekha Nair

    Production Coordinator

    Melwyn Dsa

    Cover Work

    Melwyn Dsa

    About the Author

    Luke Drumm is an experienced software developer and consultant who wrote his first computer game at age 10, and has been enthusiastically exploring the world of game development ever since. With the first public release of XNA in 2006, Luke quickly latched onto the technology and began creating and talking about how to create games within XNA at every possible opportunity. This culminated in his regular presence at conferences, game camps, and user groups, and in his becoming a recipient of the Microsoft MVP Award, for XNA and DirectX, for at least four successive years. Luke lives in Sydney, Australia, with his amazing, patient, and supportive wife Cheryl, and two dogs, who may or may not rule the roost.

    About the Reviewers

    Jason Mitchell is a passionate .NET developer and an independent game development enthusiast. He has worked with Microsoft's XNA Game Studio since its initial release and has experience using it to create games on Windows, Xbox 360, and Windows Phone.

    Kenneth Dahl Pedersen, now aged 35, has been programming basically since he got his first computer at age 6, starting on the Commodore 64, with small programs that could do next to nothing. This quickly evolved when he migrated to the much more powerful Amiga 500 with some demos and light applications, and finally culminated when he got his first PC.

    Since then, game development has held his interest in a vice grip, and Kenneth has studied numerous programming languages and APIs for this purpose. His repertoire includes C/C++, OpenGL, DirectX, C#, WPF, WCF, MDX, and XNA.

    With the appearance of readily-available, high-end engines, such as Unreal Development Kit, Kenneth found another interest to keep him well-sated in his thirst for game development knowledge, UnrealScript, providing another mountain top to climb.

    Kenneth is a Systems Analyst and Developer. Originally from Denmark, where he still works, he now lives in Sweden with his wife and baby daughter.

    Other than being with his wife and daughter, he uses his spare time for game development, seeking new knowledge and dabbling in 3D visual arts in applications, such as 3D Studio Max and ZBrush. And of course, Kenneth is an avid gamer. After all, you cannot make games if you don't enjoy playing them!

    First of all, I would like to thank my wife, Nina, for the patience she's shown me while I was doing this review. I have probably not been as helpful around the house as I should have been, while this was going on.

    My beautiful daughter, Nadia, for always giving me a reason to smile and laugh.

    And last, but certainly not least, Michelle Quadros, for believing in me and giving me this incredible experience and opportunity to do a tech review of this awesome book on XNA.

    My advice to you, the Reader: Read it, cover-to-cover. You will not regret it, as it contains some absolute treasures of tips and techniques for your own game projects.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    You might want to visit www.PacktPub.com for support files and downloads related to your book.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    http://PacktLib.PacktPub.com

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

    Why Subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print and bookmark content

    On demand and accessible via web browser

    Free Access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

    Preface

    The Microsoft XNA 4.0 Game Development Cookbook is all about what happens once you've completed the various introductory tutorials, and want to create something with a little more substance.

    In this book, you'll find examples of how to flesh out some of the more complex, or initially less intuitive, pieces of what goes into a full-blown game.

    Not sure what it takes to add water to your Xbox 360 Indie game? Confused about maps for your Windows Phone game? Curious over what it takes to get started using Kinect with XNA? Then this book may just be for you.

    What this book covers

    Chapter 1, Applying Special Effects: Discover the principles behind some common special effects used in big budget titles, and add them to your own games.

    Chapter 2, Building 2D and 3D Terrain: Learn some of the tricks behind creating landscapes in both two and three dimensions.

    Chapter 3, Procedural Modeling: Explore what's involved in creating models in code, instead of using an external 3D modeling package.

    Chapter 4, Creating Water and Sky: Add depth to your worlds with some virtual atmosphere.

    Chapter 5, Non-Player Characters: Inhabit your virtual worlds with characters that can move and interact in intelligent and interesting ways.

    Chapter 6, Playing with Animation: Have a peek into some of the ways that animation can be both produced and displayed.

    Chapter 7, Creating Vehicles: Launch your players onto the roads or into the skies with the addition of vehicles.

    Chapter 8, Receiving Player Input: Discover how your players can drag, drop, point, and type their way through your games.

    Chapter 9, Networking: Expand your virtual world across to the real one by adding the ability to communicate.

    What you need for this book

    To write games using the examples presented in this book, you'll need:

    Windows Vista (SP2) or later

    XNA Game Studio 4.0 (usually bundled as part of the Windows Phone SDK) or later

    For the Kinect-based recipe, a Kinect or Kinect for Windows unit is required along with the Kinect for Windows SDK.

    Who this book is for

    If you are an XNA developer who has already successfully dabbled in some of the simple 2D and 3D functionality provided by XNA, and are eager to find out how to achieve some of the more advanced features presented in popular games, dive into the Microsoft XNA 4.0 Game Development Cookbook for an example-based approach that should have you safely on your way towards the next level of game creation. You should be comfortable with the basics of the XNA framework and have experience with C#.

    Conventions

    In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

    Code words in text are shown as follows: We will be using the BasicEffect class in this example, but any effect that implements the IEffectMatrices interface and has some way to darken the rendered model should be adequate.

    A block of code is set as follows:

    Vector3 lightDirection;

    BasicEffect reachShadowEffect;

    Matrix flattenShadow;

    New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: Start by adding a new Content Pipeline Extension project to the solution.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

    To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title through the subject of your message.

    If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

    Piracy

    Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

    Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.

    We appreciate your help in protecting our authors, and our ability to bring you valuable content.

    Questions

    You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.

    Chapter 1. Applying Special Effects

    In this chapter we will cover:

    Creating shadows within the Reach profile

    Creating shadows within the HiDef profile

    Implementing lens flare within the Reach profile

    Implementing lens flare within the HiDef profile

    Implementing smoke within the Reach profile

    Creating explosions within the Reach

    Enjoying the preview?
    Page 1 of 1