XNA Intro Workshop

Preview:

DESCRIPTION

 

Citation preview

Sjors MiltenburgSoftware Ontwikkelaar

smiltenburg@sogyo.nlwww.software-innovators.nl

Microsoft’s XNA

Who?

Who?

William

Higinbotham

First video game, 1958

First video game, 1958

Spacewar, 1962

The Galaxy Game, 1971

Pong, 1972

Spaceinvader, 1978

Commodore, 1982

Super Mario Bros, 1985

Wolfenstein 3D, 1992

Duke Nukem 3D, 1996

Call of Duty 4, 2007

Second Life

$5 million p.

month

NL game industry bigger than film industry

NL game

industry bigger

than

music industry

NL Game industie$ 1.47 miljard

Facts

World of Warcraft

[2007]

$ 1.176 BillionUSA [2007]$ 17.9 billion

Halo 3, first 24 hour$ 170 million

Turnover Ubisoft 2007$ 662.7 million

Microsoft’s

Windows

Microsoft’s DirectX

Microsoft’s

Xbox

Microsoft’s Xbox 360

Microsoft & gaming

XNA

• tools for game development

• Completely managed environment

• All aspects of game production in one system

• Game development is accessible

XNA Platform

• XNA Framework

• XNA Build

• XNA Framework Content Pipeline

• XNA Game Studio

What do you need?

