XNA 4.0 Workshop - Week 3

23. February 2011 16:43 by Jeromy Walsh in Game Developedia, User Input, Win Phone 7, Workshop, Xbox 360, XNA 4.0  //  Tags:   //   Comments (8)

Welcome to Week 3 of the XNA 4.0 Winter Workshop. As you no doubt have noticed, the workshop fell a bit behind. Due to work and real-life railroading me, I've been unable to convert code to XNA 4.0, post introductory articles, write review questions, or even respond to peoples' posts on the forums... Until NOW!

This marks the beginning of us being back on track again. As we've been sort of on chapters 4 and 5 for a couple weeks now, this will be a short week. You'll still have until the upcoming Sunday to complete the reading if you've not already done so, and then we'll move on to Week 4 on Monday.

With all that said, this week we officially move into the second sense, leaving sight behind and focusing on touch, both figuratively and literally.

This week's reading assignment is Chapter 5 from the textbook: "Handling Input to Move Our Camera". One important element of the title is that it implies we'll not only be learning how to use the User Input devices, but will also be using them to do something productive.

Creating a Game Service

The chapter begins with a discussion on creating game services. Game services, along with component oriented programming, allows us to decouple classes from one another in order to create a more pluggable architecture. By defining interactions between systems via interfaces, and then requesting services that implement those interfaces, we give ourselves the freedom to function with or without optional services, and also allow ourselves to substitute one implementation of a service for another when it benefits us to do so. 

Working with Input Devices

After the discussion on game services the chapter moves on to coverage of the different input devices in order to create our own input component and service. In specific, it addresses the Keyboard, GamePad, and Mouse input devices, highlighting that the Mouse is only available on Windows. 

At this point I feel it's important to note there's a few omissions in the book, due to changes from XNA 3.0 to XNA 4.0 as well as simple oversights. I'll go over these in supplemental tutorials I post in the coming days, but briefly...the Keyboard, through the use of a chat pad is accessible on the Xbox 360 in addition to the PC. To use the chat pad interface you must pass into the Keyboard.GetState() method an argument identifying which GamePad you'd like to access the chat pad of. Unfortunately, there's no way to determine if the GamePad actually HAS an attached chat pad.

The next big change from XNA 3.0 to 4.0 is the addition of the Windows Phone 7 as a supported device. This comes with it a slew of secondary changes. First, the Mouse API which was previously only usable on Windows is now supported on a second device. When using WinPhone7 the Mouse API can be used to get the primary touch point. Along similar lines, the brand new Input.Touch namespace and the associated classes can be used to access Gestures and multiple simultaneous touches. 

Also, while there's no classes directly within XNA to gain access to it, the Windows Phone 7 also has support for an accelerometer. However Silverlight, another library which is also accessible on the WinPhone 7, does have access to it through the Accelerometer class included in the Microsoft.Devices.Sensors assembly. You can add that as a reference to an existing WinPhone 7 XNA project and then use the Accelerometer class in order to treat the orientation of the phone as a form of input.

Another thing to note is that WinPhone7 has built in support for both hardware and virtual keypads. Unfortunately, as with the Xbox 360, there's no way to determine if the Windows Phone the user is on actually HAS a hardware keyboard or whether or not it's enabled. In general, Microsoft encourages the use of the SIP (Software Input Panel) which can be displayed via the Guide class in the GamerServices namespace.

And finally, XNA 4.0 adds support for Microphones. The Microphone can be used on all three consoles. For the PC it takes input from the primary input device. For the Windows Phone it uses the built-in microphone, and for the Xbox 360 it uses the Microphone on the headset accessory. In either case, the Microphone class, which is located in the Microsoft.Xna.Framework.Audio namespace can be used to capture voice audio for playback or other purposes directly in your games.

Creating Cameras & Split Screen

After coverage of the various XNA 3.0 supported input device, the chapter ends with an implementation of both a stationary camera as well as a first-person camera. The first-person camera is then used in the development of two demos, one called InputDemo, and one called SplitScreen.

The only difference between these two demos is SplitScreen has multiple viewports and thus allows the scene to be shown from two different viewpoints. On the Xbox 360 these two viewports are tied to gamepad 1 and gamepad 2 respectively and so simulates a split screen race car game, etc... With the transition from XNA 3.1 to XNA 4.0 Microsoft more closely aligned the XNA API with that of DirectX 11. As a result, it is no longer possible to clear regions of the current display buffer. As a result, migrating the code from XNA 3.0 to 4.0 required a few rendering changes.

