Esempio n. 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            switch (GameElements.currentState)
            {
            case GameElements.State.Run:     //kör själva spelet
                GameElements.RunDraw(spriteBatch);
                break;

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

            case GameElements.State.Quit:     // avsluta spelet
                spriteBatch.Begin();
                this.Exit();
                break;

            default:     // Menyn
                GameElements.MenuDraw(spriteBatch);
                break;
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Esempio n. 2
0
        protected override void Update(GameTime gameTime)
        {
            //Stänger av spelet om man trycker på back-knappen på gamepaden:
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            switch (GameElements.currentState) // kollar vilket state spelet är i
            {
            case GameElements.State.Run:       // kör själva spelet
                GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime);

                break;

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

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

            default:     // Menu
                GameElements.currentState = GameElements.MenuUpdate(gameTime);
                break;
            }

            base.Update(gameTime);
        }
Esempio n. 3
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     GameElements.LoadContent(Content, Window, GraphicsDevice); // kallar på loadcontent i GameElements
 }
Esempio n. 4
0
 protected override void Initialize()
 {
     GameElements.currentState = GameElements.State.Menu;
     GameElements.Initialize();
     base.Initialize();
 }