コード例 #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            _snowEmitter.Update(gameTime);

            base.Update(gameTime);
        }
コード例 #2
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) && _escState)
            {
                _escState  = false;
                _escWaarde = !_escWaarde;
                menu.Enable(_escWaarde);
                IsMouseVisible = _escWaarde;
            }
            else if (Keyboard.GetState().IsKeyUp(Keys.Escape) && !_escState)
            {
                _escState = true;
            }

            move.Update(player);
            player.PhysicsUpdate(gameTime);

            menu.Update(gameTime);

            foreach (Blok item in level.blokArray)
            {
                if (item != null)
                {
                    bool colCheck = player.CheckCollision(item.HitBox);
                    if (colCheck)
                    {
                        if (item.getTypeBlock == Blok.TypeBlock.Coin)
                        {
                            Resources.Sounds["coin"].Play();
                            item.isVisble = false;
                            attributes.AddCoins();
                        }
                        if (item.getTypeBlock == Blok.TypeBlock.Water)
                        {
                            if (player.Velocity.X > 0)
                            {
                                player.Velocity.X = 0.1f;
                            }
                            else if (player.Velocity.X < 0)
                            {
                                player.Velocity.X = -0.1f;
                            }
                        }

                        if (item.getTypeBlock == Blok.TypeBlock.Enemy)
                        {
                            attributes.DecreasLife();
                        }

                        if (item.getTypeBlock == Blok.TypeBlock.Chest)
                        {
                            attributes.AddCoins(10);
                        }

                        if (item.getTypeBlock == Blok.TypeBlock.Exit)
                        {
                            player.Position = new Vector2(250, 200);
                            level.CreateWorld(level.Level1);
                            level.Snow = true;
                        }
                    }
                }
            }

            attributes.Update();
            player.Update(gameTime);


            camera.Follow(player);
            foreach (var sb in _scrollingBackgrounds)
            {
                sb.Update(gameTime);
            }
            if (level.Snow)
            {
                _snowEmitter.Update(gameTime);
            }
            level.UpdateWorld(gameTime);
            base.Update(gameTime);
        }