Ejemplo n.º 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.Black);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            //Title menu
            if (gameState == 0)
            {
                level.Draw(gameTime, spriteBatch, gameState);
                hud.DrawMenu(spriteBatch, gameState);
            }
            //Playing mode
            else if (gameState == 1)
            {
                level.Draw(gameTime, spriteBatch, gameState);
                hud.Draw(gameTime, spriteBatch);
            }
            //Instructions
            else if (gameState == 2)
            {
                level.Draw(gameTime, spriteBatch, gameState);
                hud.DrawMenu(spriteBatch, gameState);
            }
            //Pause screen in game
            else if (gameState == 5)
            {
                hud.DrawMenu(spriteBatch, gameState);
            }
            else
            {
                level.Draw(gameTime, spriteBatch, gameState);
                hud.DrawMenu(spriteBatch, gameState);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
        public void Draw(GameTime gt, SpriteBatch sb, int gs)
        {
            if (height < 12800)
            {
                for (int i = 0; i < bgList.Length; i++)
                {
                    sb.Draw(bgList[i], new Vector2(bgOffsetList[i], i * 100 + (height % 100) - 100), Color.White);
                }
            }
            else if (height < 104000)
            {
                for (int i = 0; i < bgList.Length; i++)
                {
                    sb.Draw(bgList[i], new Vector2(bgOffsetList[i], i * 100 + (height % 500 / 5) - 100), Color.White);
                }
            }
            else
            {
                for (int i = 0; i < bgList.Length; i++)
                {
                    sb.Draw(bgList[i], new Vector2(bgOffsetList[i], i * 100 + ((height % 100000) / 1000) - 100), Color.White);
                }
            }

            if (height > 15000000)
            {
                sb.Draw(moon, new Vector2(0, (0 + height % 15000000 / 10000) - moon.Height), Color.White);
            }

            //Dont draw ameplay things at the menus
            if (gs == 1 || gs == 3)
            {
                foreach (Collectible col in collectiblesList)
                {
                    col.Draw(sb, gt);
                }

                foreach (Collidable col in collidablesList)
                {
                    col.Draw(sb, gt);
                    if (col.position.X < (0 - col.spriteMask.Width) && col.direction == 1)
                    {
                        hud.DrawWarningLabel(sb, (int)(col.position.Y - col.spriteMask.Height / 2), 1);
                    }
                    else if (col.position.X > 480 && col.direction == -1)
                    {
                        hud.DrawWarningLabel(sb, (int)(col.position.Y - col.spriteMask.Height / 2), -1);
                    }
                }
                player.Draw(gt, sb);
            }

            if (!playerAlive)
            {
                hud.DrawMenu(sb, 9);
            }

            if (height > 18700000)
            {
                sb.Draw(resources.bigBlank, Vector2.Zero, Color.White * (float)(height % 18700000 / 1000000));
            }
        }