SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
Introduktion till
Johan Lindfors
windows phone för spel

•   imponerande prestanda
•   sensorer och ”touch”
•   potentiellt xbox-live
•   annonser och trials
harbor master
harvest
tiki towers
doodle fit
ilomilo
xna på 1 minut

•   ett omfattande ramverk för spel
•   integrerad hantering av innehåll
•   spel med 2d och ”sprites”
•   spel med 3d och ”meshes”
•   gemensamma förmågor för pc, wp, xbox
Initialisera   Uppdatera   Rita
hantering av innehåll

•   content pipeline
•   importera vanliga filer
•   optimeras till binärt format
•   utbyggbart
demo
”hardware scaler”

• 800x480       =    384 000 pixlar
• 600x360       =    216 000 pixlar (56%)
• 400x240       =    96 000 pixlar (25%)

 graphics.PreferredBackBufferHeight = 800;
 graphics.PreferredBackBufferWidth = 480;
generellt för prestanda

•   gc är ”enklare” än på pc (för närvarande)
•   allokera objekt tidigt, återanvänd
•   håll reda på stack och heap
•   använd inte foreach
•   använd inte linq
och nu lite 3d

• x, y och z
• kameran beskrivs med matriser
  • vy
  • projektion
• världsmatriser transformerar relativa objekt
  • förflyttning
  • rotation
  • skalning
demo
effekter - shaders

• konfigurerbara
  •   basic
  •   skinned
  •   environmentMap
  •   dualTexture
  •   alphaTest
ljud och musik

•   soundEffect
•   laddas som vanligt innehåll
•   wp kan hantera upp till 64 samtidiga
•   möjligt att förändra
    • ”pitch”
    • volym
    • plats som ljudet spelas upp från
orientering
 graphics.SupportedOrientations =
     DisplayOrientation.Portrait |
     DisplayOrientation.LandscapeLeft |
     DisplayOrientation.LandscapeRight;

• grundinställningen är ”LandscapeLeft”
orientering
 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();
 };
accelerometer
    using Microsoft.Devices.Sensors;



•    mäter acceleration i X, Y och Z
•    värden returneras mellan -1 och +1
•    händelsebaserad
•    läs värden i ”event”, lagra för användning
starta accelerometern
 Accelerometer accel;
 private void startAccelerometer() {
     accel = new Accelerometer();

     accel.ReadingChanged += new
         EventHandler
         <AccelerometerReadingEventArgs>
         (accel_ReadingChanged);

     accel.Start();
 }
läsa accelerometern
 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;
     }
 }
touch

• windows phone hanterar 4 punkter
  • alla punkter har unika id’n
  • pressed | moved | released

 TouchCollection Touches;
 protected override void Update(GameTime gt)
 {
     Touches = TouchPanel.GetState();
     ...
 }
gester

• wp kan också hantera gester
  • tap | drag | hold | flick | pinch ...
 TouchPanel.EnabledGestures =
     GestureType.Flick;

 while (TouchPanel.IsGestureAvailable) {
   GestureSample g = TouchPanel.ReadGesture();
   if (g.GestureType == GestureType.Flick)
   { ... }
 }
nätverksåtkomst

• http, rest, xml...
 void wc_OpenReadCompleted(object sender,
           OpenReadCompletedEventArgs e) {
   if (e.Error == null)
   {
       mapImage = Texture2D.FromStream(
           graphics.GraphicsDevice,
           e.Result);
   }
 }
xbox live

• avatarer och “trials” för alla
• för utvecklare med kontrakt
  •   “profile”
  •   “invites”
  •   riktiga “achievements”
  •   “leaderboards”
  •   “gamerServices”
• kontakta: wpgames@microsoft.com
trial mode

• var kreativ för att driva sälj
 #if DEBUG
     Guide.SimulateTrialMode = true;
 #endif

 bool isTrial = Guide.IsTrialMode;
 ...
 Guide.ShowMarketplace(PlayerIndex.One);

• anrop till IsTrialMode tar 60 ms, cacha!
annonser

• istället för att användaren betalar
• finns inte för svenska applikationer ännu*

 using Microsoft.Advertising.Mobile.Xna;
 ...
 AdManager adManager;
 Ad bannerAd;


     *sanning med modifikation, det finns alternativ
