예제 #1
0
 public override void Update(GameTime gameTime, List <Kogel> sprites, SpriteEffects effect, ITransform trans)
 {
     Direction = new Vector2((float)Math.Cos(0), (float)Math.Sin(0));
     // naar rechts //
     if (input.LeesInput().Y == 1 && effect == SpriteEffects.None)
     {
         LinearVelocity = 4f;
         Position       = new Vector2(trans.positie.X + 78, trans.positie.Y + 40);
         AddBullet(sprites);
     }
     // naar links //
     if (input.LeesInput().Y == 1 && effect == SpriteEffects.FlipHorizontally)
     {
         LinearVelocity = -4f;
         Position       = new Vector2(trans.positie.X - 2, trans.positie.Y + 40);
         AddBullet(sprites);
     }
     LinearVelocity = 0;
 }
        public void Update(GameTime gameTime)
        {
            if (input.LeesInput().X != -1 || input.LeesInput().X != 1)
            {
                frameB.Add((new AnimationFrame(new Rectangle(0, -4, 80, 94))));
                CurrentFrame = frameB[0];
            }

            if (input.LeesInput().X == 1 || input.LeesInput().X == -1)
            {
                for (int jj = 0; jj <= 400; jj += 80)
                {
                    frameM.Add(new AnimationFrame(new Rectangle(jj, 94, 80, 94)));
                }
                WalkM(gameTime);
            }

            if (input.LeesInput().Y == 1)
            {
                frameS.Add(new AnimationFrame(new Rectangle(0, 276, 80, 94)));
                CurrentFrame = frameS[0];
            }
        }
예제 #3
0
        public void Update(GameTime gameTime, Rectangle hero, int x, IGameCommand moveCommand)
        {
            if (trans.positie.X < 0)
            {
                trans.positie = new Vector2(0, hero.Y);
            }

            if (trans.positie.X > x - hero.Width)
            {
                trans.positie = new Vector2(x - hero.Width, hero.Y);
            }

            foreach (Rectangle blok in detectedblokken)
            {
                if (VanBoven(hero, blok))
                {
                    moveCommand.snelheid = Vector2.Zero;
                    moveCommand.spring   = false;
                }

                // hero mag nooit onder de grond gaan //
                if (trans.positie.Y > 1595)
                {
                    trans.positie = new Vector2(trans.positie.X, 1595);
                }
                if (!VanBoven(hero, blok) && trans.positie.Y < 1595 && input.LeesInput().X == 1 && !CheckCollision(hero, blok) ||
                    !VanBoven(hero, blok) && trans.positie.Y < 1595 && input.LeesInput().X == -1 && !CheckCollision(hero, blok))
                {
                    moveCommand.spring = true;
                }
                if (VanLinks(hero, blok) && input.LeesInput().X == 1)
                {
                    if (input.LeesInput().X == -1)
                    {
                        break;
                    }
                    trans.positie = new Vector2(blok.X - hero.Width - 2, hero.Y);
                }
                if (VanRechts(hero, blok) && input.LeesInput().X == -1)
                {
                    if (input.LeesInput().X == 1)
                    {
                        break;
                    }
                    trans.positie = new Vector2(blok.X + blok.Width + 2, hero.Y);
                }
                // ervoor zorgen dat die niet door de blok kan van onder //
                if (VanOnder(hero, blok))
                {
                    moveCommand.snelheid += new Vector2(0, +0.15f);
                }
            }
        }
예제 #4
0
        public void Update(GameTime gameTime, SoundEffect spring)
        {
            walk.Update(gameTime);

            Movecommand.Execute(gameTime, this, inputReader.LeesInput(), spring);

            _collisionRectangle.X = (int)positie.X;
            _collisionRectangle.Y = (int)positie.Y;
            CollisionRectangle    = _collisionRectangle;

            colli.Update(gameTime, CollisionRectangle, backgroundsize, Movecommand);

            foreach (var sprite in kogels.ToArray())
            {
                sprite.Update(gameTime, kogels, walk.sprite, this);
            }

            DeleteBullet();
        }
예제 #5
0
        public void ChangeDirection(GameTime gameTime)
        {
            if (input.LeesInput().X == -1)
            {
                sprite = SpriteEffects.FlipHorizontally;
            }

            if (input.LeesInput().X == 1)
            {
                sprite = SpriteEffects.None;
            }

            if (input.LeesInput().Y == -1 && input.LeesInput().X == -1)
            {
                sprite = SpriteEffects.FlipHorizontally;
            }

            if (input.LeesInput().Y == -1 && input.LeesInput().X == 1)
            {
                sprite = SpriteEffects.None;
            }
        }