예제 #1
0
        public override void Update(GameTime gameTime)
        {
            Animationen.Update(gameTime);

            Velocity += new Vector2(Velocity.X, Bewegungsgeschwindigkeit);
            Position += Velocity;

            if (Watch.ElapsedMilliseconds >= sekunden)
            {
                sekunden = GameMain.Zufall.Next(1000, 5000);

                if (richtung == 1)
                {
                    richtung = 0;
                }
                else
                {
                    richtung = 1;
                }
                Watch.Restart();
            }

            if (richtung == 0)
            {
                Move(new Vector2(-Bewegungsgeschwindigkeit * gameTime.ElapsedGameTime.Milliseconds, 0));
            }
            else
            {
                Move(new Vector2(Bewegungsgeschwindigkeit * gameTime.ElapsedGameTime.Milliseconds, 0));
            }
        }
예제 #2
0
        public override void LoadContent(ContentManager content)
        {
            base.LoadContent(content);

            Animationen.Textur = content.Load <Texture2D>("Assets/zombie_tilesheet");

            var stehanimation = new Animation("Stehen");

            stehanimation.Breite = 80;
            stehanimation.Höhe   = 110;
            stehanimation.AddFrame(0);

            Animationen.AddAnimation(stehanimation);

            var laufanimation = new Animation("Laufen");

            laufanimation.Breite = 80;
            laufanimation.Höhe   = 110;
            laufanimation.AddFrame(9);
            laufanimation.AddFrame(10);

            Animationen.AddAnimation(laufanimation);

            Animationen.Play("Stehen");
        }
예제 #3
0
        public void Move(Vector2 delta)
        {
            Position += delta;

            Animationen.Play("Laufen");

            if (richtung == 0)
            {
                Effects = SpriteEffects.FlipHorizontally;
            }
            else if (richtung == 1)
            {
                Effects = SpriteEffects.None;
            }
        }