35
XNA-in-a-Day Introduction to XNA Game Studio

XNA in a Day

Embed Size (px)

DESCRIPTION

Presentation deck to go along with my XNA in a Day training.

Citation preview

Page 1: XNA in a Day

XNA-in-a-Day

Introduction to XNAGame Studio

Page 2: XNA in a Day

Andrew ParsonsAcademic Developer Evangelist@MrAndyPuppy

Page 3: XNA in a Day

GETTING STARTED

Page 4: XNA in a Day

The Tools You Need

• A computer– A decent card if you want graphics

acceleration

• Windows– Windows 7 works well

• Visual Studio or Visual C#– Visual Studio 2010 Professional – available to

students through DreamSpark

• XNA Game Studio– Current version – XNA Game Studio 4.0

Page 5: XNA in a Day
Page 6: XNA in a Day

What is DreamSpark?o DreamSpark provides free Microsoft software to verified

students around the world for FREE!

Who is eligible for DreamSpark?o All part-time and full-time students are entitled to DreamSpark software

What software can they get from DreamSpark?o Visual Studio 2010 Professional, Expression Studio 4 Ultimate, Windows

Server, SQL Servero Free appHub account for Windows Phone 7 Marketplaceo One year free subscription to XNA Creators Clubo 90 days of free Pluralsight training

Page 7: XNA in a Day

www.DreamSpark.comto register

Page 8: XNA in a Day

Visual Studio

• Integrated Development Environment

• Main code window• Solution Explorer• Toolbars and menus

Page 9: XNA in a Day

Creating a game

• Create new project• Basic structure of game project– Initialize– LoadContent (and UnloadContent)– Update– Draw

• GraphicsDeviceManager• SpriteBatch (we’ll revisit)

Page 10: XNA in a Day

ACTUALLY CREATING A GAME…

Page 11: XNA in a Day

Adding Assets

• http://bit.ly/XNADayFiles • Content – what is it• Add content to project

Page 12: XNA in a Day

Preparing Assets (Background)

• Texture2D• ContentManager• Content.Load• viewPortRect

Page 13: XNA in a Day

Using Assets

• Draw() method• 2D graphical assets - SpriteBatch

Page 14: XNA in a Day

Now for some fun stuff

• Cannon– Loaded in the same way– Drawn in the same way– Not quite!

Page 15: XNA in a Day

GameObject Class

• Sprite Texture• Position– Vector2.Zero

• Center• Rotation– Float

Page 16: XNA in a Day

Cannon Take 2

• Declare• Load – and set position

• Draw – Using GameObject properties

…• Interact

Page 17: XNA in a Day

INTERACTION

Page 18: XNA in a Day

Interaction Part 1

• Cannon Rotation– Shorthand operator += – Thumbstick– Restricting movement

• Keyboard control too– Conditional compilation #if

• Change Draw method

Page 19: XNA in a Day

Cannonballs - setup

• GameObject updates– Velocity– Alive

• Constants and Arrays• Loops– for– foreach and condition to draw

Page 20: XNA in a Day

Interaction Part 2

• State – GamePad and Keyboard– Define objects– Retrieve and save state

Page 21: XNA in a Day

Cannonballs - firing

• Buttons.A == ButtonState.Pressed– Previous state should be Released

(make them work for it)

• Automatic Method creation• Rotation in Radians – Cos/Sin math

functions• return to exit loop

Page 22: XNA in a Day

Cannonballs - moving

• Position + Velocity• Is it still visible?– viewPortRect.Contains(Point)

Page 23: XNA in a Day

Something to shoot at (1)

• Same as cannonballs – Array Declaration– Load Content– Draw– Update if alive

Page 24: XNA in a Day

Something to shoot at (2)

• Different from cannonballs– Update if not alive– Set Velocity– Set Position– Set Alive

Page 25: XNA in a Day

Introducing randomness

• Random• Random.NextDouble• Lerp - MathHelper function – Interpolate number within range

Page 26: XNA in a Day

Contact!

• Compare cannonballs and enemies• Create virtual Rectangles• Check Intersect

Page 27: XNA in a Day

Scoring - SpriteFont

• Create• Declare• Load• Draw

Page 28: XNA in a Day

WHERE TO NEXT?

Page 29: XNA in a Day

Particle System

• Use– 2D textures– Randomness– Rotation, velocity, position

Page 30: XNA in a Day

Imagine Cup

VIDEOS!

Page 31: XNA in a Day

Windows Phone 7

• Converting to Windows Phone 7 (or Xbox 360).

• Add touch support• Take it to the next level

Page 32: XNA in a Day

Windows Phone 7 - Touch

• Add Reference

• Get TouchPanel state

• Check TouchLocation state

Page 33: XNA in a Day

Starter Kits

• Platformer• RPG• Space Shooter• Racing

Page 34: XNA in a Day

ScriptTD

• http://bit.ly/APscriptTD

Page 35: XNA in a Day

More Info

• http://bit.ly/puppyblog• http://bit.ly/puppytube