I'll discuss those changes in a later tutorial.

Supplemental Reading

Below is a list of supplemental reading that might help this week's reading make more sense to you. I am likely to add to this list over the course of the week (or even the workshop) and will make an announcement when I've added additional reading or resources.

[none]

XNA 4.0 Source Code

In this week's reading I again migrated the code from XNA 3.0 to 4.0. Feel free to compare the code I've provided below with that which was originally on the companion disk to see the differences. I will also be providing a more in-depth explanation in a future tutorial. One other thing I wanted to note, per Chad's request over twitter, I've excluded the art assets from the downloads. In order to get the below source code to work, you'll need to copy the required textures into the Content folders.

Discussion

Please use the Week 3 XNA 4.0 Workshop Forums for any discussion of this week's reading.

XNA 4.0 Winter Workshop 2011 Topics

23. November 2010 09:52 by Jeromy Walsh in Game Developedia, XNA 4.0  //  Tags:   //   Comments (13)

I've just about finished the outline for the XNA 4.0 Winter Workshop, but am still interested in hearing more about the topics other people would covered. Since I've not published the outline yet I thought I'd take a moment and get people's feedback.

If you have time, please post a comment indicating which topics within the realm of XNA 4.0 (or general game development) you'd be interested in. For example...

  • 2D Rendering Pipeline
  • 3D Rendering Pipeline
  • HLSL
  • Audio
  • Networking
  • State Management
  • Storage
  • etc...

And of course, if you have something you'd like covered which does not fit neatly into a category listed above, feel free to describe what you'd like to learn and I'll do my best to work it in.

Workshop outline and signup form coming soon!

Re: Sample Code Not Working with XNA 4.0 [Release]

11. November 2010 09:04 by Jeromy Walsh in Game Developedia, XNA 4.0  //  Tags:   //   Comments (0)

Thanks to Scott Ratushny who emailed me to let me know my code samples weren't working. Tutorials 1-5 were all built with the Beta version of XNA 4.0, so all my old tutorials would not build with the release version of XNA.

I've updated all of my previous projects to point to the correct assemblies. So if you tried downloading the demos before and found they would not compile, try again, they should work now.

Thanks again, Scott!

Announcing the 2011 XNA 4.0 Workshop

9. November 2010 07:03 by Jeromy Walsh in C#, Game Developedia, Win Phone 7, Xbox 360, XNA 4.0  //  Tags:   //   Comments (40)

Starting this coming January I will once again be running one of my GameDev.net workshops! Due to growing interest and the recent release of XNA 4.0, this workshop will be on XNA 4.0, including coverage of WinPhone 7 development. Unlike my previous workshops, this one will require previous C# programming experience. Additionally, a basic understanding of game programming and linear algebra (vectors, matrices, transforms) is highly recommended.

XNA Workshop Overview (Start Date: January 17, 2011)

This workshop is designed to aid people in their journey to learn XNA. This workshop is targeted at highly motivated individuals who are interested in learning XNA or who have attempted to learn XNA in the past, but found that without sufficient support and mentoring they were unable to connect all the pieces of this highly complex but powerful Framework. This is a guided workshop. Each student is responsible for taking the time to read the material and learn the information. The community and tutors that arise out of this workshop are here for making the learning process run more smoothly. Because everyone will be working from the same source materials, students may find it easier to get answers to the specific questions they might have. There is no minimum age requirement, however all participants should have at least mastered Algebra, Geometry, and some Matrix/Vector mathematics.

Additionally, this workshop does not attempt to defend XNA as a Framework, nor does it attempt to demonstrate that XNA is either more or less useful than other API's for any particular purpose. People who intend to start a discussion about the differences between XNA and ANY other API (except as are relevant to a particular topic), are encouraged to do so elsewhere. This workshop is for educational, not philosophical discussions.

XNA Workshop Summary

1. Anyone interested in participating will be asked to sign up here on Game Developedia so I can keep track of who's following along and send out announcements if necessary. The signup sheet will be provided in December.

2. Anyone interested in participating will purchase a copy of Chad Carter's Microsoft XNA Game Studio 3.0 Unleashed.

