Beispiel #1
0
 public GameEntity(Level level)
 {
     Level = level;
     MovementVector = new Vector2(0, 0);
     Speed = new Vector2(3.0f, 3.0f);
     Friction = new Vector2(2.0f, 5.0f);
     MaxSpeed = new Vector2(1.0f, 2.0f);
     DeathTimeout = 1.0f;
 }
Beispiel #2
0
 public Goomba(Level level, Vector2 startPosition)
     : base(level, startPosition)
 {
     Texture = level.Content.Load<Texture2D>("Goomba");
     Size = new Vector2(16, 16);
     Speed = new Vector2(1.0f, 3.0f);
     Direction = Direction.Left;
     Sprite = new Animator();
     Animations = new[]
         {
             new Animation(this, AnimationType.Run,   2, 0.5f, true),
             new Animation(this, AnimationType.Death, 1, 0.5f, false)
         }.ToDictionary(x => x.AnimationType);
     Sprite.SetAnimation(Animations[AnimationType.Run]);
 }
Beispiel #3
0
        protected override void Update(GameTime gameTime)
        {
            // Get keyboard state once so we can pass it through.
            _prevKeyboardState = _currentKeyboardState;
            _currentKeyboardState = Keyboard.GetState();

            // Previous keyboardstate was saved to prevent double taps:
            if (_currentKeyboardState.IsKeyDown(Keys.Escape)
                && !_prevKeyboardState.IsKeyDown(Keys.Escape))
                _level = new Level(Services,Rand);

            _level.Update(gameTime, _currentKeyboardState);

            base.Update(gameTime);
        }
Beispiel #4
0
        public Player(Level level)
            : base(level)
        {
            Texture = Level.Content.Load<Texture2D>("Mario");
            CurrentPosition = Level.StartPosition;
            Size = new Vector2(16, 16);
            Speed = new Vector2(5.0f, 3.3f);

            Sprite = new Animator();
            Animations = new[]
                {
                    new Animation(this, AnimationType.Stand, 1, 0.5f, false),
                    new Animation(this, AnimationType.Run,   2, 0.25f, true),
                    new Animation(this, AnimationType.Jump,  2, 0.5f, false),
                    new Animation(this, AnimationType.Death, 1, 0.5f, false),
                    new Animation(this, AnimationType.Skid,  1, 0.5f, false)
                }.ToDictionary(x => x.AnimationType);
            Sprite.SetAnimation(Animations[AnimationType.Stand]);
        }
Beispiel #5
0
 public Enemy(Level level, Vector2 startPosition)
     : base(level)
 {
     CurrentPosition = startPosition;
 }
Beispiel #6
0
 protected override void LoadContent()
 {
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     _level = new Level(Services, Rand);
 }