Advertisement
Guest User

Player

a guest
Mar 5th, 2012
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using Microsoft.Xna.Framework.Input;
  7. using Microsoft.Xna.Framework;
  8.  
  9. using Cerios.Miner.Cameras;
  10.  
  11. namespace Cerios.Miner.Entities
  12. {
  13.     public class SPlayer : Player
  14.     {
  15.         private Camera camera;
  16.  
  17.         public SPlayer()
  18.         {
  19.             camera = new Camera(CeriosMiner.Instance.GraphicsDevice.Viewport);
  20.         }
  21.  
  22.         public Camera GetCamera()
  23.         {
  24.             return camera;
  25.         }
  26.  
  27.         public override void Update()
  28.         {
  29.             Vector2 position = camera.Position;
  30.             if (Keyboard.GetState().IsKeyDown(Keys.A))
  31.             {
  32.                 position.X += 1;
  33.             }
  34.             else if (Keyboard.GetState().IsKeyDown(Keys.D))
  35.             {
  36.                 position.X -= 1;
  37.             }
  38.  
  39.             if (Keyboard.GetState().IsKeyDown(Keys.W))
  40.             {
  41.                 position.Y += 1;
  42.             }
  43.             else if (Keyboard.GetState().IsKeyDown(Keys.S))
  44.             {
  45.                 position.Y -= 1;
  46.             }
  47.  
  48.             camera.Position = position;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement