Download presentation
Presentation is loading. Please wait.
2
* 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 an 8-bit Atari 65 XE (on cassette) * Currently making games for Windows Phone 7
3
* 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)
4
* 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
5
* 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
6
* Game loop vs event driven programming * Games play even when you don’t UpdateDraw
7
* 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 YES IsRunningSlowly = true Time for next update
8
* 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) UpdateDraw
9
* 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
10
* 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/
11
* 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)
12
* Like in Silverlight, events can occur in XNA #if WINDOWS_PHONE PhoneApplicationService.Current.Launching+=Current_Launching; PhoneApplicationService.Current.Deactivated+=Current_Deactivating; PhoneApplicationService.Current.Activated+=Current_Activating; #endif
13
* 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
14
When you start a new Windows Phone 7 XNA Game everything is setup for you: Your Game class A spriteBatch object to draw sprites Your Graphics Devide Manager object Your Content root Your Initialize function Your LoadContent function Your UnloadContent function Your Update function Your Draw function UpdateDraw Start Initialize Load Content Unload Content Finish
15
* How to use multi touch * Touch can detect Pressed, Moved, Released events * Is arranged in touch collections with unique IDs // 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)); }
16
* How to use the accelerometer * Use a ReadingChanged event * Read 3 axis data
17
Accelerometer 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 (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; }
18
// 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; }
19
//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. }
20
* The App Hub http://developer.windowsphone.com/ * Windows Phone 7 Developer Training Kit http://create.msdn.com/en- US/education/catalog/article/wp7_training_kit * Windows Phone 7 Jump Start http://create.msdn.com/en- US/education/catalog/article/wp7_jump_start * Education http://create.msdn.com/en-US/education/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.