Ejemplo n.º 1
0
        private void drawText(Interstellar.GameState gameState)
        {
            // Score
            spriteBatch.DrawString(font, "SCORE", new Vector2(), Color.White);
            spriteBatch.DrawString(font, world.Score.ToString(), new Vector2(0, font.LineSpacing - LineSpacingReduction), Color.White);

            // High score
            Vector2 size = font.MeasureString("HIGH SCORE");

            spriteBatch.DrawString(font, "HIGH SCORE", new Vector2(ViewportWidth - size.X, 0), Color.White);
            size = font.MeasureString(world.HighScore.ToString());
            spriteBatch.DrawString(font, world.HighScore.ToString(), new Vector2(ViewportWidth - size.X, font.LineSpacing - LineSpacingReduction), Color.White);

            if (gameState == Interstellar.GameState.Ready)
            {
                drawStringAtCenter("READY");
            }
            else if (gameState == Interstellar.GameState.Paused)
            {
                drawStringAtCenter("PAUSED");
            }
            else if (gameState == Interstellar.GameState.GameOver)
            {
                drawStringAtCenter("GAME OVER");
            }
        }
Ejemplo n.º 2
0
 public void Update(float dt, Interstellar.GameState gameState)
 {
     if (gameState == Interstellar.GameState.Playing)
     {
         playerController.Update(dt);
         enemyController.Update(dt);
         bulletController.Update(dt);
     }
     particleController.Update(dt);
 }
Ejemplo n.º 3
0
        public void Render(Interstellar.GameState gameState)
        {
            updateCamera();

            graphicsDevice.Clear(Color.Black);

            // Draw scene to render target
            graphicsDevice.SetRenderTarget(renderTarget);

            spriteBatch.Begin(blendState: BlendState.AlphaBlend, transformMatrix: Cam.TransformMatrix);

            drawBorder();

            foreach (Particle particle in world.Particles)
            {
                drawParticle(particle);
            }

            if (!world.Player.Dead)
            {
                drawShip(world.Player);
            }

            foreach (Ship enemy in world.Enemies)
            {
                drawShip(enemy);
            }

            foreach (Bullet bullet in world.Bullets)
            {
                drawBullet(bullet);
            }

            spriteBatch.End();

            // Generate bloom and draw to screen
            Texture2D bloom = bloomFilter.Draw(renderTarget, ViewportWidth, ViewportHeight);

            graphicsDevice.SetRenderTarget(null);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
            spriteBatch.Draw(renderTarget, new Rectangle(0, 0, ViewportWidth, ViewportHeight), Color.White);
            spriteBatch.Draw(bloom, new Rectangle(0, 0, ViewportWidth, ViewportHeight), Color.White);

            drawText(gameState);

            spriteBatch.End();
        }