Example #1
0
        protected override void Update(GameTime gameTime)
        {
            frameCount++;
            elapsed += gameTime.ElapsedGameTime.Milliseconds;

            if (elapsed >= 1000)
            {
                fps = frameCount.ToString();

                frameCount = 0;
                elapsed    = 0;
            }

            //Update the in[put state for the active module
            foreach (Player p in PROP.players)
            {
                p.input.Update();
            }
            PROP.allInput.Update();

            //Store current module
            ModuleName pre = activeModule.moduleName;

            //Get the next Module name
            ModuleName post = activeModule.Update(gameTime);

            //If change, then tell old one and new one of the change
            if (pre != post)
            {
                //Inform the 'old' module that it is no longer active
                activeModule.Deactivated();

                //Check to exit the game
                if (post == ModuleName.Exit)
                {
                    Exit();
                }
                else
                {
                    //Update module and possibly change active module
                    activeModule = modules[(int)post];

                    //Inform the 'new' module that it has been activated
                    activeModule.Activated();
                }
            }

            base.Update(gameTime);
        }