Real life XNA
-
Upload
johan-lindfors -
Category
Technology
-
view
887 -
download
0
Transcript of Real life XNA
![Page 1: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/1.jpg)
![Page 2: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/2.jpg)
Real life
Johan Lindfors
![Page 3: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/3.jpg)
![Page 4: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/4.jpg)
windows phone for games
• impressive performance
• sensors and touch
• potentially xbox-live
• ads and trials
![Page 5: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/5.jpg)
kinectimals
![Page 6: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/6.jpg)
harvest
![Page 7: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/7.jpg)
implode
![Page 8: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/8.jpg)
doodle fit
![Page 9: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/9.jpg)
ilomilo
![Page 10: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/10.jpg)
other favorites
![Page 11: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/11.jpg)
xna in 1 minute
• a comprehensive framework for games
• integrated management of content
• games with 2d and ”sprites”
• games with 3d and ”meshes”
• shared features for pc, wp, xbox
![Page 12: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/12.jpg)
initialize update render
![Page 13: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/13.jpg)
managing content
• content pipeline
• import common files
• leverage compile time
• optimized binary format
• extensible
![Page 14: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/14.jpg)
first some 2d
• x and y (and z)
• spriteBatch
• sprites/sprite sheets
• blending
![Page 15: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/15.jpg)
and then some 3d
• x, y and z
• camera is described with matrices
• view
• projection
• world matrix transforms objects relatively
• movement (translation)
• rotation
• size (scale)
![Page 16: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/16.jpg)
demo
![Page 17: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/17.jpg)
effects - shaders
• configurable
• basic
• skinned
• environmentMap
• dualTexture
• alphaTest
![Page 18: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/18.jpg)
demo
![Page 19: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/19.jpg)
”hardware scaler”
• 800x480 = 384 000 pixels
• 600x360 = 216 000 pixels (56%)
• 400x240 = 96 000 pixels (25%)
graphics.PreferredBackBufferHeight = 800; graphics.PreferredBackBufferWidth = 480;
![Page 20: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/20.jpg)
performance tips
• manage the stack and heap
• reference types live on the _______!
• value types live on the _______!
• pass large structures by reference
• don’t foreach or linq (know code cost)
Matrix a, b, c; c = Matrix.Multiply(a, b); // copies 192 bytes! Matrix.Multiply(ref a, ref b, out c);
![Page 21: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/21.jpg)
performance tips
• gc is ”simpler” than on pc
• allocate objects early, reuse
• GC.Collect() can be your friend!
• after load, while paused
• cpu or gpu based?
• you can go up to 60 fps (60 hz)
![Page 22: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/22.jpg)
demo
![Page 23: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/23.jpg)
sound and music
• soundEffect
• load as content
• wp handles 64 simultaneously
• possible to change
• pitch
• volume
• 3d location
![Page 24: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/24.jpg)
orientation
• default is ”LandscapeLeft”
graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
![Page 25: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/25.jpg)
orientation
Window.OrientationChanged += (s, e) => { switch (Window.CurrentOrientation) { case DisplayOrientation.Portrait: graphics.PreferredBackBufferHeight = 800; graphics.PreferredBackBufferWidth = 480; break; default: graphics.PreferredBackBufferHeight = 480; graphics.PreferredBackBufferWidth = 800; break; } graphics.ApplyChanges(); };
![Page 26: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/26.jpg)
accelerometer
• measures acceleration in X, Y and Z
• values returned between -1 and +1
• event based
• read values in event, store for usage
using Microsoft.Devices.Sensors;
![Page 27: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/27.jpg)
Accelerometer accel; private void startAccelerometer() { accel = new Accelerometer(); accel.ReadingChanged += new EventHandler <AccelerometerReadingEventArgs> (accel_ReadingChanged); accel.Start(); }
start accelerometer
![Page 28: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/28.jpg)
Vector3 accelReading; void accel_ReadingChanged(object sender, AccelerometerReadingEventArgs e) { lock (this) { accelReading.X = (float)e.X; accelReading.Y = (float)e.Y; accelReading.Z = (float)e.Z; } }
read the accelerometer
![Page 29: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/29.jpg)
touch
• windows phone handles 4 touch points
• all points have unique id
• pressed | moved | released
TouchCollection touches; protected override void Update(GameTime gt) { touches = TouchPanel.GetState(); ... }
![Page 30: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/30.jpg)
gestures
• wp can also handle gestures
• tap | drag | hold | flick | pinch ...
TouchPanel.EnabledGestures = GestureType.Flick; while (TouchPanel.IsGestureAvailable) { GestureSample g = TouchPanel.ReadGesture(); if (g.GestureType == GestureType.Flick) { ... } }
![Page 31: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/31.jpg)
network
• http, rest, xml, sockets...
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { mapImage = Texture2D.FromStream( graphics.GraphicsDevice, e.Result); } }
![Page 32: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/32.jpg)
xbox live
• avatars and “trials” available for all
• developers with agreements
• profile
• invites
• achievements
• leaderboard
• gamerServices
• contact: [email protected]
![Page 33: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/33.jpg)
trial mode
• call to IsTrialMode takes 60 ms, cache!
• be creative in feature set
• trial or free light?
#if DEBUG Guide.SimulateTrialMode = true; #endif bool isTrial = Guide.IsTrialMode; ... Guide.ShowMarketplace(PlayerIndex.One);
![Page 34: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/34.jpg)
ads
• instead of user paying for app
• not for swedish apps yet*
*not from Microsoft that is, there are options
using Microsoft.Advertising.Mobile.Xna; ... AdManager adManager; Ad bannerAd;
![Page 35: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/35.jpg)
marketplace
• local structure
• test kit in VS2010
• updates
• auto-publish
![Page 36: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/36.jpg)
protect yourself
• ready for obfuscation?
public void d(bp.b A_0) { this.l = A_0; this.i = new List<string>(); this.i.Add(am.a().e("SK_NO")); this.i.Add(am.a().e("SK_YES")); this.g = bo.a; SignedInGamer.SignedIn += new EventHandler<SignedInEventArgs>(this.d); }
![Page 37: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/37.jpg)
![Page 38: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/38.jpg)
news in mango
• silverlight + xna
• fast application switching
• profiling
• combined api for movement
![Page 39: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/39.jpg)
demo
![Page 40: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/40.jpg)
tripeaks solitaire
• fabrication games
• true 3D
• all code in objective-c
![Page 41: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/41.jpg)
-(BOOL) animate { if([self animation] == nil) { [self draw]; return NO; } else { BOOL animationDone = [[self animation] animate]; [self draw]; if (animationDone) { x += [[self animation] currentX]; y += [[self animation] currentY]; z += [[self animation] currentZ]; rotation += [[self animation] currentRotation]; [animations removeObjectAtIndex:0]; } return animationDone; } }
![Page 42: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/42.jpg)
public bool Animate() { if (this.Animation == null) { this.Draw(); return false; } else { bool animationDone = this.Animation.Animate(); this.Draw(); if (animationDone) { x += this.Animation.CurrentX; y += this.Animation.CurrentY; z += this.Animation.CurrentZ; rotation += this.Animation.CurrentRotation; animations.RemoveAt(0); } return animationDone; } }
![Page 43: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/43.jpg)
public bool Animate(GraphicsDevice graphics, BasicEffect effect) { if (this.Animation == null) { this.Draw(graphics, effect); return false; } else { bool animationDone = this.Animation.Animate(); this.Draw(graphics, effect); if (animationDone) { x += this.Animation.CurrentX; y += this.Animation.CurrentY; z += this.Animation.CurrentZ; rotation += this.Animation.CurrentRotation; animations.RemoveAt(0); } return animationDone; } }
![Page 44: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/44.jpg)
demo
![Page 45: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/45.jpg)
future of xna?
• silverlight 5.0
• subset of XNA
• focused on business apps
• windows 8
• leverages directx 11
• likely to attract commercial studios
![Page 47: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/47.jpg)
resources
• create.msdn.com
• jodegreef.wordpress.com - angry pigs
• www.xnaresources.com
• http://msdn.microsoft.com/en-
us/library/bb417503(XNAGameStudio.41).aspx
• programmeramera.se
• www.coderox.se
![Page 48: Real life XNA](https://reader033.fdocuments.us/reader033/viewer/2022052206/554a003fb4c9055b7a8b4ee4/html5/thumbnails/48.jpg)