Why Windows Phone 7 Game Development Marios Karagiannis.

31
YMTIS WORKSHOP Zurich Why Windows Phone 7 Game Development Marios Karagiannis

Transcript of Why Windows Phone 7 Game Development Marios Karagiannis.

Page 1: Why Windows Phone 7 Game Development Marios Karagiannis.

YMTIS WORKSHOPZurich

Why Windows Phone 7 Game DevelopmentMarios Karagiannis

Page 2: Why Windows Phone 7 Game Development Marios Karagiannis.

Who am I

• My name is Marios Karagiannis• I am Greek• I am not affiliated with Microsoft• PhD Candidate @ UNIGE

– In my last year• Gamer

– Since the Game & Watch era• Games Developer

– Made my first game on an8-bit Atari 65 XE (on cassette)

– Currently making games for Windows Phone 7

Mkaragia@ xbox live

Page 3: Why Windows Phone 7 Game Development Marios Karagiannis.

WP7 Hardware• All Windows Phone 7 phones must have as a minimum (called Chassis

1):– 4 points multi touch capacitive screens– 480x800 screen resolution– 1GHz CPU– Accelerometer– 256MB Ram – 8GB Storage– DirectX 9 GPU with video acceleration– 5 MP Camera with flash– A-GPS– Compass– Ambient and proximity sensors– 3 hardware keys (Back, Start, Search)

Page 4: Why Windows Phone 7 Game Development Marios Karagiannis.

XNA

• What is XNA?– A set of tools specifically designed for game development– Managed runtime environment– For

• Windows Phone• XBOX 360• Windows

– (using almost the same code)

– Originally for the XBOX it was called Xbox New Architecture)

– After XBOX 360 it means XNA is Not an Acronym

Page 5: Why Windows Phone 7 Game Development Marios Karagiannis.

Is XNA any good?

• Let me state this– Developing games with XNA is the best way to develop

games in any platform, ever(did I say ever?)

• Why?– C#– .NET– Free and great tools (XNA Game Studio 4 and Visual Studio

Express 2010)– Great libraries– Amazing documentation

Page 6: Why Windows Phone 7 Game Development Marios Karagiannis.

Is XNA any good?

• Also comes with extra bonuses– Have you worked with XBOX 360 games?– You already know 99% of the things you need to

know to make Windows Phone 7 games• Apart from console specific or phone specific things

– Change joypad to touch screen– Change screen resolution and adapt your content– Use accelerometer and touch screen

– Wanna see how easy it is?

Page 7: Why Windows Phone 7 Game Development Marios Karagiannis.

XNA for Windows Phone 7

• Game loop vs event driven programming– Games play even when you don’t

Update Draw

Page 8: Why Windows Phone 7 Game Development Marios Karagiannis.

Game timing

• XNA lets you choose how you want timing to work in your game:– Fixed Time Step (default)

TargetElapsedTime = TimeSpan.FromSeconds(1/30.0);

Update Draw

NO

YESIsRunningSlowly = true

Time for next

update

Page 9: Why Windows Phone 7 Game Development Marios Karagiannis.

Game timing

• XNA lets you choose how you want timing to work in your game:– Variable Time Step

Be careful to use ElapsedGameTime (more traditional way to develop games)

Update Draw

Page 10: Why Windows Phone 7 Game Development Marios Karagiannis.

Content

• XNA provides a powerful content pipeline that can import and process:– Images (bmp, dib, hdr, jpg, pfm, png, ppm, tga)– Fonts (converted automatically to spritefonts)– XML– 3D models(fbx)– Music (mp3, wma)– Sounds (wav)– And custom processors (if you so wish)

• Assets are processed to xbl files• Some assets can be compressed

Page 11: Why Windows Phone 7 Game Development Marios Karagiannis.

Physics

• Although technically not part of the XNA you can easily compile and use the Farseer Physics Engine with your Windows Phone 7 games

