Пример #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);
            frameCounter.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
            var fps = string.Format("FPS: {0}", frameCounter.AverageFramesPerSecond);

            spriteBatch.Begin();

            //this.explosionSprite.Draw(gameTime, spriteBatch);
            backgroundSprite.Draw(gameTime, spriteBatch);
            starGenerator.Draw(gameTime, spriteBatch);

            enemyGenerator.Draw(gameTime, spriteBatch);

            if (spaceshipSprite.IsActive)
            {
                spaceshipSprite.Draw(gameTime, spriteBatch);
            }

            laserPool.Draw(gameTime, spriteBatch);

            explosionPool.Draw(gameTime, spriteBatch);

            this.gameOverScene.Draw(gameTime, spriteBatch);

            var scoreString     = string.Format("Score: {0}", this.score.ToString().PadLeft(7, '0'));
            var scoreStringSize = scoreFont.MeasureString(scoreString);

            spriteBatch.DrawString(scoreFont, scoreString, new Vector2(GraphicsDevice.Viewport.Width - scoreStringSize.X - 20, 5), Color.Yellow);

            #region Output Debug Information

            if (settings.ShowDebugInfo)
            {
                // FPS
                spriteBatch.DrawString(messageFont, fps, Vector2.One, Color.Yellow);

                // Spacecraft Information
                var spaceCraftInfo = string.Format("[Spacecraft] X = {0}, Y = {1}", spaceshipSprite.X, spaceshipSprite.Y);
                spriteBatch.DrawString(messageFont, spaceCraftInfo, new Vector2(1, 15), Color.Yellow);

                // Laser Pool Information
                var laserPoolCountStr = string.Format("[Laser Pool] Count = {0}", this.laserPool.Count);
                spriteBatch.DrawString(messageFont, laserPoolCountStr, new Vector2(1, 30), Color.Yellow);

                // Enemy Pool Information
                var enemyPoolCountStr = string.Format("[Enemy Pool] Count = {0}", this.enemyPool.Count);
                spriteBatch.DrawString(messageFont, enemyPoolCountStr, new Vector2(1, 45), Color.Yellow);

                // Explosion Pool Information
                var explPoolCountStr = string.Format("[Expln Pool] Count = {0}", this.explosionPool.Count);
                spriteBatch.DrawString(messageFont, explPoolCountStr, new Vector2(1, 60), Color.Yellow);

                // Viewport Information
                var viewportInfoStr = string.Format("[ Viewport ] Width = {0}, Height = {1}",
                                                    GraphicsDevice.Viewport.Width,
                                                    GraphicsDevice.Viewport.Height);
                spriteBatch.DrawString(messageFont, viewportInfoStr, new Vector2(1, 75), Color.Yellow);

                // Game time Information
                var gameTimeInfoStr = string.Format("[ GameTime ] Total = {0}", gameTime.TotalGameTime);
                spriteBatch.DrawString(messageFont, gameTimeInfoStr, new Vector2(1, 90), Color.Yellow);
            }


            #endregion

            spriteBatch.End();

            base.Draw(gameTime);
        }
