Example #1
0
        protected override void Initialize()
        {
            //WINDOW SETUP
            this.Window.Title = "Independance Day - Alpha";
            this.IsFixedTimeStep = false;

            PROP.screen = new Rectangle(0, 0, //top left of course
                                   graphics.GraphicsDevice.DisplayMode.Width,
                                   graphics.GraphicsDevice.DisplayMode.Height);

            PROP.screenCenter = new Vector2((float)PROP.screen.Width / 2.0f,
                                                  (float)PROP.screen.Height / 2.0f);

            if (false) //NORMAL FULLSCREEN
            {
                graphics.IsFullScreen = true;
                graphics.PreferredBackBufferHeight = (int)PROP.screen.Height;
                graphics.PreferredBackBufferWidth = (int)PROP.screen.Width;
                graphics.ApplyChanges();
            }
            else //DEBUG WINDOW
            {
                graphics.PreferredBackBufferHeight = (int)PROP.screen.Height - 90;
                graphics.PreferredBackBufferWidth = (int)PROP.screen.Width - 30;
                graphics.ApplyChanges();
            }

            //Create the Modules
            modules = new Module[6];
            modules[(int)ModuleName.Intro] = new Intro();
            modules[(int)ModuleName.MainMenu] = new MainMenu();
            modules[(int)ModuleName.Engine] = new Engine();
            modules[(int)ModuleName.Options] = new Options();
            modules[(int)ModuleName.Instructions] = new Instructions();
            modules[(int)ModuleName.Credits] = new Credits();

            for (int i = 0; i < 6; i++)
            {
                modules[i].refIntro = (Intro)modules[(int)ModuleName.Intro];
                modules[i].refMainMenu = (MainMenu)modules[(int)ModuleName.MainMenu];
                modules[i].refEngine = (Engine)modules[(int)ModuleName.Engine];
                modules[i].refInstructions = (Instructions)modules[(int)ModuleName.Instructions];
                modules[i].refOptions = (Options)modules[(int)ModuleName.Options];
                modules[i].refCredits = (Credits)modules[(int)ModuleName.Credits];
            }

            //Set the startup module
            activeModule = modules[(int)ModuleName.MainMenu];

            base.Initialize();
        }
Example #2
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);
        }