Пример #1
0
        public void Update(float axisUpDown, bool shoot)
        {
            if (Lost)
            {
                return;
            }
            shootCoolDown.Update(time.AbsoluteTime);
            //remove outside bullet - lazy remove (once per frame one bullet is removed)
            foreach (var bullet in bullets)
            {
                if (bullet.MinY > 1.0f)
                {
                    bullets.Remove(bullet);
                    break;
                }
            }
            HandleCollisions();

            UpdatePlayer(axisUpDown, shoot);
            MoveEnemies();
            MoveBullets();

            if (0 == enemies.Count && 0 == bullets.Count)
            {
                //game is won -> start new, but faster
                CreateEnemies();
                enemySpeed += 0.05f;
            }
        }
Пример #2
0
        public void Update(float absoluteTime, float axisUpDown, bool shoot)
        {
            if (Lost)
            {
                return;
            }
            shootCoolDown.Update(absoluteTime);
            //remove outside bullet - lazy remove
            foreach (Box2D bullet in bullets)
            {
                if (bullet.Y > 1.0f)
                {
                    bullets.Remove(bullet);
                    return;
                }
            }
            HandleCollisions();

            var timeDelta = absoluteTime - lastUpdateTime;

            lastUpdateTime = absoluteTime;
            UpdatePlayer(absoluteTime, timeDelta, axisUpDown, shoot);
            MoveEnemies(timeDelta);
            MoveBullets(timeDelta);

            if (0 == enemies.Count && 0 == bullets.Count)
            {
                //game is won -> start new, but faster
                CreateEnemies();
                enemySpeed += 0.05f;
            }
        }
Пример #3
0
        private void Update(float updatePeriod)
        {
            shootCoolDown.Update(time.AbsoluteTime);
            if (Lost)
            {
                return;
            }

            float axisLeftRight = Keyboard.GetState()[Key.Left] ? -1.0f : Keyboard.GetState()[Key.Right] ? 1.0f : 0.0f;
            bool  shoot         = Keyboard.GetState()[Key.Space];

            Update(updatePeriod, axisLeftRight, shoot);
        }
Пример #4
0
        private void Update(IInput input, float updatePeriod)
        {
            shootCoolDown.Update(time.AbsoluteTime);
            if (Lost)
            {
                return;
            }

            float axisLeftRight = input.IsButtonDown("Left") ? -1f : input.IsButtonDown("Right") ? 1f : 0f;
            bool  shoot         = input.IsButtonDown("Space");

            Update(updatePeriod, axisLeftRight, shoot);
        }
Пример #5
0
        private void Update(float updatePeriod)
        {
            shootCoolDown.Update((float)timeSource.Elapsed.TotalSeconds);
            if (Lost)
            {
                return;
            }

            float axisLeftRight = Keyboard.GetState()[Key.Left] ? -1.0f : Keyboard.GetState()[Key.Right] ? 1.0f : 0.0f;
            bool  shoot         = Keyboard.GetState()[Key.Space];

            Update(updatePeriod, axisLeftRight, shoot);
        }