XNA 4 3D Game Development by Example: Beginner's Guide

Create action-packed 3D games with the Microsoft XNA Framework with this book and ebook.

XNA 4 3D Game Development by Example: Beginner's Guide

Beginner's Guide
Kurt Jaegers

Create action-packed 3D games with the Microsoft XNA Framework with this book and ebook.
$29.99
$49.99
RRP $29.99
RRP $49.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849687089
Paperback322 pages

About This Book

  • Learn the structure of a 3D world and how to implement a variety of 3D techniques including terrain generation and 3D model rendering.
  • Build three different types of 3D games step-by-step, including a first-person maze game, a battlefield tank game, and a 3D sidescrolling action game on the surface of Mars.
  • Learn to utilize High Level Shader Language (HLSL) to add lighting and multi-texturing effects to your 3D scenes.

Who This Book Is For

This book is intended for readers who want to create 3D games using the XNA Framework. Basic knowledge of the C# programming language and 2D XNA concepts are helpful, but not required.

Table of Contents

Chapter 1: Introduction to XNA
System requirements
Installing the Windows Phone SDK
Time for action – installing Windows Phone SDK
Speller – Our first XNA game
Time for action – creating an XNA project
Managing content
Time for action – creating content assets
Member variables
Time for action – declaring new member variables
The Game1 constructor
Initialization
Time for action – customizing the Initialize() method
Loading content
Time for action – creating a square texture
Updating
Time for action – customizing the Update() method
The Draw() method
Time for action – drawing Speller
Helper methods
Time for action – words and letters
Time for action – completing the Speller project
Summary
Chapter 2: Cube Chaser – A Flat 3D World
Designing the game
Creating the project
Time for action – creating the Cube Chaser project
Our view of the world
Time for action – beginning the Camera class
The Projection matrix
Looking at something
Time for action – implementing a look-at point
The View matrix
Time for action – the View matrix
From the ground up
Time for action – creating the Maze classes
Drawing the floor
Time for action – drawing the floor
Moving around
Time for action – expanding the Camera
Time for action – letting the player move
Summary
Chapter 3: Cube Chaser – It's A-Mazing!
Maze generation
Time for action – defining a MazeCell
Time for action – generating the Maze class
Constructing the walls
Time for action – building walls
Time for action – drawing the walls
Solid walls
Time for action – bouncing off the walls
Summary
Chapter 4: Cube Chaser – Finding Your Way
The cube
Time for action – placing the cube
Time for action – rotating the cube
Matrices – big scary math things?
Positioning the cube
Time for action – randomly positioning the cube
Catching the cube
Time for action – catching the cube
Summary
Chapter 5: Tank Battles – A War-torn Land
Creating the project
Time for action – creating the Tank Battles project
An arc-ball camera
Time for action – the ArcBallCamera class – part 1
Time for action – finishing the ArcBallCamera class
Building the playfield
Time for action – generating the terrain
Time for action – adding the ReadHeightMap() method
Time for action – adding the BuildVertexBuffer() method
Time for action – the buildIndexBuffer() method
Let's see the terrain already!
Time for action – drawing the terrain
Adding texture – a gentle introduction to HLSL
Time for action – HLSL declarations
Time for action – Vertex Shader Input and Output definition
Time for action – the vertex shader
Time for action – the pixel shader
Time for action – utilizing Terrain.fx
Moving the camera
Time for action – moving the camera with the mouse
Summary
Chapter 6: Tank Battles – The Big Guns
Adding the tank model
Time for action – adding the tank model
Building tanks
Time for action – building the Tank class
Time for action – terrain heights
Time for action – tank animation
Time for action – positioning tanks
Summary
Chapter 7: Tank Battles – Shooting Things
Interface components
Time for action – creating the UIWidget class
Time for action – creating UITextblocks
Time for action – creating buttons
Time for action – adding the UIHelper class
Time for action – creating the UI
Time for action – responding to events
Time for action – ShotManager-part 1
Time for action – the Particle class-part 1
Time for action – finishing the Particle class
Time for action – the ParticleManager class
Time for action – building Particles.fx
Time for action – implementing particles
Summary
Chapter 8: Tank Battles – Ending the War
Managing game states
Time for action – implementing a title screen
Time for action – detecting hits
Managing turns
Time for action – managing turns
Visual improvements
Time for action – computing normals
Time for action – HLSL for lighting
Time for action – using ambient light
Time for action – multitexturing
Summary
Chapter 9: Mars Runner
Design of Mars Runner
Getting started with the GSM sample
Time for action – creating the Mars Runner solution
Time for action – customizing the BackgroundScreen class
Time for action – updating the menu
Time for action – creating the MarsRunnerPlayScreen class
A new camera
Time for action – the stationary camera
Creating the background
Time for action – creating a skybox
Building the Martian surface
Time for action – beginning the MarsTrack class
Time for action – generating the track
Time for action – drawing the track
Summary
Chapter 10: Mars Runner – Reaching the Finish Line
Abstracting support for 3D models
Time for action – the GameEntity class
Building the rover
Time for action –building the rover
Time for action – accepting user input
Animating the planet
Time for action – moving the world
Animating the rover
Time for action – animating the rover
Crashing into craters
Time for action – detecting craters
Adding an enemy
Time for action – the basic flying saucer
Time for action – flying the saucer
Shots and collisions
Time for action – Shot classes
Time for action – the ShotManager class
Time for action – enemy shots
Time for action – player shots versus aliens
Time for action – enemy shots versus the rover
Scoring
Time for action – scoring
Time for action – the GameOver screen
Sound effects
Time for action – building the SFXManager class
Time for action – playing sound effects
Summary

