コード例 #1
0
        protected override void Initialize()
        {
            base.Initialize();

            #region Assign Game Settings
            MaxX = graphics.GraphicsDevice.Viewport.Width;
            MaxY = graphics.GraphicsDevice.Viewport.Height;
            int MaxTitleX = graphics.GraphicsDevice.Viewport.TitleSafeArea.Width;
            int MaxTitleY = graphics.GraphicsDevice.Viewport.TitleSafeArea.Height;
            #endregion

            #region Assign Game Properties
            gameSpeed = 1f;
            gameOver  = false;
            score     = 0;
            #endregion

            #region Assign Game Objects
            proceduralStarBackground = new Background(MaxX, MaxY, bgStar);
            oldState         = Keyboard.GetState();
            destructableDict = new dustructablesDictionary();
            Destructibles    = new Queue <DestructibleObject>();
            Bullets          = new Queue <BulletObject>();
            Boons            = new Queue <BoonObject>();
            #endregion

            #region Initialize Player
            Vector2 shipSpeed       = new Vector2(7, 5); // 7 is horizontal speed, 5 is vertical speed
            Vector2 shipPos         = new Vector2(MaxTitleX / 2 - 10, MaxTitleY - 50);
            int     shipHealth      = 100;
            float   bonusAttraction = 300f;
            float   bonusGrabRadius = 35f;
            Ship = new PlayerShip(shipPos, shipHealth, shipSpeed, bonusAttraction, bonusGrabRadius);
            List <Texture2D> shipEmitTextures = new List <Texture2D>()
            {   // Put textures for ship particles here
                Content.Load <Texture2D>("pEngine/pStar")
            };
            Ship.Initialize(new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width, GraphicsDevice.Viewport.TitleSafeArea.Height),
                            new AnimatedSprite(Content.Load <Texture2D>("BshipAtlas"), 1, 3),
                            new ParticleEngine(shipEmitTextures, new Vector2(400, 240)));
            #endregion

            // Temporary
            bulletVelocity = 10 * gameSpeed; // Vertical bullet speed?
            fireCooldown   = 0;
            int[] ship1 = new int[3] {
                50, 10, 3
            };
            destructableDict.dict.Add("ship1", ship1);
            // /TEMPORARY

            destructibleObjects = new ObjectManager();
        }
コード例 #2
0
        protected override void Initialize()
        {
            base.Initialize();

            #region Assign Game Settings
            MaxX = graphics.GraphicsDevice.Viewport.Width;
            MaxY = graphics.GraphicsDevice.Viewport.Height;
            int MaxTitleX = graphics.GraphicsDevice.Viewport.TitleSafeArea.Width;
            int MaxTitleY = graphics.GraphicsDevice.Viewport.TitleSafeArea.Height;
            #endregion

            #region Assign Game Properties
            gameSpeed = 1f;
            gameOver = false;
            score = 0;
            #endregion

            #region Assign Game Objects
            proceduralStarBackground = new Background(MaxX, MaxY, bgStar);
            oldState = Keyboard.GetState();
            destructableDict = new dustructablesDictionary();
            Destructibles = new Queue<DestructibleObject>();
            Bullets = new Queue<BulletObject>();
            Boons = new Queue<BoonObject>();
            #endregion

            #region Initialize Player
            Vector2 shipSpeed = new Vector2(7, 5); // 7 is horizontal speed, 5 is vertical speed
            Vector2 shipPos = new Vector2(MaxTitleX / 2 - 10, MaxTitleY - 50);
            int shipHealth = 100;
            float bonusAttraction = 300f;
            float bonusGrabRadius = 35f;
            Ship = new PlayerShip(shipPos, shipHealth, shipSpeed, bonusAttraction, bonusGrabRadius);
            List<Texture2D> shipEmitTextures = new List<Texture2D>()
            {   // Put textures for ship particles here
                Content.Load<Texture2D>("pEngine/pStar")
            };
            Ship.Initialize(new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width, GraphicsDevice.Viewport.TitleSafeArea.Height),
                            new AnimatedSprite(Content.Load<Texture2D>("BshipAtlas"), 1, 3),
                            new ParticleEngine(shipEmitTextures, new Vector2(400, 240)));
            #endregion

            // Temporary
            bulletVelocity = 10 * gameSpeed; // Vertical bullet speed?
            fireCooldown = 0;
            int[] ship1 = new int[3] { 50, 10, 3 };
            destructableDict.dict.Add("ship1", ship1);
            // /TEMPORARY

            destructibleObjects = new ObjectManager();
        }