Beispiel #1
0
 /// <summary>
 /// Cổng vào của Game.
 /// </summary>
 static void Main(string[] args)
 {
     using (TankWarsGame tankWarsGame = new TankWarsGame())
     {
         tankWarsGame.Run();
     }
 }
Beispiel #2
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(TankWarsGame tankWars, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
Beispiel #3
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(TankWarsGame tankWars, bool loadingIsSlow,
                                params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in tankWars.GetScreens())
            {
                screen.ExitScreen();
            }

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(tankWars,
                                                            loadingIsSlow,
                                                            screensToLoad);

            tankWars.AddScreen(loadingScreen);
        }
Beispiel #4
0
        public virtual void Draw(MenuScreen screen, bool isSelected, GameTime gameTime)
        {
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = ((float)Math.Sin(time * 6)) * 0.25f + 0.75f;

            float scale = 1;

            Color color = isSelected ? Color.Yellow * pulsate : Color.Red;

            color *= screen.TransitionAlpha;

            TankWarsGame tankWars    = screen.TankWars;
            SpriteBatch  spriteBatch = tankWars.SpriteBatch;
            SpriteFont   font        = tankWars.Font;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            spriteBatch.DrawString(font, text, position, color, 0,
                                   origin, scale, SpriteEffects.None, 0);
        }