marketplace

•   testa, testa, testa
•   lokal struktur
•   uppdateringar
•   auto-publicering
nyheter i och med mango

•   silverlight + xna
•   exekveringsmodellen
•   profilering
•   kombinerat api för rörelse
demo
tripeaks solitaire

• fabrication games
• äkta 3D
• all kod i objective-c
-(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;
    }
}
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;
    }
}
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;
    }
}
demo
johan.lindfors@infozone.se
så många resurser – så lite tid

• create.msdn.com
• jodegreef.wordpress.com - angry pigs
• www.xnaresources.com

• programmeramera.se
• www.infozone.se
Introduktion till XNA

Más contenido relacionado

Destacado (13)

Aparato circulatorio 4º primaria
Aparato circulatorio 4º primariaAparato circulatorio 4º primaria
Aparato circulatorio 4º primaria
 
1193 dangerous complacency
1193 dangerous complacency1193 dangerous complacency
1193 dangerous complacency
 
122295732677 Photos
122295732677 Photos122295732677 Photos
122295732677 Photos
 
Y3 colour sounds ext unit 23 year 3
Y3 colour sounds ext unit 23 year 3Y3 colour sounds ext unit 23 year 3
Y3 colour sounds ext unit 23 year 3
 
1
11
1
 
Presentation1
Presentation1Presentation1
Presentation1
 
Maravilla
MaravillaMaravilla
Maravilla
 
Seminario Estadual de Agricultura Urbana - programação
Seminario Estadual de Agricultura Urbana - programaçãoSeminario Estadual de Agricultura Urbana - programação
Seminario Estadual de Agricultura Urbana - programação
 
Taller De Dominó
Taller De DominóTaller De Dominó
Taller De Dominó
 
Campaña de recogida de METALES
Campaña de recogida de METALESCampaña de recogida de METALES
Campaña de recogida de METALES
 
Keene State Michael
Keene State MichaelKeene State Michael
Keene State Michael
 
Burnt bread
Burnt breadBurnt bread
Burnt bread
 
Pranav mistry 6th sense technology transcript
Pranav mistry 6th sense technology transcriptPranav mistry 6th sense technology transcript
Pranav mistry 6th sense technology transcript
 

Más de Johan Lindfors

Windows Phone 7.5 (Mango)
Windows Phone 7.5 (Mango)Windows Phone 7.5 (Mango)
Windows Phone 7.5 (Mango)
Johan Lindfors
 
Säker utveckling med SDL
Säker utveckling med SDLSäker utveckling med SDL
Säker utveckling med SDL
Johan Lindfors
 

Más de Johan Lindfors (12)

Being a game developer with the skills you have
Being a game developer with the skills you haveBeing a game developer with the skills you have
Being a game developer with the skills you have
 
MVVM
MVVMMVVM
MVVM
 
Real life XNA
Real life XNAReal life XNA
Real life XNA
 
Windows Phone 7.5 (Mango)
Windows Phone 7.5 (Mango)Windows Phone 7.5 (Mango)
Windows Phone 7.5 (Mango)
 
Windows phone 7
Windows phone 7Windows phone 7
Windows phone 7
 
Metro and Windows Phone 7
Metro and Windows Phone 7Metro and Windows Phone 7
Metro and Windows Phone 7
 
Säker utveckling med SDL
Säker utveckling med SDLSäker utveckling med SDL
Säker utveckling med SDL
 
Windows Mobile 6.5
Windows Mobile 6.5Windows Mobile 6.5
Windows Mobile 6.5
 
Microsoft Net 4.0
Microsoft Net 4.0Microsoft Net 4.0
Microsoft Net 4.0
 
Effektiva gränssnitt med WM 6.5
Effektiva gränssnitt med WM 6.5Effektiva gränssnitt med WM 6.5
Effektiva gränssnitt med WM 6.5
 
Windows Azure - Windows In The Cloud
Windows Azure - Windows In The CloudWindows Azure - Windows In The Cloud
Windows Azure - Windows In The Cloud
 
Att hålla presentationer
Att hålla presentationerAtt hålla presentationer
Att hålla presentationer
 