What You Will Learn

  • The core concepts of 3D graphics and how XNA describes the 3D world
  • Build a 3D maze that the player can explore in search of the mysterious spinning cube
  • Create 3D terrain based on a 2D height map image, adding texturing and lighting to the terrain’s surface
  • Load, display and animate 3D models
  • Build a button-based user interface overlay for your 3D game
  • Create a billboard particle system to produce dynamic explosions
  • Build a skybox to give your worlds full 3D backgrounds
  • Detect collisions between 3D objects and have your game react accordingly

In Detail

Move beyond the world of flat 2D-based game development and discover how to create your own exciting 3D games with Microsoft XNA 4.0. Create a 3D maze, fire shells at enemy tanks, and drive a rover on the surface of Mars while being attacked by alien saucers.

"XNA 4 3D Game Development by Example: Beginner's Guide" takes you step-by-step through the creation of three different 3D video games with Microsoft XNA 4.0. Learn by doing as you explore the worlds of 3D graphics and game design.

This book takes a step-by-step approach to building 3D games with Microsoft XNA, describing each section of code in depth and explaining the topics and concepts covered in detail.
From the basics of a 3D camera system to an introduction to writing DirectX shader code, the games in this book cover a wide variety of both 3D graphics and game design topics. Generate random mazes, load and animate 3D models, create particle-based explosions, and combine 2D and 3D techniques to build a user interface.

"XNA 4 3D Game Development by Example: Beginner's Guide" will give you the knowledge to bring your own 3D game creations to life.

Authors

Table of Contents

