<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>John's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/johnkenn/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/johnkenn/feed.xml</link>
    <description>Apps for Windows</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:11:47 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Hack Arizona</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/hack-arizona</link>
      <pubDate>Tue, 17 Jan 2017 19:10:37 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=3005</guid>
      <description><![CDATA[I spent the weekend stepping over bodies - both real and virtual - at the Hack Arizona event in...]]></description>
      <content:encoded><![CDATA[I spent the weekend stepping over bodies - both real and virtual - at the <a href="http://hackarizona.org">Hack Arizona</a> event in Tucson. As part of the Microsoft sponsorship team, we flew down (bringing the rain with us, you're welcome) and gave demos, talks and prizes to the hard-working sleep-deprived hackers who were spending 36 hours bringing their projects to life. It was genuinely wonderful to see the passion of this &gt; 900 crowd of designers and developers, working hard to make their dreams into reality in exchange for fame, glory and (for some!) really good prizes.

One of the discoveries which surprised me the most was the number of Windows laptops in use. I was expecting there to be more glowing Apple logos to be perfectly honest, and it was refreshing to see Windows being used as the OS of choice.

We had a fun time showing off the HoloLens, and our Surface Books, and just chatting about Microsoft with so many interested and interesting students. It did leave me with a few thoughts:
<ul>
 	<li>Windows 10 would make life so much easier for many of the hackers. Having access to the Bash shell without various hoops would just simplify things so much.</li>
 	<li>Microsoft has so many development tools (Visual Studio, Azure, Cognitive Services) that would have made the hacking projects just that little bit easier to get going. We definitely need to get the word out!</li>
</ul>
By Sunday, everyone was exhausted and yet excited enough to make some really great demos for us to judge. There was an amazing array of projects, from apps designed to improve society, to VR training sims and even a beer-pong score keeper (hey, it was an a university ;-) But no matter the project, the enthusiasm of the teams and willingness to put in 36 hours of effort was very impressive. Students slept on floors, passed out from sheer hard work, and woke up again with possibly dangerous levels of energy drinks in their bloodstream to get right back to work. It was amazing! Well done to everyone who took part.

&nbsp;

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Get started writing games for Windows 10 - Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/get-started-writing-games-for-windows-10-part-2</link>
      <pubDate>Fri, 23 Dec 2016 19:27:36 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2985</guid>
      <description><![CDATA[Happy Holidays! Way back in Part 1, we looked at how to set up a Windows 10 UWP app that would use...]]></description>
      <content:encoded><![CDATA[Happy Holidays! Way back in <a href="https://blogs.msdn.microsoft.com/johnkenn/2016/11/23/get-started-writing-game-for-window-10/">Part 1</a>, we looked at how to set up a Windows 10 UWP app that would use MonoGame to draw some sprites on the screen. If you are wondering how to move things around the screen in a non-XAML kind of way, MonoGame is perhaps one of the simplest ways to get started. It adds APIs for creating and drawing sprites, and frankly that's all you need to write the kind of simple games we enjoyed until about 1985!

Now we can take the app we created, and take it a little further. Nothing fancy: but it'll introduce collision detection and using a Microsoft Dial as a game controller. It's certainly something you can build upon and experiment with. In fact, if you don't have a Surface Book and Microsoft Dial, you will need to experiment a little in order to get it to do anything. Don't worry, I'm not going to make you retype anything: you can <a href="https://github.com/GrantMeStrength/Bat-and-Ball-and-Dial">find it all here on GitHub</a>.
<h2>Bat and Ball and Dial</h2>
And here it is. Enjoy the beauty that three different sprite textures and the mostly basic "physics" can create.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/batball.png"><img width="454" height="303" class="alignnone  wp-image-2995" alt="Simple (very) game." src="https://msdnshared.blob.core.windows.net/media/2016/12/batball.png" /></a>
<h2>The Basics</h2>
This a simple hit-the-ball-back-and-destroy-the-blocks game. Move the bat, hit the ball back (or don't - at the moment, it'll just bounce off the bottom of the screen) and try to hit all the blocks. Moving the block is done with the Dial, and the ball just updates it's position every game iteration. There's a check to see if the ball has hit anything, or the edge of the screen, and that's all there is to it. It is ripe for your improvements.

Open up the project in Visual Studio, and you'll see it doesn't contain very much that isn't boilerplate. The only files you need to worry about are <strong>Game1.cs</strong> and <strong>SpriteClass.cs</strong>. There are also some PNG files for the ball, bat and brick.

The <strong>SpriteClass.cs</strong> code is used by the ball, bat and all the blocks. It contains the texture associated with the sprite (the PNG file, created in Photoshop), and keeps track of the X,Y co-ordinates that define where on the screen the sprite will be displayed. Some extra values (DX,DY) are also available to store in which direction the ball is moving. A bool to define the sprite as circular is also used (it is required for the collision detection stuff). The <strong>SpriteClass</strong> also contains the drawing code which actually displays the sprite. There's an optional <strong>DrawColor</strong> method which is used when drawing the bricks to use the <strong>tintColor</strong> to change their appearance.

The <strong>Game1.cs</strong> file does the hard work of creating the sprite objects, and in the <strong>Update</strong> method the location of the ball is updated and any collisions between the ball and bat, or ball and bricks is checked for. Rather than update the ball's location with the same value every time <strong>Update</strong> is called, the time difference between previous loop is used: this keeps the movement at the same speed no matter what PC hardware you are using. That is what this code is about:
<pre> ball.X += ball.DX * (float)gameTime.ElapsedGameTime.TotalSeconds;
 ball.Y += ball.DY * (float)gameTime.ElapsedGameTime.TotalSeconds;</pre>
<h2>Scaling issues</h2>
If you are using a Windows computer with a high density pixel display, <a href="https://blogs.windows.com/buildingapps/2016/10/24/high-dpi-scaling-improvements-for-desktop-applications-and-mixed-mode-dpi-scaling-in-the-windows-10-anniversary-update/#rcpf0gJQ0R2s8Sq8.97">you might sometime see some scaling issues</a>. For example, the MonoGame template for UWP apps seems to need a little help in order to get accurate values for the size of the screen. If you look in <strong>Game1.cs</strong>, you'll see the following code:
<pre>ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;

screenHeight = (float)ApplicationView.GetForCurrentView().VisibleBounds.Height;
 screenWidth = (float)ApplicationView.GetForCurrentView().VisibleBounds.Width;

 // Take high density screens into account, such as Surface Pro
 DisplayInformation d = DisplayInformation.GetForCurrentView();
 screenHeight *= (float)d.RawPixelsPerViewPixel;
 screenWidth *= (float)d.RawPixelsPerViewPixel;</pre>
This tries to make sure the screen height and width values returned are a little more sensible. However, the rest of the app pretty much ignores this information, so if you try the game and the bricks are all over the place and the bat is missing, start looking at the hard-coded values for X,Y co-ordinates and maybe divide them by two to see what happens.
<h2>Collision detection</h2>
MonoGame doesn't come out of the box with built-in collision detection, but it's easy to implement a simple version based on overlapping rectangles or rectangles and circles. You'll find the code in the <strong>SpriteClass</strong>, and it includes a few different kinds to best match your sprites. In this particular game, the Rectangle-to-Circle is all you need, and it look like this:
<pre>bool RectangleAndCircleCollision(SpriteClass otherSprite)
 {
  float r2 = otherSprite.texture.Width / 2;

 if (this.X + this.texture.Width/2 &lt; otherSprite.X - r2) return false;
 if (this.Y + this.texture.Height/2 &lt; otherSprite.Y - r2) return false;
 if (this.X - this.texture.Width / 2 &gt; otherSprite.X + r2) return false;
 if (this.Y - this.texture.Height / 2 &gt; otherSprite.Y + r2) return false;
 return true;
 }
}</pre>
All it does it make sure the objects are not overlapping. It's called the "bounding box" approach.

&nbsp;
<h2>Dial support</h2>
<img width="284" height="160" alt="It's silver and round. You wouldn't want to try eating it." src="https://dri1.img.digitalrivercontent.net/Storefront/Company/msintl/images/English/en-INTL-Surface-Campo-2WR-00001/en-INTL-XL-Surface-Campo-2WR-00001-mnco.jpg" />

The Microsoft Dial shipped as part of the Surface Studio, but it's also available separately for $99 from the Microsoft Store. It connects via Bluetooth to a number of compatible computers, including the Surface Pro and the Surface Book I used for development. You need to be running Windows 10 Anniversary Update for it to work (and make sure any new Visual Studio project you create is set for that version of Windows too).

There are a <a href="https://channel9.msdn.com/Blogs/One-Dev-Minute/Programming-the-Microsoft-Surface-Dial">few magic spells required to configure it</a>, and then you just sit back and let the handler get called every time the user rotates or clicks on it. It returns an angle, which is easy to transform into the X co-ordinate for the Bat. This game also waits until the user clicks on the Dial to start.

If you don't have a Dial to play with, you're going to have to add your own keyboard or mouse handling code to make sure the ball starts moving and the bat position changes. You could use a touch screen, or something more esoteric like the angle at which the tablet is being held to control how the bat moves.
<h2>That's about it..</h2>
There's not much more to say! This app simply demonstrates how easy it is to create a UWP game using moving sprites, and even to make use of the latest hardware such as the Dial. As it's a UWP app, you can fix it up and submit it to the Microsoft Store to distribute it. And even port it with minor changes to run on the Xbox (haha! it might look a little primitive on the Xbox! :-) and even HoloLens. Got any questions? Just post in comments.]]></content:encoded>
    </item>
    <item>
      <title>Popular apps on Mac vs. Windows</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/popular-apps-on-mac-vs-windows</link>
      <pubDate>Fri, 16 Dec 2016 18:18:43 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2965</guid>
      <description><![CDATA[Thinking of switching / dual-OS-using Mac and Windows, but not sure if your favorite app is...]]></description>
      <content:encoded><![CDATA[Thinking of switching / dual-OS-using Mac and Windows, but not sure if your favorite app is available?

Here's a list of the apps I use. Which ones do <span style="text-decoration: underline">you</span> need?

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-16-at-10.16.44-AM.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-16-at-10.16.44-AM.png" alt="screen-shot-2016-12-16-at-10-16-44-am" width="472" height="494" class="alignnone size-full wp-image-2975" /></a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>How to build and run a HoloLens app in Unity using the Emulator</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/how-to-build-and-run-a-unity-hololens-app-using-the-emulator</link>
      <pubDate>Wed, 07 Dec 2016 20:52:04 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2875</guid>
      <description><![CDATA[Here's how to set up a development environment to write HoloLens apps, even if you don't have a...]]></description>
      <content:encoded><![CDATA[Here's how to set up a development environment to write <a href="https://www.microsoft.com/microsoft-hololens/en-us/developers">HoloLens</a> apps, even if you don't have a HoloLens. You will need a PC running the latest Windows 10, a game controller and a copy of Unity. The free <em>Personal</em> edition of Unity, will work fine.

It won't do any harm to have Visual Studio installed too as it makes a good C# editor (along other things ;-) ). You can also use <a href="http://code.visualstudio.com/?utm_expid=101350005-35.Eg8306GUR6SersZwpBjURQ.0&amp;utm_referrer=http%3A%2F%2Fcode.visualstudio.com%2F%3Fwt.mc_id%3DDX_573435%26utm_source%3Dgoogle%26utm_medium%3Dpaid%26utm_content%3D1%26utm_campaign%3DCorp-FY16Q3March-Dev-PJVS%26gclid%3DCjwKEAiAg5_CBRDo4o6e4o3NtG0SJAB-IatY5KPwcD5iCkR5pxvQj62ApJh9E8eG6nJmapsAJIj5bRoCdvXw_wcB">Visual Studio Code</a> for editing.
<ul>
 	<li>Install the latest version of <a href="http://www.unity.com">Unity</a>.

IMPORTANT:  During installing, make sure to select <b>Windows Store .NET Scripting Backend</b>. If you omit this, (you will know you have if you find various menu options discussed later are missing) you will not be able to build <a href="https://msdn.microsoft.com/en-us/windows/uwp/get-started/whats-a-uwp">UWP</a> apps, and that means HoloLens apps. If you discover that you did forget to install it, you can re-launch the <b>Unity Download Assistant</b> (it will be in your Downloads folder) and check the box.</li>
 	<li>Create a new 3D project.</li>
 	<li>Add something to the scene to look at - a Cube for example. When you've done this, click<b> File</b> / <b>Save Scene</b> to save this view.</li>
 	<li>Select the <b>Main Camera</b>, and in the Inspector, change <b>Background</b> from <b>SkyBox</b> to <b>Solid Color</b>, and make the color (0,0,0). When drawing Holograms, you don't want any background blocking your view of the real world.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl1.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl1.png" alt="hl1" width="295" height="209" class="alignnone wp-image-2885" /></a></li>
 	<li>Go <b>File</b> / <b>Build Settings</b> and select <b>Windows Store</b> for <b>Platform</b>. Then click <b>Switch Platform</b> to make it stick. Can't do this?<i> See Step 1</i>.</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl2.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl2.png" alt="hl2" width="464" height="450" class="alignnone wp-image-2895" /></a>
<ul>
 	<li>Click <b>Add Open Scenes</b> so there is something to build.</li>
 	<li>For <b>Target Device</b>, click the pull-down and select <b>HoloLens</b>.</li>
 	<li>Click <b>Player Settings</b> and in the view that opens on the right, expand <b>Other Settings</b> and check <b>Virtual Reality Supported</b>. <em>Windows Holographic</em> should be selected as the Virtual Reality SDK.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl3.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl3.png" alt="hl3" width="301" height="252" class="alignnone wp-image-2905" />
</a></li>
 	<li>Close the <b>Build Settings</b> window</li>
 	<li>Click on the menu option <b>Window</b> / <b>Holographic Emulation</b>. If you have followed the previous steps, you'll now have the option of selecting the <b>Emulation Mode</b>. Change it to <b>Simulated in Editor</b>.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl4.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl4.png" alt="hl4" width="273" height="153" class="alignnone wp-image-2866" /></a></li>
 	<li>Click on the Unity <b>Play</b> button, and the app will start. Use the game controller to look around the scene. Admittedly, the scene isn't very exciting at this point, as it's one white cube in a vast empty universe.</li>
 	<li>Let's make things a little more interesting by adding some environmental details. HoloLens uses technique called<a href="https://developer.microsoft.com/en-us/windows/holographic/spatial_mapping"><i> Spatial Mapping</i></a> to capture the user's surroundings. Select the <b>Main Camera</b>, and from the <b>Component</b> menu, go to <b>AR</b> and <b>Spatial Mapping Renderer</b>.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl5.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl5.png" alt="hl5" width="251" height="266" class="alignnone wp-image-2925" />
</a></li>
 	<li>View the <b>Spatial Mapping Renderer</b>'s properties in the Inspector, and change <b>Render State</b> from <b>Occlusion</b> (which simply blocks you from seeing objects that are hidden) to <b>Visualization</b> (which draws the 'fake' spatial data).</li>
 	<li>Ensure the <b>Window</b> / <b>Holographic Emulation</b> window is open, select a room, and click <b>Play</b> again. You should be able to walk around the virtual room using the game controller. The room data will update at a similar rate to a real HoloLens, so there will be a tiny delay before the room appears.</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl6.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl6.png" alt="hl6" width="1721" height="924" class="alignnone size-full wp-image-2915" /></a>

<b>Interacting with the Spatial Room Data</b>

&nbsp;
<ol>
<ol>
 	<li>The spatial data we added isn't just for looks either: we can make our virtual objects interact with it. First, select <b>Main Camera</b> again, and go to <b>Components</b> /  <b>AR</b> and now add <b>Spatial Mapping Collider</b>.</li>
 	<li>Next we'll create a ball object which we can throw around. We'll actually create a Unity <a href="https://docs.unity3d.com/Manual/Prefabs.html"><i>prefab</i></a> object which is a template from which multiple objects can be quickly created.</li>
 	<li>Start by creating sphere 3D object, and change its scale to be (0.1, 0.1, 0.1).</li>
 	<li>Select the sphere, and in the <b>Inspector</b> panel click on <b>Add Component</b>, and add <b>Physics</b> / <b>Rigidbody</b>. This provides the sphere with some physical properties, so it can bounce off things.</li>
 	<li>Drag the sphere you created from the <b>Scene hierarchy</b> view on the left, to the <b>Assets</b> view at the bottom of the screen. This creates a <i>Prefab</i> object from the sphere. You can now click on the sphere in the hierarchy view and delete it from the scene. We'll create the spheres programmatically in a script instead, based on the prefab.</li>
 	<li>In the <b>Assets</b> view, right click and select <b>Create</b> /<b> C# Script. </b>Double-click the script object, and it'll open in whatever the default editor happens to be.</li>
 	<li>Edit the script to read like this:</li>
</ol>
</ol>
&nbsp;
<pre>using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BallShooter : MonoBehaviour {
    public Rigidbody ball;
    void Start () {
}

// Update is called once per frame

void Update () {
        if (Input.GetButton("Fire1") )
        {
            Rigidbody clone = (Rigidbody) Instantiate(ball, transform.position, transform.rotation);
            clone.velocity = transform.forward * 10f;
            Destroy(clone.gameObject, 3);
        }
    }
}</pre>
&nbsp;
<ol>
 	<li>Save the script, and return to the Unity editor. There are just a few more steps we need to do to wrap this up: specifically, linking the sphere prefab object with the reference to the<strong> public Rigidbody</strong> <b>ball</b> object declared in the script.</li>
 	<li>First, drag the script from <strong>Assets</strong> onto the <b>Main Camera</b> object so that it will actually be called. Once you do this, select the <b>Main Camera</b> to see script listed in the <strong>Inspector</strong>.</li>
 	<li>From the <strong>Assets</strong> panel, drag the sphere object to the <strong>Inspector</strong> view and drop it where it says <strong>Ball</strong>.

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl7.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl7.png" alt="hl7" width="557" height="350" class="alignnone wp-image-2945" />
</a></li>
 	<li>Now when you click <b>Play</b>, press <b>A</b> on the game controller and you will find yourself throwing multiple balls into the scene. Notice how they bump and roll over the wireframe walls and furniture in the view.
At this point a light bulb may be going on over your head: yes, when you are using a <i>real</i> HoloLens, the room data will be the room you are <i>actually</i> standing in, and yes, your game objects will bounce off the <i>actual</i> furniture in your actual room. Isn't that wild?
<a href="https://msdnshared.blob.core.windows.net/media/2016/12/hl8.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/hl8.png" alt="hl8" width="1411" height="1036" class="alignnone size-full wp-image-2935" /></a></li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>Keyboard and Trackpad shortcuts for Mac vs. Windows</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/keyboard-and-trackpad-shortcuts-for-mac-vs-windows</link>
      <pubDate>Tue, 06 Dec 2016 23:18:04 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2845</guid>
      <description><![CDATA[Updated: Added a few more

If you're moving between a Mac system and a Windows 10 system, you...]]></description>
      <content:encoded><![CDATA[<strong>Updated: Added a few more</strong>

If you're moving between a Mac system and a Windows 10 system, you might find you'll need to reconfigure your muscle memory a little. Here's a handy summary if you need help. You also might find a useful shortcut you haven’t used before..

<strong>Keyboard shortcuts</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-12-at-10.05.56-AM.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-12-at-10.05.56-AM.png" alt="screen-shot-2016-12-12-at-10-05-56-am" width="485" height="551" class="alignnone size-full wp-image-2955" /></a>

<strong>Trackpad shortcuts</strong>

<em>Note: On a PC, some of these require a “Precision Trackpad” which comes with Surface devices and some other third party laptops.</em>

<a href="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-06-at-3.15.01-PM.png"><img src="https://msdnshared.blob.core.windows.net/media/2016/12/Screen-Shot-2016-12-06-at-3.15.01-PM.png" alt="screen-shot-2016-12-06-at-3-15-01-pm" width="456" height="516" class="alignnone size-full wp-image-2865" /></a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Get started writing games for Windows 10 - Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/get-started-writing-game-for-window-10</link>
      <pubDate>Wed, 23 Nov 2016 19:53:10 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2835</guid>
      <description><![CDATA[If you've been writing iOS or Android games and apps, you might have glanced at Windows and though...]]></description>
      <content:encoded><![CDATA[If you've been writing iOS or Android games and apps, you might have glanced at Windows and though "Hmm, well, Windows is all C# and XAML, so unless my game is 'Database Simulator V' that's not going to be much fun". And you might have a point: it's true XAML isn't suited to apps like games, but on the other hand, there now more frameworks and tools available on Windows than ever before. I'd go so far and say there's never been a better time to start writing games for Windows. If anything, with so many different choices, it can be rather confusing to know how to get started.

So, let's get down to some basics and ask the obvious question: "What should you use to write a game that you want to publish in the Windows Store?"

The answer you get is going to depend on who you ask, and what kind of game you want to write. 2D? 3D? It will also depend on if you want to go cross-platform, and it will depend on your choice of programming language.

But since I'm writing this, you're going to get my opinion. My favorite type of game to write is 2D and Sprite based. I like the retro classics, and I've writing them since before they were retro. So, on iOS I am a big fan of the SpriteKit framework. I've been looking around for the closest equivalent, and the answer seems to be <em>MonoGame</em>. MonoGame, if you didn't know, is what happened to Microsoft's XNA game framework. MonoGame is now open source and cross-platform. You can even use Xamarin to write MonoGame apps and run them on everything from iPhones to Xboxes.

So let's start here. I'm assuming you have Windows 10 running, and Visual Studio 2015 installed.
<h2>Part 1 - Getting the tools installed</h2>
1. Install <strong>MonoGame 3.5</strong> for Visual Studio from <a href="http://www.monogame.net">MonoGame.net</a>

2. Launch Visual Studio 2015, and go to <strong>File</strong> / <strong>New</strong> / <strong>Project</strong>

3. Under the Visual C# project templates, select <strong>MonoGame</strong> and <strong>MonoGame Windows 10 Universal Project</strong>

4. Pick a name for your app, and click on <strong>OK</strong>.

5. Have a little cry because the template is broken and you get an error. :-(

6. Have a cup of tea. Resolve to fix this.

7. Find the MonoGame templates. They have (perhaps unexpectedly) been installed into: <strong>C:\Users\USER\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C#\Visual C#\MonoGame</strong>

8. Unzip the template <strong>WindowsUniversal.zip</strong>, and explore its contents.

9. Find the file called <strong>WindowsUniversal.vstemplate</strong> and open it in a XML editor.

10. Locate the XML that looks like this, and delete it:

<code>&lt;wizardextension&gt;
</code><code>  &lt;assembly&gt;Microsoft.VisualStudio.WinRT.TemplateWizards, Version=14.0.0.0, Culture=neutral, PublicKeyToken = b03f5f7f11d50a3a&lt;/assembly&gt;
&lt;fullclassname&gt; Microsoft.VisualStudio.WinRT.TemplateWizards.ApplicationInsights.Wizard\&lt;/fullclassname&gt;&lt;/wizardextension&gt;</code>

11. Save the file. Delete the original template file <strong>WindowsUniversal.zip</strong>.

12. Restart Visual Studio.

13. Go to <strong>File</strong> / <strong>New</strong> / <strong>Project</strong>

14. Under the Visual C# project templates, select <strong>MonoGame</strong> and <strong>MonoGame Windows 10 Universal Project</strong>

15. Pick a name for your project (different from Step 4), and click OK.

16. Your project will be created. It will look as though there are errors, until you build it for the first time as this triggers the installation of some nuget packages.

17. Make sure <strong>x86</strong> and <strong>Local Machine</strong> are set as a target platform, and build and run the empty project: if it's working, you will see a beautiful, blue window.
<h2>Part 2 - Getting something onto the screen</h2>
1. Starting with your empty MonoGame project, drag in a PNG image to act as a sprite. Place the image in the <strong>Content</strong> directory for now.

<em>Note: MonoGame supports a "content pipeline", which is a separate tool that processes images and sounds and other files into a resource that your app can use. For larger projects, it makes sense to use the pipeline. For small apps like this, directly loading the image from file is fine.</em>

2. Open the file<strong> Game1.cs</strong>, which the template has created for you. This file contains the main functions that are called when are app is running, including <strong>Initialize()</strong>, <strong>Update()</strong> and <strong>Draw()</strong>.

3. Let's create a texture - the property that stores an image. Under

<code>SpriteBatch spriteBatch;</code>

add:

<code>Texture2D spaceshipTexture;</code>

4. In the <strong>LoadContent()</strong> method, add the following code to load the PNG file and assign it to a Texture2D object:

<code>
using (var stream = TitleContainer.OpenStream("Assets/SpaceShip.png"))
{
spaceshipTexture = Texture2D.FromStream(this.GraphicsDevice, stream);
}
</code>

5. Now we can draw the texture by updating the <strong>Draw()</strong> method to include the following:
<pre>protected override void Draw(GameTime gameTime)
 {
 GraphicsDevice.Clear(Color.CornflowerBlue);
 spriteBatch.Begin();
 Vector2 spritePosition = new Vector2(100, 100);
 Color tintColor = Color.White;
 spriteBatch.Draw(spaceshipTexture, spritePosition, tintColor);
 spriteBatch.End();
 base.Draw(gameTime);
 }</pre>
That's how easy it is to create a sprite and draw it, using MonoGame. What next? Let's see how to move and control things. Stay tuned!]]></content:encoded>
    </item>
    <item>
      <title>Getting unblocked</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/getting-unblocked</link>
      <pubDate>Fri, 15 Jul 2016 17:41:50 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2815</guid>
      <description><![CDATA[Who doesn't love writing games? Only people who don't know it, IMHO.

I was recently working on a...]]></description>
      <content:encoded><![CDATA[Who doesn't love writing games? Only people who don't know it, IMHO.

I was recently working on a simple sprite-based game to run on iOS (for reasons which should become clear at some point), and was having fun creating classes for aliens, explosions and lasers.

<a href="https://msdnshared.blob.core.windows.net/media/2016/07/sprites.jpg" rel="attachment wp-att-2825"><img class="alignnone size-medium wp-image-2825" src="https://msdnshared.blob.core.windows.net/media/2016/07/sprites-300x185.jpg" alt="Sprite-base game" width="300" height="185" /></a>

Eventually I had the laser class working fine, blowing up flying saucers, but I wanted to trigger an big bang  from the explosion class at the correct location.

As all my sprite classes were quite separate, it seemed messy to pass around all the details required to trigger an explosion at the right co-ordinates, and so I wrote some Block-based code to do it. This made me happy, as Blocks - and in <a href="http://goshdarnblocksyntax.com/">particular the syntax for Blocks </a>- always seem a little like black magic to me.

Here is the method that needed calling to trigger the explosion:

<code>-(void)explodeAt: (CGPoint) p
{
[explosions explode:p :_baseEffect];
}</code>

Here, <strong>_baseEffect </strong>is the property that is required for the sprite rendering so don't worry about that, but <strong>p</strong> is the location where the explosion should happen and that is important. I needed to call this method from the code that did the collision testing between the alien bad guys and the lasers. Here is how I passed that method into the testing code:

<code>// Check for collisions between lasers and UFOs
[badguys CollisionTestAndExplode: [lasers getAllLasers] : ^void (CGPoint p) { [self explodeAt : p]; }];
</code>

Over in the lasers class, here is how that <strong>CollisionTestAndExplode</strong> method works and how it calls the <strong>explodeAt </strong>method:

<code>// The array of sprites is provided, and checked against the UFO array.
// If there is a collection, the object is deleted, and explosion triggered

-(bool)CollisionTestAndExplode: (NSMutableArray *) targetSprites : (void (^)(CGPoint p))explodeAt
{
bool collision = false;
NSMutableArray *destroyed = [NSMutableArray array];
for (SpriteClass *s in targetSprites)
{
for (Ufo *u in _ufos)
{
if (CGRectIntersectsRect( [u getRect] , [s getRect] ))
{
explodeAt(s.spritePosition);
[destroyed addObject:u];
collision = true;
}
}
}</code>

It's one of those things that looks very simple in retrospect, but at the time takes about an hour of trial and error get to sorted. In other words, this blog posting is my victory nerd dance and memorandum all in one.]]></content:encoded>
    </item>
    <item>
      <title>Getting used to Zero</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/getting-used-to-zero</link>
      <pubDate>Thu, 05 May 2016 15:38:58 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2795</guid>
      <description><![CDATA[Some stats after two weeks of riding around on my new Zero electric motorcycle:

Miles:...]]></description>
      <content:encoded><![CDATA[Some stats after two weeks of riding around on my new <a title="Zero, California" href="http://www.zeromotorcycles.com/">Zero electric motorcycle</a>:

Miles: 160

Cost to recharge: Less than a Starbucks latte

Number of times I tried to grab a clutch lever that wasn't there: 1
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/IMG_0456.jpg"><img class="alignnone size-medium wp-image-2806" src="https://msdnshared.blob.core.windows.net/media/2016/05/IMG_0456-300x169.jpg" alt="IMG_0456" width="300" height="169" /></a>

Number of times I got into the lift at work and pressed "1" expecting it to take me to the "first" floor above: 1
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/IMG_0564-e1462462473328.jpg"><img class="alignnone size-medium wp-image-2805" src="https://msdnshared.blob.core.windows.net/media/2016/05/IMG_0564-e1462462473328-225x300.jpg" alt="American floor numbering still floors me" width="225" height="300" /></a>]]></content:encoded>
    </item>
    <item>
      <title>Zero chance of going back to gas.</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/zero-chance-of-going-back-to-gas</link>
      <pubDate>Fri, 22 Apr 2016 21:45:31 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2725</guid>
      <description><![CDATA[We're all nerds here, right? Yeah, thought so.

So what do nerds like doing? Being early adopters,...]]></description>
      <content:encoded><![CDATA[We're all nerds here, right? Yeah, thought so.

So what do nerds like doing? Being early adopters, right? And if you're a nerd that also like riding motorcycles (I've finally started to say that instead of the more UK-centric 'motorbikes'), then you pretty much have no choice <em>but</em> to get an electric bike from <a title="Took about a week from order to deliver to the dealer in Seattle." href="http://www.zeromotorcycles.com">Zero</a>, right?

I've been thinking about getting a Zero ever since I read about them a few years ago, and <em>really</em> thinking about it every since doing a test ride on one whilst my Triumph was in getting an annual service. Riding home on the Triumph after the Zero ride was the clincher: what would I prefer? A noisy, smoking (albeit retro-cool) riding machine, or one which glides by with a whirr and enough acceleration to make me swallow my teeth? And then there's a tax refund deal for US folks, and a special offer from Zero for this month, and anyway Triumph just updated my model so it looks old and even more clunky now.. and just sign here you say? Sure, don't mind if I do. And a week later, here's me:

&nbsp;

[caption id="attachment_2735" align="alignnone" width="225"]<a href="https://msdnshared.blob.core.windows.net/media/2016/04/IMG_0483-e1461360678712.jpg"><img class="wp-image-2735 size-medium" src="https://msdnshared.blob.core.windows.net/media/2016/04/IMG_0483-e1461360678712-225x300.jpg" alt="I'm a daft punk" width="225" height="300" /></a> I'm smiling under there[/caption]

&nbsp;

I have been commuting all week on my new SR model, and so far that has cost me about $0.50 in electricity. I've also been grinning a lot, and answering a lot of questions:

Q. Who makes Zero?
A. <a title="And there's a tax rebate too!" href="http://www.zeromotorcycles.com">Zero</a> in California.

Q. Where's the clutch?
A. There isn't one. There are no gears. Just twist it.

Q. What's the range?
A. About 160 miles in commuter type traffic, 80 miles if going faster.

Q. How long does it take to charge?
A. After my commute, one or two hours. From flat, about 8 hours using a standard 110 volt socket. I could get a fast charger fitted to if it that was a problem (it isn't so far).

Q. Isn't it dangerous as it makes no sound?
A. Well, it makes some sound. Not enough for the guy I was riding behind yesterday who was driving wearing over-the-ear headphones to hear me, that's for sure.

Q. How fast does it go?
A. Very fast. The specs say 0 to 60 in 3.3 seconds and over 100 mph top speed. I'm still cautious so I'm using it in "Eco" mode, which is less crazy than "Sport" mode.

Q. How many times have you grabbed the missing clutch lever?
A. Six times this week.

Q. Any regrets?
A. So far, not so much. I wish the mirrors were a little better spaced, and it's tricky to see the speedo as the position is a little more sit-up than my Thruxton, but it's very comfy so far. I wouldn't mind getting a <a title="HoloLens? Sure, but I think this is safer while riding." href="https://www.skully.com">Skully</a> helmet to help with the visibility issues.

Q. Does it come with an app?
A. Haha, yes - you can choose between Eco and Sport modes, or define your own custom mode using your iPhone or Android device and syncing over BlueTooth. No SDK yet, or I'd be thinking about how to get Windows support on there..

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Family Notes: a Windows UWP Sample with Voice, Ink and Face recognition</title>
      <link>https://docs.microsoft.com/archive/blogs/johnkenn/introducing-the-virtual-fridge</link>
      <pubDate>Thu, 14 Apr 2016 18:08:50 GMT</pubDate>
      <dc:creator><![CDATA[grantmestrength]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/johnkenn/?p=2676</guid>
      <description><![CDATA[If you watched the Build keynote this year, you would have seen a lot of emphasis on the Windows 10...]]></description>
      <content:encoded><![CDATA[If you watched the <a title="I didn't go to Build this year." href="https://channel9.msdn.com/Events/Build/2016/KEY01">Build keynote</a> this year, you would have seen a lot of emphasis on the Windows 10 features that focus on a more <em>personal</em> aspect of computing. This can sound kinda vague, but it boils down to making software which is easier to use, more intuitive and just plain smarter. After all, we've now got these incredibly powerful, always-computers computers around us all the time: from the phones in our pockets to the PCs on our desks, and it's unlikely we're even using 10% of their brains most of the time. As automagical services like deep learning engines start to become more common, we're really on the verge of making apps that we can interact with in entirely new ways. Think of Cortana, or Siri or Amazon's Alexa - we now just expect computers to understand us: I remember writing a programme (that's how old and British I am) on a <a title="man, I'm so old" href="https://en.wikipedia.org/wiki/Amstrad_CPC">Z80 based computer</a> that would sample sounds and after thinking for a few minutes tell me if I'd said "hello" or "goodbye". Now I can say "Alexa, play some Pink Floyd" and it starts into "Shine on you crazy diamond" before I've had a chance to blow up my inflatable pig.

As a Windows developer, you've maybe got the itch to add these features to your own apps. Support for ink, voice commands and recognition, and super-smart stuff like face recognition. I know we - the folks in the Windows documentation team - did, and so we decided to write a sample app for you. Yesterday, <a title="Sample app on GitHub" href="http://github.com/Microsoft/Windows-appsample-virtualfridge">we pushed it to GitHub</a> for you to try out for yourself. And use the code.

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/VirtualFridge.png"><img class="alignnone  wp-image-2695" src="https://msdnshared.blob.core.windows.net/media/2016/04/VirtualFridge-300x191.png" alt="VirtualFridge" width="404" height="257" /></a>

&nbsp;

<b>Family Notes</b>

The Family Notes app is a noticeboard style app, designed to run on a tablet PC sitting in your kitchen (or glued to your fridge) and be used by the entire family. Once you've added your family members to it, you can create and assign them little sticky notes. You can type these notes (old school), or dictate them or even ink them with a stylus. The app is also listening for voice commands so you can say "Read note" or "Add note for John", and so on.

Most ambitious of all, we've used the <a title="It's not SkyNet, honestly" href="https://www.microsoft.com/cognitive-services/en-us/apis">Microsoft Cognitive Services</a> facial recognition service (you might have heard of its earlier name Project Oxford) to take images from the PC's webcam, and try to recognize anyone standing in front of it. So when I walk to up to the computer, the app "sees" me, and highlights the notes for me. At first it feels like magic, but then it just works and feels normal, like something computers should just be doing. We decided <a title="Minitory Report" href="https://www.youtube.com/watch?v=7bXJ_obaiYQ">not to play advertising tailored to you</a> at this time..

Here's a low-budget video clip of the app in action. I promise it's better than this video makes it look:

&nbsp;

<iframe src="https://www.youtube.com/embed/i7uLWeQNrFE" width="459" height="344" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

&nbsp;

<strong> How does it work?</strong>

The code sample is well documented, but we've also got a series of blog posts coming up on the <a title="This is a more corporate blog, so I have to be on my best behavior to post to it." href="https://blogs.windows.com/buildingapps/">Building Apps for Windows Blog</a> in the few weeks that delve into the more interesting aspects and the challenges we faced (so you don't have to!). For example, if you want to know how to serialize ink, yeah, we worked that out. Or have voice commands <em>and</em> dictation in the same app? Nailed it.

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/Logo.png"><img class="alignnone size-medium wp-image-2685" src="https://msdnshared.blob.core.windows.net/media/2016/04/Logo-300x145.png" alt="Logo" width="300" height="145" /></a>]]></content:encoded>
    </item>
  </channel>
</rss>