3. Anyone interested in participating will download and install XNA Game Studio 4.0 and Visual C# 2010 Express Edition. (Or another edition)

4. Each week, participants will be responsible for reading the designated chapters of the text and the accompanying tutorials provided here.

5. As people have questions on a chapter they may post them in our weekly chapter forums, located in the XNA Workshop Forum of GameDev.net. These forums will be created in early January. More advanced XNA programmers may post additional questions or exercises to help test the other students' understanding of the material.

6. Each week students should submit their answers to the quiz questions which will be provided here on Game Developedia. Quizzes will be computer graded, so you can determine how well you're grasping the information.

7. Every four weeks there will be a programming project due (see below) - designed to test a student's understanding of the previous four weeks. Students should complete these projects and upload the source code to our project database for peer review and feedback.

XNA Workshop Text

Microsoft XNA Game Studio 3.0 Unleashed.

After looking around at various XNA books, Chad's book seems to be the most well-rounded, covering both 2D and 3D technologies, creating some sample projects, and in general providing good coverage of the framework. As you've no doubt noticed, Chad's book is based on XNA Game Studio 3.0. To make the information relevant to XNA 4.0, and to cover the new features of XNA 3.1 and 4.0 which are not present in his book, I will be providing supplemental tutorials here on Game Developedia.

Weekly Chapter Threads

As with my GameDev.net C# Workshop, an XNA Workshop Forum will be created and each week a sub-forum will be added that can be used to post your questions and answers for the current week's reading assignment. People who come late to the workshop can catch up by reading over the previous threads and continuing to post their new questions.

The weekly chapter forums will have an introduction thread which will be mirrored (and stickied) in the "DirectX and XNA" forum on GameDev.net The first post of each weekly thread will be structured with a brief introduction to the workshop, and provide links back to the XNA Workshop Forum and this blog so that people can easily navigate and follow the conversation of the current week.

Monthly Project Threads

Forums will be created for each of the Monthly Projects where the first post outlines the details and requirements of the project. People can then use those forums to discuss the project, get design ideas, and ask questions.

While the full details of how this will be accomplished are not yet hammered out, participants will be able to upload their projects for analysis and peer review. Projects will not be graded, however promising projects will receive some kind of notoriety. 

Timeline

The workshop will begin January 17th, and is estimated to run for 16 weeks, allowing some leeway for any setbacks due to my own schedule, or delays due to people needing more time to complete projects, etc...

As always, feel free to provide feedback about the XNA workshop proposal within this thread. Specifically, I'm interested in hearing what kind of projects you'd like to see, and how eager you are to start. =)

May, 2010 Update

31. May 2010 20:18 by Jeromy Walsh in Game Developedia  //  Tags:   //   Comments (0)

Hi All!

It's the curse of all new blog owners to succumb to real-life issues just as they obtain the necessary motivation to start their own blog and/or tutorial website. It seems I'm no exception. (There really should be a named law for it)

Since my last blog post I have been hired by the DigiPen Institute of Technology as a Part-Time Teacher and Part-Time Recruiter, bought and moved into a new house, and had my entire family come down with Salmonella induced food-poison. This included roughly 2-4 hours straight of vomiting, fever, and cold-sweats, followed by 2-3 days of...err... lots of bathroom trips. So yeah, it's been a busy month.

But, with all that aside, I'm back on blog/tutorial duty so you can look forward to a new tutorial within a few days. As I previously advertised, the next tutorial will be on color blending.

Cheers!
Jeromy

The Four Elements Tutorial Series

26. April 2010 08:56 by Jeromy Walsh in 3D Graphics, Game Developedia, XNA 4.0  //  Tags:   //   Comments (4)

This blog post serves as an announcement for my next tutorial series - the Four Elements Series. With the Intro to XNA series well underway (and Tutorial 5 coming soon), readers will soon be armed with all the techniques they need to render and interact with a basic 3D environment. So why not add an environment! The Four Elements Series aims to be a walkthrough of the creation of the four elements commonly associated with video game environments; specifically: Earth, Air, Water, and Fire.

Each element represents a domain of topics which, when combined with the others, comprises all of the non-biological components that make up a typical 3D environment. Here's the specifics:

  • Earth - Terrain
  • Air - Sky, Clouds, & Time of Day
  • Water - Uh, Water, duh.
  • Fire - Particle Effects (Fire, Snow, Rain, etc...)

