Lecture 7: Introduction to XNA Game Studio Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology2 Dungeon Quest • Developed in 4 days at the 2007 GDC at the XNA contest • By Benjamin Nitschke and Christoph Rienaecker Screenshot from exdream.no-ip.info/blog/2007/07/31/DungeonQuestUpdatedWithSourceCodeNow.aspx4 Torpex’s “Schizoid” (on Xbox Live Arcade) http://www.gametrailers.com/player/28542.html Screenshot from http://screenshots.teamxbox.com/screen/68599/Schizoid/5 XNA GS Framework • Built on Microsoft’s .NET – Makes MS comfortable with letting “ordinary folks” program on the Xbox 360 • C# is standard language for XNA development – But in theory could use Managed C++, VB.NET, etc. on the PC • Xbox 360 uses .NET Compact Framework – Some stuff available in .NET on the PC is missing! – Garbage collector on 360 isn’t as smart as on the PC – Caused the Schizoid team some trouble, as well as one semester of CS44556 Is managed code too slow for games? • Vertigo Software ported Quake II to Managed C++, got 85% performance of the original C code – Should expect to do better if you have the .NET Common Language Runtime in mind from the beginning • Xbox 360 – GPU: 337 million transistors – CPU: 165 million transistors7 XNA GS graphics • XNA is built on top of DirectX 9 – Not built on MDX or Managed DirectX • DirectX 9 has a fixed function pipeline, but XNA doesn’t! – Everything done with shaders From XNA Team Blog, “What is the XNA Framework,” blogs.msdn.com/xna/archive/2006/08/25/724607.aspx8 Why no fixed-function pipeline? • Programmable pipeline is the future – Neither Direct3D 10 or Xbox 360 have fixed-function pipeline • Early adopters and customers said cross-platform goal more important than fixed-function pipeline • Fear is someone would start and finish their game using the fixed-function APIs, and then get dozens of errors when they tried to compile it on the Xbox 360 • Better to know your code works on both right from the beginning From XNA Team Blog, “What is the XNA Framework,” blogs.msdn.com/xna/archive/2006/08/25/724607.aspx In Microsoft’s own words (paraphrased):9 Some convenient things about XNA • Don’t need to mess with Win32-ish boilerplate (opening a window, etc.) • Easy interfacing with the Xbox 360 controller (for both Windows and Xbox 360) • Storage (“saved games”) unified between Windows and Xbox 360 – On Xbox 360, have to associate data with a user profile, put on hard drive or memory card, etc. – XNA “emulates” this on windows From XNA Team Blog, “What is the XNA Framework,” blogs.msdn.com/xna/archive/2006/08/25/724607.aspx10 Hello Bluescreen public class SampleGame : Game {!""" private GraphicsComponent graphics;!""!""" public SampleGame() {!""""""" this.graphics = new GraphicsComponent();!""""""" this.GameComponents.Add(graphics);!""" }!""!""" protected override void Update() { }!""!""" protected override void Draw() {!""""""" this.graphics.GraphicsDevice.Clear(Color.Blue);!""""""" this.graphics.GraphicsDevice.Present();!""" }!""!""" static void Main(string[] args) {!""""""" using (SampleGame game = new SampleGame()) {!""""""""""" game.Run();!""""""" }!"" }! From XNA Team Blog, “What is the XNA Framework,” blogs.msdn.com/xna/archive/2006/08/25/724607.aspx11 XNA strengths & weaknesses: audio • Uses XACT, Microsoft’s Audio Creation Tool • Nice for modifying sound effects directly in XACT until you like them • No support for .mp3 or .wma • Xbox 360 has XMA, and Windows has ADPCM, but game still 3-5 bigger than it might otherwise be Info from Alistair Wallis, “Microsoft XNA: A Primer,” interview with Benjamin Nitschke www.gamecareerguide.com/features/328/microsofts_xna_a_.php?page=412 Benjamin Nitschke’s Rocket Commander Screenshot & info from www.gamecareerguide.com/features/328/microsofts_xna_a_.php?page=4 Original 10M, XNA version 50M due to larger audio files13 Careful if you’re on Windows x64 • XNA normally targets “AnyCPU” • Will break when you try to run on x64 machines, since x64 versions XNA framework dlls don’t exist (yet) • Workaround: Change target to x8614 Caveats about Xbox 360 development • Many TVs cutoff 5-10% of the pixels around the edge – Keep text & important info away from there • Xbox 360 handles post processing and render targets a little differently than the PC Info from Alistair Wallis, “Microsoft XNA: A Primer,” interview with Benjamin Nitschke www.gamecareerguide.com/features/328/microsofts_xna_a_.php?page=415 Dream Build Play contest • See http://www.dreambuildplay.com • This year’s entries are due Sept. 23 – Too late for this year, probably… – But keep on the lookout for the 2009 Dream Build Play contest!16 XNA Community Games • See http://creators.xna.com • Join the XNA Creator’s Club – The XNA CC memberships students get free from DreamSpark will let you run games on the 360, but may not let you take part in Community Games • Upload your game, rate content (violence, etc.) • Peer review – confirm content ratings, check quality • Can sell your game to Xbox 360 users!17 Introduction to C# - emphasis on “gotchas” by Ben Albahari, Peter Drayton, and Brad Merrill, 2001 Great article: Jesse Liberty, “Top ten traps in C# for C++ programmers” www.ondotnet.com/pub/a/oreilly/dotnet/news/programmingCsharp_0801.html18 Value vs. reference types • Like C++, C# has user defined types • C# also makes a distinction between value types and reference types • Value types: – Intrinsic types and structs – “Passed by value” (copied) – Stored on the stack (unless part of a reference type) • Reference types: – Classes and interfaces, and “boxed” value types – “passed by reference” (implicit pointer) – Variables sit on the stack, but hold a pointer to an address on the heap; real object lives on heap19 Boxing and unboxing • Boxing allows value types to be treated as reference types – Value boxed inside an object – Unboxed to get original value back • Everything in C# is derived from “Object,” so everything can be implicitly cast to an object • Unboxing must be done explicitly20
View Full Document