Yeah, I am using the awesome tutorial from http://create.msdn.com/gamedevelopment , and what a lazy blogger I am.  But like following a trail in the forest, sometimes the goal is similar, but maybe where I make my camp isn’t going to be the same as the people whose trail I am following, or I stop and fish at a stream, or etc.

The diversion is yet to come, but it will.  I am reviewing the third part, Player input which doesn’t have a video.

After working through this part of the tutorial, I simplified my code by eliminating all of the XBox and Windows code, by changing the code to:

Code Snippet
  1. private void UpdatePlayer(GameTime gameTime)
  2.         {
  3.             // Windows Phone Controls
  4.             while (TouchPanel.IsGestureAvailable)
  5.             {
  6.                 GestureSample gesture = TouchPanel.ReadGesture();
  7.                 if (gesture.GestureType == GestureType.FreeDrag)
  8.                 {
  9.                     player.Position += gesture.Delta;
  10.                 }
  11.             }            
  12.  
  13.             // Make sure that the player does not go out of bounds
  14.             player.Position.X = MathHelper.Clamp(player.Position.X, 0, GraphicsDevice.Viewport.Width - player.Width);
  15.             player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, GraphicsDevice.Viewport.Height - player.Height);
  16.         }

That wasn’t hard, I simply comment out the code that I thought was for the XBox and Windows, and then when the code ran, I deleted the code so that the overall code was shorter and to the point.

I also changed the “player” asset which is the aircraft to a dolphin that is manning an anti-aircraft gun.  Here is a visual step by step:

Start by finding the player.png in the solution explorer, you can open the Properties box by pressing F4, I added the comments around the player.Initialize line:

image

Now add an existing png instead of the ship, in this case, a dolphin with a gun to blast water bottles that are entering the water from the land:

image

Browse to the image, in this case I select the dolphinAA.png

image

Note that the dolphinAA.png now has the default name of dolphinAA

image

Now we want to use the DolphinAA.png in place of the Player.png, so first change the Player.png asset name to player1, each asset must be uniquely named:

image

Change the default asset name for dolphinAA.png from dolphinAA to player

image

 

Once you get everything done, you should now see the following (the image will be the one you use), the image should move with your mouse if you are using a computer and with your finger if you load it to the phone.

image