http://farseerphysics.codeplex.com/

Page 12: Why Windows Phone 7 Game Development Marios Karagiannis.

Drawing (2D and 3D)• One Draw method

– You can render 3D objects and then 2D objects• Or vice versa

• GPU hardwalre image scaler is free to use– The scaler is easy to use: just set graphics.PreferredBackBufferWidth and

PreferredBackBufferHeight in your game constructor– The resolution can be anywhere from 240x240 up to a max of 800x480 (or

480x800 if you are making a portrait game)– If you choose a resolution that does not match the screen aspect ratio, it

will be automatically letterboxed (black bars along the edges)– Touch input is automatically scaled to match your chosen backbuffer

resolution– Scaling is implemented by dedicated hardware, so doesn't cost any GPU– Scaling uses a high quality filter (better looking than GPU bilinear filtering)

Page 13: Why Windows Phone 7 Game Development Marios Karagiannis.

But you also get events

• Although XNA is game loop driven– You still get events• Phone calls• Battery down• Etc.

#if WINDOWS_PHONEPhoneApplicationService.Current.Launching+=Current_Launching;PhoneApplicationService.Current.Deactivated+=Current_Deactivating;PhoneApplicationService.Current.Activated+=Current_Activating;

#endif

Page 14: Why Windows Phone 7 Game Development Marios Karagiannis.

Phone Sensors

• With XNA you have control over– The vibration function– The accelerometer– The touch screen– The camera

• But not (yet)– The compass– The light and proximity sensors– Bluetooth

Page 15: Why Windows Phone 7 Game Development Marios Karagiannis.

Let’s see how easy it isWhen you start a new Windows Phone 7 XNA Game everything is setup for

you:Your Game classA spriteBatch object to draw spritesYour Graphics Devide Manager objectYour Content rootYour Initialize functionYour LoadContent functionYour UnloadContent functionYour Update functionYour Draw function

Update Draw

Start

Initialize

LoadContent

UnloadContent

Finish

Page 16: Why Windows Phone 7 Game Development Marios Karagiannis.

An example

• How to use multi touch– Touch can detect Pressed, Moved, Released

events– Is arranged in touch collections with unique IDs• Remember you always have at least 4 touch multitouch

// Process touch events TouchCollection touchCollection = TouchPanel.GetState(); foreach (TouchLocation tl in touchCollection) {

if ((tl.State == TouchLocationState.Pressed) || (tl.State == TouchLocationState.Moved)) { // add sparkles based on the touch location sparkles.Add(new Sparkle(tl.Position.X, tl.Position.Y, tl.Id)); }

}

Page 17: Why Windows Phone 7 Game Development Marios Karagiannis.

Another example

• How to use the accelerometer– Use a ReadingChanged event• Read 3 axis data

Page 18: Why Windows Phone 7 Game Development Marios Karagiannis.

Another exampleAccelerometer accelSensor; Vector3 accelReading = new Vector3();

public void AccelerometerReadingChanged(object sender, AccelerometerReadingEventArgs e) {

accelReading.X = (float)e.X; accelReading.Y = (float)e.Y; accelReading.Z = (float)e.Z;

}

accelSensor = new Accelerometer(); // Add the accelerometer event handler to the accelerometer sensor. accelSensor.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(AccelerometerReadingChanged);

// Start the accelerometer try {

accelSensor.Start(); accelActive = true;

} catch (AccelerometerFailedException e) {

// the accelerometer couldn't be started. No fun! accelActive = false;

} catch (UnauthorizedAccessException e) {

// This exception is thrown in the emulator-which doesn't support an accelerometer. accelActive = false;

}

Page 19: Why Windows Phone 7 Game Development Marios Karagiannis.

Another example

// Start the accelerometer try {

accelSensor.Start(); accelActive = true;

} catch (AccelerometerFailedException e) {

// the accelerometer couldn't be started. No fun! accelActive = false;

} catch (UnauthorizedAccessException e) {

// This exception is thrown in the emulator-which doesn't support an accelerometer. accelActive = false;

}

