Example #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // De olika "Draw" metoderna nedan anroppas beroende på i vilken gamestate man är.
            if (gamestates == Gamestates.startmenu)
            {
                spriteBatch.Begin();
                startmenu.Draw(spriteBatch);
                spriteBatch.End();
            }


            if (gamestates == Gamestates.levelmenu)
            {
                spriteBatch.Begin();
                levelMenu.Draw(spriteBatch);
                spriteBatch.End();
            }

            if (gamestates == Gamestates.shopmenu)
            {
                spriteBatch.Begin();
                shopmenu.Draw(spriteBatch, buyJump);
                spriteBatch.End();
            }


            if (gamestates == Gamestates.inGame)
            #region InGame Draw
            {
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.ViewMatrix);

                for (float i = 0; i < 100; i++)
                {
                    spriteBatch.Draw(background, backgroundTest, Color.White);
                    backgroundTest = new Vector2(backgroundWidth * i, 0);
                }


                player.Draw(spriteBatch);
                foreach (ObjektBasklassen objekten in Objekten)
                {
                    objekten.Draw(spriteBatch);
                }

                spriteBatch.End();
            }
            #endregion


            if (gamestates == Gamestates.pausemenu)
            {
                spriteBatch.Begin();
                pausemenu.Draw(spriteBatch);
                spriteBatch.End();
            }

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Example #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // De olika "Draw" metoderna nedan anroppas beroende på i vilken värde "gamestates" har.

            //Ritar ut startmenyn.
            if (gamestates == Gamestates.startmenu)
            {
                spriteBatch.Begin();
                startmenu.Draw(spriteBatch);
                spriteBatch.End();
            }


            //Ritar ut levelmenyn.
            if (gamestates == Gamestates.levelmenu)
            {
                spriteBatch.Begin();
                levelMenu.Draw(spriteBatch, comicSansFont);
                spriteBatch.End();
            }


            //Ritar ut shopmenyn.
            if (gamestates == Gamestates.shopmenu)
            {
                spriteBatch.Begin();
                shopmenu.Draw(spriteBatch, comicSansFont);
                spriteBatch.End();
            }


            //Ritar ut leveln och player.
            if (gamestates == Gamestates.inGame)

            #region InGame Draw (Samuel)
            {
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.ViewMatrix);

                for (float i = 0; i < 100; i++)
                {
                    spriteBatch.Draw(background, backgroundTest, Color.White);
                    backgroundTest = new Vector2(backgroundWidth * i, 0);
                }

                lvl1.Draw(spriteBatch);
                player.Draw(spriteBatch);

                spriteBatch.End();
            }
            #endregion


            //Ritar ut pausmenyn.
            if (gamestates == Gamestates.pausemenu)
            {
                spriteBatch.Begin();
                pausemenu.Draw(spriteBatch);
                spriteBatch.End();
            }


            //Ritar ut gameovermenyn.
            if (gamestates == Gamestates.gameOverMenu)
            {
                spriteBatch.Begin();
                gameOverMenu.Draw(spriteBatch);
                spriteBatch.End();
            }

            //Ritar ut youwinmenyn
            if (gamestates == Gamestates.youWinMenu)
            {
                spriteBatch.Begin();
                youWinMenu.Draw(spriteBatch);
                spriteBatch.End();
            }
            #endregion
            //===========================================================================================================================
            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }