コード例 #1
0
 protected override void Update(GameTime gameTime)
 {
     if (stop)
     {
         Exit();
     }
     InputManager.Update(CanvasScale);
     GlobalTime.Update(gameTime);
     GlobalTime.ChangeSpeed(GameSpeed);
     SceneManager.UpdateScenes();
     ParticleManager.UpdateParticles();
     if (Convert.ToBoolean(ConfigManager.GetValue("enable_sky")))
     {
         sky.Update();
     }
     base.Update(gameTime);
 }
コード例 #2
0
        public override void Update()
        {
            float time = (float)GlobalTime.ElapsedGameMilliseconds / 1000;

            if (GameInput.IsButtonDown(NESInput.Up))
            {
                pos.Y -= VELOCITY * time;
                if (pos.Y < 0)
                {
                    pos.Y = 0;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Down))
            {
                pos.Y += VELOCITY * time;
                if (pos.Y + sprite.rectangle.Height > 240)
                {
                    pos.Y = 240 - sprite.rectangle.Height;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Left))
            {
                pos.X -= VELOCITY * time;
                if (pos.X < 0)
                {
                    pos.X = 0;
                }
            }
            if (GameInput.IsButtonDown(NESInput.Right))
            {
                pos.X += VELOCITY * time;
                if (pos.X + sprite.rectangle.Width > 256)
                {
                    pos.X = 256 - sprite.rectangle.Width;
                }
            }
            if (GameInput.IsButtonDown(NESInput.A))
            {
                if (shootDelay >= BULLET_SHOOT_DELAY)
                {
                    ShootBullet();
                }
            }
            if (particleDelay >= PARTICLE_SPAWN_DELAY)
            {
                ParticleManager.CreateParticles(ContentIndex.Pixel, new Vector2(pos.X + random.Next(6, 10), pos.Y + 14), PARTICLE_AMOUNT, new Vector2(0, 1), spread: 0, minSpeed: 10, maxSpeed: 20, Color.CornflowerBlue, colorHueShift: 1, 1);
                particleDelay -= PARTICLE_SPAWN_DELAY;
            }

            if (speed > 0)
            {
                GlobalTime.ChangeSpeed(Easing.ApplyEasingFromOne(1 - speed, EasingMode.CubicIn));
                speed -= (time * 5);
            }
            else
            {
                speed = 0;
            }

            if (shootDelay < BULLET_SHOOT_DELAY)
            {
                shootDelay += time;
            }
            if (particleDelay < PARTICLE_SPAWN_DELAY)
            {
                particleDelay += time;
            }

            bbox.X = (int)pos.X;
            bbox.Y = (int)pos.Y;

            base.Update();
        }