3
COMP436/536B 2007 – Lecture 2 Microsoft’s game development system for Xbox 360 and PC We will use XNA Express / C# Express Released in beta late 2006 Version 1.0 release Jan 2007 Version 2.0 release Dec 2007 (current) Version 3.0 currently in CTP Freely available from http://creators.xna.com/ (from Resources / download on menu bar) Theory 1 DirectX N ext generation A rchitecture Theory 2: Some kind of play on DNA and DirectX in that XNA is the successor to DirectX and is the ‘DNA’ for game development Theory 3: X NA is N ot an A cronym A graphics library Allows us to generate 2 and 3D images on screen A content management system Can add images / sounds / models / animations Can load them into memory and display / play An outline game framework (class) Creating a game Start “XNA Game Studio Express” Available in R block, Lab 2. File / New Project Windows Game (2.0) Decide where you want to store it, give it a name Solution / Project / Solution Explorer Remember the view menu if anything is missing

Microsoft’s game development system Version 2.0 release ...coms0108/536/536Lecture1.pdf · XNA is Not an Acronym A graphics library Allows us to generate 2 and 3D images on screen

  • Upload
    others

  • View
    24

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microsoft’s game development system Version 2.0 release ...coms0108/536/536Lecture1.pdf · XNA is Not an Acronym A graphics library Allows us to generate 2 and 3D images on screen

COMP436/536B 2007 – Lecture 2

� Microsoft’s game development system

for Xbox 360 and PC

� We will use XNA Express / C# Express

� Released in beta late 2006

� Version 1.0 release Jan 2007

� Version 2.0 release Dec 2007 (current)

� Version 3.0 currently in CTP

� Freely available from http://creators.xna.com/(from Resources / download on menu bar)

� Theory 1

� DirectX Next generation Architecture

� Theory 2:

� Some kind of play on DNA and DirectX in that XNA

is the successor to DirectX and is the ‘DNA’ for

game development

� Theory 3:

� XNA is Not an Acronym

� A graphics library

� Allows us to generate 2 and 3D images on screen

� A content management system�Can add images / sounds / models / animations

�Can load them into memory and display / play

� An outline game framework (class)

� Creating a game

� Start “XNA Game Studio Express”

�Available in R block, Lab 2.

� File / New Project

�Windows Game (2.0)

�Decide where you want to store it, give it a name

� Solution / Project / Solution Explorer

�Remember the view menu if anything is missing

Page 2: Microsoft’s game development system Version 2.0 release ...coms0108/536/536Lecture1.pdf · XNA is Not an Acronym A graphics library Allows us to generate 2 and 3D images on screen

� The game class has methods

� Constructor

� Initialize

� LoadGraphicsContent

� UnloadGraphicsContent

� Update

� Draw

� And data: graphics device, content manager

� It runs (F5 or Debug / Start Debug)

� Can modify title (this.window.title) or colour

� System.Diagnostics.Debug.WriteLine(“ “);

� gameTime.TotalGameTime.TotalSeconds

� Assets

� Graphic objects

� Mathematical objects

� Input objects

� Externally created graphic and other objects to

use in the game program

� Texture2D – a 2D image (picture)

� Add asset to project (in solution explorer)

� Useful to put into a folder (Content)

� Properties to give the asset a name

� Need a variable to hold the asset during play

� Declaration

� Texture2D tex1;

� In LoadContent

� tex1 = Content.Load<Texture2D>(“Lillies”);

Page 3: Microsoft’s game development system Version 2.0 release ...coms0108/536/536Lecture1.pdf · XNA is Not an Acronym A graphics library Allows us to generate 2 and 3D images on screen

� Vectors, matrices and quaternions

� Vector2 – a point (x, y)

� Declare

�Vector2 location

� Give values

� location = Vector2.Zero;

� location = new Vector2(100.0f, 200.0f);

� Objects used in a game

� A sprite is a 2D image as presented in the game.

� SpriteBatch

�Object for managing and drawing sprites

�Predefined in the outline game you start with

�Does the setup of the graphics device required before

drawing a sprite – is an object to allow us to do this

setup only once when drawing many sprites

� Drawing

� spriteBatch.Begin();

� spriteBatch.Draw(tex1, Vector2.Zero, Color.White);

� spriteBatch.End();

� You can declare and create additional

SpriteBatch objects of your own (create with

new), but we will have no need to do this

� The parameters of draw give the top left corner

in screen coordinates and the tint colour

� Alternative forms of draw provide other options

including scaling

� To provide access to game controllers, mouse

and keyboard

� Keyboard

� Check current state of a key

� Keyboard.GetState().IsKeyDown(Keys.Q));