Chapter 1: Introduction to XNA
System requirements
Installing the Windows Phone SDK
Time for action – installing Windows Phone SDK
Speller – Our first XNA game
Time for action – creating an XNA project
Managing content
Time for action – creating content assets
Member variables
Time for action – declaring new member variables
The Game1 constructor
Initialization
Time for action – customizing the Initialize() method
Loading content
Time for action – creating a square texture
Updating
Time for action – customizing the Update() method
The Draw() method
Time for action – drawing Speller
Helper methods
Time for action – words and letters
Time for action – completing the Speller project
Summary
Chapter 2: Cube Chaser – A Flat 3D World
Designing the game
Creating the project
Time for action – creating the Cube Chaser project
Our view of the world
Time for action – beginning the Camera class
The Projection matrix
Looking at something
Time for action – implementing a look-at point
The View matrix
Time for action – the View matrix
From the ground up
Time for action – creating the Maze classes
Drawing the floor
Time for action – drawing the floor
Moving around
Time for action – expanding the Camera
Time for action – letting the player move
Summary
Chapter 3: Cube Chaser – It's A-Mazing!
Maze generation
Time for action – defining a MazeCell
Time for action – generating the Maze class
Constructing the walls
Time for action – building walls
Time for action – drawing the walls
Solid walls
Time for action – bouncing off the walls
Summary
Chapter 4: Cube Chaser – Finding Your Way
The cube
Time for action – placing the cube
Time for action – rotating the cube
Matrices – big scary math things?
Positioning the cube
Time for action – randomly positioning the cube
Catching the cube
Time for action – catching the cube
Summary
Chapter 5: Tank Battles – A War-torn Land
Creating the project
Time for action – creating the Tank Battles project
An arc-ball camera
Time for action – the ArcBallCamera class – part 1
Time for action – finishing the ArcBallCamera class
Building the playfield
Time for action – generating the terrain
Time for action – adding the ReadHeightMap() method
Time for action – adding the BuildVertexBuffer() method
Time for action – the buildIndexBuffer() method
Let's see the terrain already!
Time for action – drawing the terrain
Adding texture – a gentle introduction to HLSL
Time for action – HLSL declarations
Time for action – Vertex Shader Input and Output definition
Time for action – the vertex shader
Time for action – the pixel shader
Time for action – utilizing Terrain.fx
Moving the camera
Time for action – moving the camera with the mouse
Summary
Chapter 6: Tank Battles – The Big Guns
Adding the tank model
Time for action – adding the tank model
Building tanks
Time for action – building the Tank class
Time for action – terrain heights
Time for action – tank animation
Time for action – positioning tanks
Summary
Chapter 7: Tank Battles – Shooting Things
Interface components
Time for action – creating the UIWidget class
Time for action – creating UITextblocks
Time for action – creating buttons
Time for action – adding the UIHelper class
Time for action – creating the UI
Time for action – responding to events
Time for action – ShotManager-part 1
Time for action – the Particle class-part 1
Time for action – finishing the Particle class
Time for action – the ParticleManager class
Time for action – building Particles.fx
Time for action – implementing particles
Summary
Chapter 8: Tank Battles – Ending the War
Managing game states
Time for action – implementing a title screen
Time for action – detecting hits
Managing turns
Time for action – managing turns
Visual improvements
Time for action – computing normals
Time for action – HLSL for lighting
Time for action – using ambient light
Time for action – multitexturing
Summary
Chapter 9: Mars Runner
Design of Mars Runner
Getting started with the GSM sample
Time for action – creating the Mars Runner solution
Time for action – customizing the BackgroundScreen class
Time for action – updating the menu
Time for action – creating the MarsRunnerPlayScreen class
A new camera
Time for action – the stationary camera
Creating the background
Time for action – creating a skybox
Building the Martian surface
Time for action – beginning the MarsTrack class
Time for action – generating the track
Time for action – drawing the track
Summary
Chapter 10: Mars Runner – Reaching the Finish Line
Abstracting support for 3D models
Time for action – the GameEntity class
Building the rover
Time for action –building the rover
Time for action – accepting user input
Animating the planet
Time for action – moving the world
Animating the rover
Time for action – animating the rover
Crashing into craters
Time for action – detecting craters
Adding an enemy
Time for action – the basic flying saucer
Time for action – flying the saucer
Shots and collisions
Time for action – Shot classes
Time for action – the ShotManager class
Time for action – enemy shots
Time for action – player shots versus aliens
Time for action – enemy shots versus the rover
Scoring
Time for action – scoring
Time for action – the GameOver screen
Sound effects
Time for action – building the SFXManager class
Time for action – playing sound effects
Summary

Book Details

ISBN 139781849687089
Paperback322 pages
Read More