« Blender Review | Main | XNA The Big Picture »
Monday
Jan052009

Review Learn Programming Now! XNA Game Studio 2.0 by Rob Miles

This was the very first XNA book I bought and I'm glad it was my first.  Based upon the 5-6 XNA books I've purchased and read, this book is the most beginner oriented.  Rob Miles does a nice job of trying to hand hold you through basic Object Oriented concepts yet also rapidly getting you involved in XNA code so you can do something exciting.  When I read books of a technical nature, I realize that most of what I read will be forgotten but exposing my brain to the ideas over and over eventually has an effect.  My point is the real value in a lot of technical books is as a reference source.  When you start developing your first project, you'll run into all sort of road blocks.  Hopefully you'll remember reading something in one of your books that provided a solution.  My strategy is I use sticky notes as page markers.  I write on them and place them on the page sticking out the top so I can easily see my note outside of the book.  Later on when I run into a problem, I can quickly browse through my sticky notes to try and find a solution.

Some of my notes include Gamepad Input, joystick vibration, filling the screen, fake 3D text, arrays, keyboard, using a struct to define an object.

Mr. Miles  walks you the development of several simple 2D games.  I particularly liked the Bread & Cheese game which he expands with Tomotoes.  For some reason, I understood how this game was organized.  It was simple, straight forward and became the structural basis for my first game project.

Based upon the XNA books I've read, about 6 at this point, this is the best beginner book for learning XNA.  One reason is that Mr. Miles avoids some of the pitfalls of other books by steering clear of multi-class projects and projects that mix Game Components with classes.  These are very confusing structural topics for beginning XNA programmers.  It's hard enough to learn basic syntax without rapidly getting into properties, parameter passing functions and constructor methods full of passed variables and fields.  Mr. Miles does everything in the main Game1.cs class.  This keeps things simple.  Another major aspect of this book, relative to beginners, is he sticks to 2D.  Most XNA books spend just a few chapters on 2D and then jump into 3D with reckless abandon.  I find this really strange when you consider that most community games on the XBOX 360 will be in 2D.  That's simply a fact.  3D game development is massively complex and not just from a coding perspective but from the graphics.  Developing 3d models, shader code etc. etc. is just way over any beginner's head.  So what you will find is many XNA books are great until they start the 3D stuff.  And then you may as well put them down.  Because if you are at my stage in this, you are not ready for 3D.

I e-mailed Mr. Miles  at his website Very Silly Games.

This was my post and his reply:


Rob,

As a new C#/XNA programmer, I've really enjoyed your book, "Learning Programming Now!" If you don't mind I have a few basic coding questions.

My 1st question is, Why do you use an algorithim to scale sprites to the displaywidth and height in your Bread and Cheese game when it seems that you could just use the scale feature built into the SpriteBatch.Draw method. There is an overload for Draw that includes scale. Would it not be simpler to just use that built-in scale feature in Draw and adjust it relative to DisplayWidth and Height?

My 2nd question is, On the XNA Creator's Club Website in the Getting Started section, there is a tutorial teaching you to make a 2D "Shoot the Flying Saucers" game. In this tutorial, the author uses a seperate class to define his sprites. He calls his class GameObjects and in that class assigns the various sprite fields etc. In his main Game class he then refers to those fields by using GameObjects dot field. (GameObjects.field) However in your book in the Bread and Cheese game you use a Structure to hold the sprite information. Is this simply a personnal coding perference or is one way better than the other?

My Final Quesiton is more complicated so please bear with me. I've read a few books that use GameComponents and Game Services to organize their code. (I'm specifically referring to "Beginning XNA 2.0 Game Programming" by Lobao, Evangelista and Faris.) This organizational structure seems bizarrly complicated to me and it seems to me that it breaks the elegance of using the class structure and proper inheritance/parameter passing between classes that you learn in C#. However the game code works and in some regards it's much simpler because is seems that it gets around all of the inheritance problems that become very complicated using multiple classes.
Since you don't address this type of structure in your book, would you be willing to offer your opinion on the use of GameComponents/Services vs. classes as a way to structure game code in C# and XNA?

Thanks so much for your help.

Allan Chaney



Sorry about the delay in getting back to you. Been awfully busy recently. I've put my answers in line...

My 1st question is, Why do you use an algorithim to scale sprites to the displaywidth and height in your Bread and Cheese game when it seems that you could just use the scale feature built into the SpriteBatch
Draw method. There is an overload for Draw that includes scale. Would it not be simpler to just use that built-in scale feature in Draw and adjust it relative to DisplayWidth and Height?

>>> Indeed I could use the scale. The thing is that I wanted to use this to teach about programming and scaling. Perhaps in a future book I could mention that the method is avaiable.

My 2nd question is, On the XNA Creator's Club Website in the Getting Started section, there is a tutorial teaching you to make a 2D "Shoot the Flying Saucers" game. In this tutorial, the author uses a seperate class to define his sprites. He calls his class GameObjects and in that class assigns the various sprite fields etc. In his main Game class he then refers to those fields by using GameObjects dot field. (GameObjects.field) However in your book in the Bread and Cheese game you use a Structure to hold the sprite information. Is this simply a personnal coding perference or is one way better than the other?

>>> I wanted to start with structures and then move into objects later.

My Final Quesiton is more complicated so please bear with me. I've read a few books that use GameComponents and Game Services to organize their code. (I'm specifically referring to "Beginning XNA 2.0 Game Programming" by Lobao, Evangelista and Faris.) This organizational structure seems bizarrly complicated to me and it seems to me that it breaks the elegance of using the class structure and proper inheritance/parameter passing between classes that you learn in C#. However the game code works and in some regards it's much simpler because is seems that it gets around all of the inheritance problems that become very complicated using multiple classes.
Since you don't address this type of structure in your book, would you be willing to offer your opinion on the use of GameComponents/Services vs. classes as a way to structure game code in C# and XNA?

>>> I've not had a chance to look at this book I'm afraid. If you want my philosophy on game structure take a look at my Starlight game for Smartphone. It is not an XNA game, but it has a lot of stuff about game design and sprite management. It also has some stuff about animation that you might find useful.

http://msdn.microsoft.com/en-us/library/aa446569.aspx

I'm immensely impressed anytime an author both supports their work with this kind of dedication and takes the time to communicate with their readers.  His website is amazing.  He has the code for a ton of his games you can download and learn from.

I highly highly recommend this book for any beginning or intermediate XNA developer.

My only recommendation for Mr. Miles is that he please write another book updating the text for XNA version 3.0 and I think he should spend a chapter or two addressing muli-class structured code and the use of Game Components.  Although these are complex topics, they are unavoidable and Rob Miles is the perfectly suited to explain them to you and me.

Allan

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>