Пример #2
0
        public void Draw(int frameExecuted)
        {
            var screen = this.machine.Screen;

            if (State != PlayStates.Quit)
            {
                screen.DrawScrollMap(maps[0], true, (int)(-ScrollX * 0.50), 0, 0, 0, 320, 136);
                screen.DrawScrollMap(maps[1], true, (int)(-ScrollX * 0.60), 0, 0, screen.Height - maps[1].Height - 16, 320, 136);
                screen.DrawScrollMap(maps[3], true, (int)(-ScrollX * 0.70), 0, 0, screen.Height - maps[3].Height - 16, 320, 136);
                screen.DrawScrollMap(maps[2], true, (int)(-ScrollX * 0.80), 0, 0, screen.Height - maps[2].Height, 320, 136);
                screen.DrawScrollMap(maps[4], true, (int)(-ScrollX * 0.90), 0, 0, screen.Height - maps[4].Height, 320, 136);
                screen.DrawScrollMap(maps[5], true, (int)(-ScrollX * 1.00), 0, 0, screen.Height - maps[5].Height, 320, 136);

                if (State != PlayStates.ChooseGamepadP1andP2)
                {
                    ammos.Draw(frameExecuted);
                    babies.Draw(frameExecuted);
                    mothers.Draw(frameExecuted);

                    ducks.Draw(frameExecuted);
                    flies.Draw(frameExecuted);

                    kabooms.Draw(frameExecuted);

                    opa.Draw(frameExecuted);
                    bombs.Draw(frameExecuted);
                    bullets.Draw(frameExecuted);
                    coins.Draw(frameExecuted);
                }

                switch (State)
                {
                case PlayStates.GameOver:

                    var yCenter = (screen.BoundsClipped.Height - 8) / 2;

                    screen.DrawText(GAMEOVER_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (GAMEOVER_TEXT.Length * 8)) / 2), yCenter);

                    if (Player != Players.Solo)
                    {
                        if (this.multiPage.State == MultiPlayPage.MultiStates.GameOver)
                        {
                            if (Score < this.multiPage.GetOpponentScore(this.Player))
                            {
                                screen.DrawText(MULTI_LOOSE_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_LOOSE_TEXT.Length * 8)) / 2), yCenter + 16);
                            }
                            else
                            {
                                screen.DrawText(MULTI_WIN_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_WIN_TEXT.Length * 8)) / 2), yCenter + 16);
                            }
                        }
                    }
                    else
                    {
                        // en solo seulement
                        if (Score > this.hiScore)
                        {
                            if (frameHiScore < 30)
                            {
                                screen.DrawText(GAMEOVER_HISCORE_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (GAMEOVER_HISCORE_TEXT.Length * 8)) / 2), yCenter + 16);
                                screen.DrawText(scoreString, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (scoreString.Length * 8)) / 2), yCenter + 24);
                            }

                            frameHiScore = (frameHiScore + 1) % 60;
                        }
                    }

                    break;

                case PlayStates.ChooseGamepadP1andP2:

                    if (Player == Players.Player1)
                    {
                        switch (MultiPlayState)
                        {
                        case MultiPlayStates.WaitStart:
                            screen.DrawText(MULTI_PRESS_START_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_PRESS_START_TEXT.Length * 8)) / 2), (screen.BoundsClipped.Height - 8) / 2);
                            break;

                        case MultiPlayStates.WaitOtherPlayer:
                            screen.DrawText(MULTI_WAITING_FOR_P2_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_WAITING_FOR_P2_TEXT.Length * 8)) / 2), (screen.BoundsClipped.Height - 8) / 2);
                            break;
                        }
                    }
                    else if (Player == Players.Player2)
                    {
                        switch (MultiPlayState)
                        {
                        case MultiPlayStates.WaitStart:
                            screen.DrawText(MULTI_PRESS_START_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_PRESS_START_TEXT.Length * 8)) / 2), (screen.BoundsClipped.Height - 8) / 2);
                            break;

                        case MultiPlayStates.WaitOtherPlayer:
                            screen.DrawText(MULTI_WAITING_FOR_P1_TEXT, screen.BoundsClipped.X + ((screen.BoundsClipped.Width - (MULTI_WAITING_FOR_P2_TEXT.Length * 8)) / 2), (screen.BoundsClipped.Height - 8) / 2);
                            break;
                        }
                    }

                    break;
                }

                // score
                screen.DrawText(SCORE_TEXT, screen.BoundsClipped.X + 4, 0);
                screen.DrawText(Score, screen.BoundsClipped.X + SCORE_TEXT.Length * fontWidth, 0);

                if (Player == Players.Solo)
                {
                    // hi score
                    screen.DrawText(hiScoreString, screen.BoundsClipped.Right - hiScoreString.Length * fontWidth - 4, 0);

#if DEBUG
                    // scroll
                    screen.DrawText((int)ScrollX, 160, 0);
#endif
                }
            }
            else
            {
                screen.Clear(Argb32.Black);
            }

            //screen.DrawText(frameExecuted == 1 ? "1" : "2", 0, 0);
        }