if (accelActive) {

// accelerate the sparkle depending on accelerometer // action. s.speed.X += accelReading.X * ACCELFACTOR; s.speed.Y += -accelReading.Y * ACCELFACTOR;

}

Page 20: Why Windows Phone 7 Game Development Marios Karagiannis.

Another example

//When the game is paused or accelerometer data is not needed// Stop the accelerometer if it's active. if (accelActive)

{ try

{ accelSensor.Stop();

} catch (AccelerometerFailedException e)

{ // the accelerometer couldn't be stopped now.

} }

Page 21: Why Windows Phone 7 Game Development Marios Karagiannis.

Interested? Where to start

• The App Hubhttp://developer.windowsphone.com/

• Windows Phone 7 Developer Training Kithttp://create.msdn.com/en-US/education/catalog/article/wp7_training_kit

• Windows Phone 7 Jump Starthttp://create.msdn.com/en-US/education/catalog/article/wp7_jump_start

• Education http://create.msdn.com/en-US/education/

Page 22: Why Windows Phone 7 Game Development Marios Karagiannis.

My latest game

MonsterUp

Page 23: Why Windows Phone 7 Game Development Marios Karagiannis.
Page 24: Why Windows Phone 7 Game Development Marios Karagiannis.

Beyond game design

• Register as a developer – free for students, $99 per year for everyone else

• Read the certification guidelines• Develop your app/game• Test your game against guidelines• Create the submission artwork• Submit your app/game• Cross your fingers and wait• …• Profit

Page 25: Why Windows Phone 7 Game Development Marios Karagiannis.

General Tips

• Try to make something good– Original is one way to go– But anyway make something people want to

use/play• Every day if possible

• Try not to make something fast just for the fun of it– Except if you don’t really care about your app

succeeding– And we have enough tip calculators, thanx

Page 26: Why Windows Phone 7 Game Development Marios Karagiannis.

Marketplace Tips

• Read the guidelines carefully– Small things can get the app rejected

• Like not handling the Back button correctly• Or having one of the artworks 1 pixel too big

– You don’t want to wait a week just to find out you waited for nothing

• Test your app for bugs– Try anything you might think of– Give it to your friends, family

etc to test stuff for you

Page 27: Why Windows Phone 7 Game Development Marios Karagiannis.

If your app fails

• Microsoft will provide feedback– Fortunately, they provide very clear instructions

on how to reproduce the problem that got your app rejected

– Follow the steps, fix the problem(s) • Test again your app• Re-submit

Page 28: Why Windows Phone 7 Game Development Marios Karagiannis.

Your app got accepted

• Congratulations• This is just the beginning though• Work hard to support your users with updates, bug fixes, new

features etc– Listen to their feedback– Get ideas for expansions

• Advertise your app as hard as you can– People cannot buy your app if they

don’t know it exists• Promotion 101 is out of the scope

of this talk

Page 29: Why Windows Phone 7 Game Development Marios Karagiannis.

Is there money to be made?• Short answer?

– Maybe, but not yet• While people may buy your game/app, and although the Marketplace is growing

_really_ fast, it’s still small• Unfortunately, you cannot make money from free

apps/games and in-app advertising outside of the US• But…• …rapid market expansion is on the way!

– Microsoft – Nokia deal– CDMA update (Sprint and Verizon in the US)

• And you want your app(s)/game(s) to be in there when the millions of user come…– …and they will come, the platform is usable, great

and improving very fast– Not to mention that the developer tools are the best

out there

Page 30: Why Windows Phone 7 Game Development Marios Karagiannis.

Ideas/Help

• I am always open to discuss your ideas• And help where I can

• Find me and these slides [email protected]

Page 31: Why Windows Phone 7 Game Development Marios Karagiannis.

Thank you

Now go make the next WP7 masterpiece