Each tutorial in the series will address part of one of the four elements, and will build on previous tutorials in the series. Upon completion of the series, readers will posses a complete XNA library for rendering 3D environments, as well as some nifty tools to help in the creation of said environments.

Stay tuned for more information on the Four Elements Tutorials!

In-Depth Look at XNA 4.0

11. April 2010 10:49 by Jeromy Walsh in Game Developedia  //  Tags:   //   Comments (0)

With the imminent arrival of XNA 4.0 and my current WinPhone 7 project well under way, I decided that my first real topic would be an in-depth look at the differences between XNA 3.1 and 4.0. In my first attempt at this I loaded up .NET Reflector and the documentation for 3.1 and 4.0 and did a side-by side comparison in order to come up with a list of missing and new classes, as well as changes to the members of each of the major classes. Wow, was that boring! Who wants to read a blog post with a bunch of class lists? So it became clear to me I had to think up a fun way to explore the new content in XNA 4.0, as well as the major changes that was a bit more interactive and interesting.

My answer is to revisit an old project I did on GameDev.net, which was to implement the NeHe OpenGL tutorials in XNA. This was done back in 2007 so it used XNA 2.0, and I only managed to get through the first 10 or so projects. But 3 years later I've got a second child, a commercial WinPhone 7 project, and I'm trying to get a job. So I've got plenty of free time and should have no problem completing all 48 tutorials. Undecided

Stay tuned for the next post when I take a high-level look at the project changes in XNA 4.0 and provide you with Project 1: Setting up an XNA Window! (As XNA is a wrapper around WinForms, this'll be a REALLY easy project).

Welcome to Game Developedia!

9. April 2010 09:23 by Jeromy Walsh in Game Developedia  //  Tags:   //   Comments (0)

Game Developedia is my personal blog and tutorial website, which will focus on all areas of game development; including...

  • XNA
  • DirectX 9, 10, & 11
  • Mathematics
  • Physics & Animation
  • Artificial Intelligence
  • Networking
  • Computer Architecture
  • IO & Storage
  • User Input
  • Audio
  • The Game Industry
  • Tools & Asset Management
  • C#/C++/Java
  • .NET/MSIL
  • SQL
  • Silverlight
  • Threading
  • Win Phone 7/Xbox 360/PC Development
  • XAML/WPF

Phew! That's a long list. But those are all of my areas of interest within game development and computer science. I may occasionally (frequently) throw in some personal anecdotes about other life issues as well.

The next questions to answer may be, "How do you plan to fill this blog with content? Where will you get your inspiration?"

Those are valid question. The answers are: slowly, and from a number of different places. First, I intend to write some detailed tutorials covering some of the more esoteric and less understood areas of computer graphics, threading, and computer architecture. I may even dig into network programming, but I'll admit that's not my strongest area. But I've often heard the best way to learn is to teach. So maybe we'll learn some network programming together.

In addition to the tutorials I plan to write, I'll also be pulling problems from some of my existing projects. As I encounter things which I find difficult, confusing, or otherwise noteworthy, I'll post about it here on my blog.

And finally, I frequent a number of community websites for game development, including GameDev.net where I'm a moderator, as well as The XNA Creators Club where I'm considered a virtual noob due to my lack of frequent posting. Often times, especially on the Creators Club, people ask questions which are promptly answered, but which I feel I either have a different answer for, or I'd like to expound upon without seeming overly pedantic. In those cases, I'll bring the topic of the forum post here to my blog and answer it myself.

Well, that gives you all an idea of what kind of topics I'll be posting about, as well as where I plan to get my inspiration from. As for posting frequency, I plan to post every couple of days. Generally speaking, the more frequent postings will come from forums or my own problems, while tutorials will come less frequently.

And as a last note, this blog theme is temporary. I've got the source code for the blog engine, as well as a set of themes I'm pulling from for inspiration, so in the coming weeks I'll be making tweaks to the software, and merging some concepts together to create my own, unique theme for the blog. 

So stay tuned!

About the author

Jeromy Walsh is a professional game programmer with multiple credited and uncredited AAA game titles. Jeromy's primary area of expertise is in Tools/Engine development, though he likes to fiddle with other areas as well.

Month List