Example #1
0
 public Player(Game game, AnimatedSprite sprite)
 {
     gameRef = (Game1)game;
     camera = new Camera(gameRef.ScreenRectangle);
     this.sprite = sprite;
     camera.LockToSprite(sprite);
 }
Example #2
0
 public Player(Game game, AnimatedSprite sprite)
 {
     gameRef = (Game1)game;
     camera = new Camera(gameRef.ScreenRectangle);
     this.sprite = sprite;
     camera.LockToSprite(sprite);
     playerrect = new Rectangle(
             (int)sprite.Position.X,
             (int)sprite.Position.Y,
             sprite.Width,
             sprite.Height);
 }
Example #3
0
 public Character(Entity entity, AnimatedSprite sprite)
 {
     this.entity = entity;
     this.sprite = sprite;
 }
Example #4
0
 public void LockToSprite(AnimatedSprite sprite)
 {
     position.X = sprite.Position.X + sprite.Width / 2
                     - (viewportRectangle.Width / 2);
     position.Y = sprite.Position.Y + sprite.Height / 2
                     - (viewportRectangle.Height / 2);
     LockCamera();
 }
Example #5
0
        protected void createPlayer()
        {
            Texture2D spriteSheet = Game.Content.Load<Texture2D>(@"PlayerSprites\char4");
            Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>();

            Animation animation = new Animation(3, 50, 50, 0, 0);
            animations.Add(AnimationKey.Down, animation);
            animation = new Animation(3, 50, 50, 0, 50);
            animations.Add(AnimationKey.Up, animation);
            animation = new Animation(3, 50, 50, 0, 100);
            animations.Add(AnimationKey.Right, animation);
            animation = new Animation(3, 50, 50, 0, 150);
            animations.Add(AnimationKey.Left, animation);
            Vector2 start = new Vector2(3 * Engine.TileHeight, 3 * Engine.TileWidth);
            AnimatedSprite sprite = new AnimatedSprite(spriteSheet, animations,start);
            player = new Player(GameRef, sprite);
        }