Wolvenspud

player

Oct 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Graphics;
  8. using Microsoft.Xna.Framework.Input;
  9. using Microsoft.Xna.Framework.Audio;
  10. namespace GameTemplate
  11. {
  12.    
  13.     public class Player : Entity
  14.     {
  15.         public Camera2d Tehcamera;
  16.        
  17.         public Player(Vector2 StartPosition, Texture2D SetSprite) : base(StartPosition,SetSprite)
  18.         {
  19.             DrawDepth = 0;
  20.         }
  21.  
  22.         public override void Update(float DT)
  23.         {
  24.             Velocity = Vector2.Zero;
  25.             if ((Keyboard.GetState().IsKeyDown(Keys.W) || Keyboard.GetState().IsKeyDown(Keys.Up)) && !WallUp)
  26.             {
  27.                 Velocity.Y = -Speed;
  28.             }
  29.             if ((Keyboard.GetState().IsKeyDown(Keys.S) || Keyboard.GetState().IsKeyDown(Keys.Down)) && !WallDown)
  30.             {
  31.                 Velocity.Y = Speed;
  32.             }
  33.             if ((Keyboard.GetState().IsKeyDown(Keys.A) || Keyboard.GetState().IsKeyDown(Keys.Left)) && !WallLeft)
  34.             {
  35.                 Velocity.X = -Speed;
  36.             }
  37.             if ((Keyboard.GetState().IsKeyDown(Keys.D) || Keyboard.GetState().IsKeyDown(Keys.Right)) && !WallRight)
  38.             {
  39.                 Velocity.X = Speed;
  40.             }
  41.  
  42.             Position.X += Game1.UpdateinputX(DT);
  43.             Position.Y += Game1.UpdateinputY(DT);
  44.             base.Update(DT);
  45.             Tehcamera.Pos = Position;
  46.         }
  47.  
  48.         public void SewtCamera(Camera2d cam)
  49.         {
  50.             Tehcamera = cam;
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment