示例#1
0
        // Draw works together with LoadContent and draws the loaded content (Like sprites, sound files, etc.)
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            // Same Switch as in Game1.Update except we're drawing the elements.
            switch (GameElements.currentState)
            {
            case GameElements.State.Run:
                GameElements.RunDraw(spriteBatch);
                break;

            case GameElements.State.AddHS:
                GameElements.AddHSDraw(spriteBatch);
                break;

            case GameElements.State.HighScore:
                GameElements.HighScoreDraw(spriteBatch);
                break;

            case GameElements.State.Quit:
                this.Exit();
                break;

            default:
                GameElements.MenuDraw(spriteBatch);
                break;
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
示例#2
0
        // Update loads in all necessary data to make the game function like movement controlls or gameTime
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            switch (GameElements.currentState)
            {
            // Run the game
            case GameElements.State.Run:
                GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime);
                break;

            case GameElements.State.AddHS:
                GameElements.currentState = GameElements.AddHSUpdate(gameTime, Window, Content);
                break;

            case GameElements.State.HighScore:
                GameElements.currentState = GameElements.HighScoreUpdate(Window);
                break;

            // Quit the game
            case GameElements.State.Quit:
                this.Exit();
                break;

            // Menu
            default:
                GameElements.currentState = GameElements.MenuUpdate(gameTime);
                break;
            }
            base.Update(gameTime);
        }
示例#3
0
 // When game starts, LoadContent is called to load all sprites, sound files etc.
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     GameElements.LoadContent(Content, Window);
 }
示例#4
0
 // When game starts, Initialise is called to make the game run.
 protected override void Initialize()
 {
     GameElements.currentState = GameElements.State.Menu;
     GameElements.Initialize();
     base.Initialize();
 }