Introduktion till XNA

  • 2.
  • 3. windows phone för spel • imponerande prestanda • sensorer och ”touch” • potentiellt xbox-live • annonser och trials
  • 9. xna på 1 minut • ett omfattande ramverk för spel • integrerad hantering av innehåll • spel med 2d och ”sprites” • spel med 3d och ”meshes” • gemensamma förmågor för pc, wp, xbox
  • 10. Initialisera Uppdatera Rita
  • 11. hantering av innehåll • content pipeline • importera vanliga filer • optimeras till binärt format • utbyggbart
  • 12. demo
  • 13. ”hardware scaler” • 800x480 = 384 000 pixlar • 600x360 = 216 000 pixlar (56%) • 400x240 = 96 000 pixlar (25%) graphics.PreferredBackBufferHeight = 800; graphics.PreferredBackBufferWidth = 480;
  • 14. generellt för prestanda • gc är ”enklare” än på pc (för närvarande) • allokera objekt tidigt, återanvänd • håll reda på stack och heap • använd inte foreach • använd inte linq
  • 15. och nu lite 3d • x, y och z • kameran beskrivs med matriser • vy • projektion • världsmatriser transformerar relativa objekt • förflyttning • rotation • skalning
  • 16. demo
  • 17. effekter - shaders • konfigurerbara • basic • skinned • environmentMap • dualTexture • alphaTest
  • 18. ljud och musik • soundEffect • laddas som vanligt innehåll • wp kan hantera upp till 64 samtidiga • möjligt att förändra • ”pitch” • volym • plats som ljudet spelas upp från
  • 19. orientering graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; • grundinställningen är ”LandscapeLeft”
  • 20. orientering 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(); };
  • 21. accelerometer using Microsoft.Devices.Sensors; • mäter acceleration i X, Y och Z • värden returneras mellan -1 och +1 • händelsebaserad • läs värden i ”event”, lagra för användning
  • 22. starta accelerometern Accelerometer accel; private void startAccelerometer() { accel = new Accelerometer(); accel.ReadingChanged += new EventHandler <AccelerometerReadingEventArgs> (accel_ReadingChanged); accel.Start(); }
  • 23. läsa accelerometern 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; } }
  • 24. touch • windows phone hanterar 4 punkter • alla punkter har unika id’n • pressed | moved | released TouchCollection Touches; protected override void Update(GameTime gt) { Touches = TouchPanel.GetState(); ... }
  • 25. gester • wp kan också hantera gester • tap | drag | hold | flick | pinch ... TouchPanel.EnabledGestures = GestureType.Flick; while (TouchPanel.IsGestureAvailable) { GestureSample g = TouchPanel.ReadGesture(); if (g.GestureType == GestureType.Flick) { ... } }
  • 26. nätverksåtkomst • http, rest, xml... void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { mapImage = Texture2D.FromStream( graphics.GraphicsDevice, e.Result); } }
  • 27. xbox live • avatarer och “trials” för alla • för utvecklare med kontrakt • “profile” • “invites” • riktiga “achievements” • “leaderboards” • “gamerServices” • kontakta: wpgames@microsoft.com
  • 28. trial mode • var kreativ för att driva sälj #if DEBUG Guide.SimulateTrialMode = true; #endif bool isTrial = Guide.IsTrialMode; ... Guide.ShowMarketplace(PlayerIndex.One); • anrop till IsTrialMode tar 60 ms, cacha!
  • 29. annonser • istället för att användaren betalar • finns inte för svenska applikationer ännu* using Microsoft.Advertising.Mobile.Xna; ... AdManager adManager; Ad bannerAd; *sanning med modifikation, det finns alternativ
  • 30. marketplace • testa, testa, testa • lokal struktur • uppdateringar • auto-publicering
  • 31. nyheter i och med mango • silverlight + xna • exekveringsmodellen • profilering • kombinerat api för rörelse
  • 32. demo
  • 33.
  • 34. tripeaks solitaire • fabrication games • äkta 3D • all kod i objective-c
  • 35. -(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; } }
  • 36. 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; } }
  • 37. 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; } }
  • 38. demo
  • 40. så många resurser – så lite tid • create.msdn.com • jodegreef.wordpress.com - angry pigs • www.xnaresources.com • programmeramera.se • www.infozone.se