Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            #region ISWIDESCREEN
            if (!GraphicsAdapter.DefaultAdapter.IsWideScreen)
            {
                if (graphics.GraphicsDevice.DisplayMode.AspectRatio == 1.25f)
                {
                    ASPECTHD          = 16.0f / 9.0f;
                    ASPECTSD          = 5f / 4f;
                    ASPECTWIDTHRATIO  = 1280f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO       = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT    = 720f;
                    VIEWPORTWIDTH     = 1280f;
                }
                else
                {
                    ASPECTHD          = 16.0f / 9.0f;
                    ASPECTSD          = 4f / 3f;
                    ASPECTWIDTHRATIO  = 1024f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO       = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT    = 720f;
                    VIEWPORTWIDTH     = 1280;
                }
            }
            #endregion

            #region BACKGROUND
            tileMap          = Content.Load <Texture2D>(@"Barrier\" + nameTileMap);
            backgoundManager = new BackgroundPixelManager(this, ref tileMap, screen);
            Components.Add(backgoundManager);
            #endregion

            #region TANK
            tank   = Content.Load <Texture2D>(@"Tank\" + nameTank);
            player = new Tank(this, ref tank, screen);
            Components.Add(player);
            player.PutinStartPosition();
            #endregion

            #region INVASOR
            invasor         = Content.Load <Texture2D>(@"Invasors\" + nameInvasor);
            invasorsManager = new InvasorsManager(this, ref invasor, difficult.normal.ToString());
            Components.Add(invasorsManager);
            #endregion

            #region UFO
            ufo_t = Content.Load <Texture2D>(@"Ufo\" + "ufo_sheet");
            ufo   = new Ufo(this, ref ufo_t);
            Components.Add(ufo);
            ufo.PutinStartPosition();
            #endregion

            #region PENTAGRAM
            pentagam_sheet = Content.Load <Texture2D>(@"Pentagram\pentagram_sheet");
            pentagramP1    = new Pentagram(this, ref pentagam_sheet, Vector2.Zero);
            pentagramP2    = new Pentagram(this, ref pentagam_sheet, new Vector2(1280 - 120, 0));
            Components.Add(pentagramP1);
            Components.Add(pentagramP2);
            #endregion

            base.Initialize();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            #region ISWIDESCREEN
            if (!GraphicsAdapter.DefaultAdapter.IsWideScreen)
            {
                if (graphics.GraphicsDevice.DisplayMode.AspectRatio == 1.25f)
                {
                    ASPECTHD = 16.0f / 9.0f;
                    ASPECTSD = 5f / 4f;
                    ASPECTWIDTHRATIO = 1280f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT = 720f;
                    VIEWPORTWIDTH = 1280f;
                }
                else
                {
                    ASPECTHD = 16.0f / 9.0f;
                    ASPECTSD = 4f / 3f;
                    ASPECTWIDTHRATIO = 1024f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT = 720f;
                    VIEWPORTWIDTH = 1280;
                }

            }
            #endregion

            #region BACKGROUND
            tileMap = Content.Load<Texture2D>(@"Barrier\" + nameTileMap);
            backgoundManager = new BackgroundPixelManager(this, ref tileMap, screen);
            Components.Add(backgoundManager);
            #endregion

            #region TANK
            tank = Content.Load<Texture2D>(@"Tank\" + nameTank);
            player = new Tank(this, ref tank, screen);
            Components.Add(player);
            player.PutinStartPosition();
            #endregion

            #region INVASOR
            invasor = Content.Load<Texture2D>(@"Invasors\" + nameInvasor);
            invasorsManager = new InvasorsManager(this, ref invasor, difficult.normal.ToString());
            Components.Add(invasorsManager);
            #endregion

            #region UFO
            ufo_t = Content.Load<Texture2D>(@"Ufo\" + "ufo_sheet");
            ufo = new Ufo(this, ref ufo_t);
            Components.Add(ufo);
            ufo.PutinStartPosition();
            #endregion

            #region PENTAGRAM
            pentagam_sheet = Content.Load<Texture2D>(@"Pentagram\pentagram_sheet");
            pentagramP1 = new Pentagram(this, ref pentagam_sheet, Vector2.Zero);
            pentagramP2 = new Pentagram(this, ref pentagam_sheet, new Vector2(1280 - 120,0));
            Components.Add(pentagramP1);
            Components.Add(pentagramP2);
            #endregion

            base.Initialize();
        }