• .NET 3.0• Visual Studio (C# Express is free!)• XNA Framework• XNA Game Studio

XNA Framework• Microsoft .NET CLR 3.0 (3.5?)

• Cross-Platform Game Development– Windows XP– Windows Vista– Xbox 360 – Zune

XNA Framework overview

Legend XNA Provides You Provide Community

Platform

CoreFramework

ExtendedFramework

XACT XINPUT XContentDirect3D

Graphics Audio Input Math Storage

Application Model Content Pipeline

Games Starter Kits Code Content Components

XNA Framework overview

Platform

CoreFramework

ExtendedFramework

XACT XINPUT XContentDirect3D

Graphics Audio Input Math Storage

Application Model Content Pipeline

Games Starter Kits Code Content Components

Legend XNA Provides You Provide Community

Starter Kits

“Take our games and make them your own”

• “Complete” games– Starting point for your own games– Available through “New Project…”– Hit F5 and done!– Documentation and tutorials

Components

• They use the standard gameloop– Initialize, Load, Update, Draw, Unload

• Create and re-use functionality• Use 3rd party components• Community has a standard• Menus, virtual keyboard, game

engine, game info, radar’s, map, etc…

Components

• Example of a Component– Virtual keyboard voor de XBOX 360

XNA Framework overview

Platform

CoreFramework

XACT XINPUT XContentDirect3D

Graphics Audio Input Math Storage

Legend XNA Provides You Provide Community

ExtendedFramework Application Model Content Pipeline

Games Starter Kits Code Content Components

Application Model

• Platform abstraction– Don’t worry about the platform

• First line of code is for your game

• Game class– Starting point for your game

Application Model

• Game– Initialize– LoadContent– Update– Draw– UnloadContent

• GameComponent, DrawableGameComponent

Game Class, starting point

Content Pipeline

• extensible content processing framework• 2D File Formats

(.DDS, .BMP, .JPG, .PNG, .TGA)• 3D File Formats (.FBX, .X)• Material File Formats (.FX)• Audio File Formats (.XAP)

Platform

ExtendedFramework

XACT XINPUT XContentDirect3D

Application Model Content Pipeline

Games Starter Kits Code Content Components

XNA Framework overview

Legend XNA Provides You Provide Community

CoreFramework Graphics Audio Input Math Storage

Core Framework

• Graphics– SpriteBatch, BasicEffect, Texture2d,

GraphicsDevice, Model, VertexBuffer• Audio

– SoundBank, WaveBank, Cue, AudioEngine

– Looping, Streaming en memory management

– low-level buffer management• Input

– GamePad, Keyboard, Mouse

Core Framework

• Math– MathHelper.ToRadians(float angle), PiOver4

• Storage– Title Storage (Shaders, Meshes, Textures,

Sounds…)– User Storage (Save games, Scores…)– Emulated on the Windows Platform

• Network– NetworkSession, PacketReader, NetworkGamer

XNA Framework Overzicht

Platform XACT XINPUT XContentDirect3D

Legend XNA Provides You Provide Community

CoreFramework

ExtendedFramework

Graphics Audio Input Math Storage

Application Model Content Pipeline

Games Starter Kits Code Content Components

Platform abstraction

• Don’t worry about the platform, but about your game!

• Mono started an implementation

XACT

• Microsoft Cross-Platform Audio Creation Tool

• Create audio files for XNA games• Compiles .wav files• Add info to the sound

– Looping, volume levels

Community

• 3D Models– Cars, Houses, humans, levels

• Mostly free• http://turbosquid.com/xna

Community

• Example of a community built Component– XNA Console

Deployment to Xbox 360

• What do you need to deploy to Xbox 360?– Xbox Live Account– XNA Game Launcher– Connection to computer– XNA Creators Club account

• XNA Creators Club account– 49 euro (4 months)– 99 euro (1 year)

Getting creative

• Creating games with XNA is easy!

We will be building

• Tank game– Drive, aim and shoot

Steps

• Run an empty game• Load graphical content• Show tank on screen• Handle user input

– Rotate– Move– Shoot

Step 1: Empty game

• Create a new XNA game • Run!

Step 2: Load Content

• Create a Tank Class– Vector2 (x,y) for position– Float (Radians) for direction

• 3 resources (tank, turret, canonball)• Texture2D

– ContentManager.Load<2DTexture>(“Tank”);

Step 3.1: Display content

• Draw tank • Draw turret

• Draw @ center of the screen• Does it matter what you draw first?

Step 3.2: Display content

• SpriteBatch.Begin();• SpriteBatch.Draw(7

implementations);• SpriteBatch.End();

• Screen– GraphicsManager.GraphicsDevice.Viewp

ort– 0,0 = top left corner– 800,600 = bottom right corner

Step 4: Handle User input

• KeyboardState = Keyboard.GetState();

• If (KeyboardState.isKeyDown(Keys.Up));

• Where do we place this code?

• Rotate (Tank & turret)• Move• Vector2 Movement = new Vector2();• Movement.X += moveDist * (float)Math.Cos(Rotation);• Movement.Y += moveDist * (float)Math.Sin(Rotation);

Step 5: Shoot

• CannonBall Class• One shot at a time (space invader

style)

Step 6: Shoot Enemy

• Draw stationary tank• Hit?

– Rectangle.Intersects– Advanced: Per pixel collision– Where should this code go?

• Draw tank health– Add new SpriteFont to content folder– Load Content– SpriteBatch.DrawString();

Step 7: Network code

• Sample code– Search for “XNA Network Prediction”– Uses Microsoft Live

• Create a local account

Resources

• http://creators.xna.com/• http://blogs.msdn.com/xna• http://www.turbosquid.com/xna• http://xbox360homebrew.com• http://www.riemers.net• http://www.xnadevelopment.com• Search for XNA at Google with Live

Search

Vragen?

Nintendo’s Wii!

Wiimote

• Knoppen• Accelerometer• IR-camera• Buzzer• Leds• Bluetooth

Accelerometer

• ADXL330 3-Axis ±3g iMEMS® Accelerometer

Accelerometer

Z (-3G, 3G)

Y (-3G,3G)

Accelerometer

1

0

0

Stil

Accelerometer

>1

0

0

Omhoog

Accelerometer

<1

0

0

Omlaag

IR-camera

• PixArt optical sensorMulti-Object Tracking engine (MOT sensor™)

• Sensor bar

IR-camera

Bluetooth

• BCM2042Advanced Wireless Keyboard/Mouse Bluetooth® Chip

• HID Device

Wiimote -> PC

• OS• Bluetooth Device• Bluetooth stack

API’s

RMX Automation

GlovePIE

WiinRemote

wiimote-api

WMD

WiiYourself!

libwiimote

WiimoteLib

WiimoteCPP

Wiiewer

Wiimotecomm

WiimoteLib classes

Simplicity

Demo time!

• Flying with the Wii